-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
46 lines (37 loc) · 1.75 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Use slim for a smaller image size and install only the required packages
FROM python:3.8-slim
# > Setting PYTHONUNBUFFERED to a non empty value ensures that the python output is sent straight to
# > terminal (e.g. your container log) without being first buffered and that you can see the output
# > of your application (e.g. django logs) in real time.
# https://stackoverflow.com/a/59812588
ENV PYTHONUNBUFFERED 1
# libpq-dev & gcc: required by psycopg2
RUN apt-get update && apt-get install -y \
curl \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Install the package manager - pipenv
RUN pip install --upgrade pip && \
pip install --no-cache-dir pipenv
# Change the working directory for all proceeding operations
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#workdir
WORKDIR /code
# "items (files, directories) that do not require ADD’s tar auto-extraction capability, you should always use COPY."
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy
COPY Pipfile .
COPY Pipfile.lock .
# Install both default and dev packages so that we can run the tests against this image
RUN pipenv sync --dev --system && \
pipenv --clear
# Copy all the source to the image
COPY . .
# "The best use for ENTRYPOINT is to set the image’s main command, allowing that image to be run as though it was that
# command (and then use CMD as the default flags)."
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#entrypoint
# have a look in .flaskenv for configured run options
ENTRYPOINT ["flask"]
CMD ["run"]
# https://docs.docker.com/engine/reference/builder/#healthcheck
HEALTHCHECK --interval=30s --timeout=5s \
CMD curl -Lf http://localhost:8000/health || exit 1