forked from 2206-devops-batch/flask-demo
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
30 lines (23 loc) · 1.06 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Most of the time, Alpine is a great base image to start with.
# If we're building a container for Python, we use something different.
# Learn why here: https://pythonspeed.com/articles/base-image-python-docker-images/
# TLDR: Alpine is very slow when it comes to running Python!
# STEP 1: Install base image. Optimized for Python.
FROM python:3.10.5-slim-bullseye
# STEP 2: Copy the source code in the current directory to the container.
# Store it in a folder named /app.
ADD . /app
# STEP 3: Set working directory to /app so we can execute commands in it
WORKDIR /app
# STEP 4: Install required dependencies.
RUN pip install -r requirements.txt
# STEP 5: Declare environment variables
ENV FLASK_APP=app.py \
FLASK_ENV=development
# STEP 6: Expose the port that Flask is running on
EXPOSE 5000
# STEP 7: Run Flask!
# For example, to check every five minutes or so that a web-server is able to serve the site’s main page within three seconds:
HEALTHCHECK --interval=5m --timeout=3s \
CMD curl -f http://localhost/ || exit 1
CMD ["flask", "run", "--host=0.0.0.0"]