-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
85 lines (58 loc) · 1.82 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
ARG PYTHON_VERSION=3.9
FROM python:${PYTHON_VERSION}-slim AS base
ENV VIRTUAL_ENV=/app/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
ENV PIPENV_VENV_IN_PROJECT=1
ENV PIPENV_VERBOSITY=-1
WORKDIR /app
# Buildtime dependencies
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,sharing=locked,target=/var/lib/apt/lists \
apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
graphviz \
libgraphviz-dev \
libpq-dev \
python3-dev
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --upgrade pip setuptools wheel pipenv
COPY Pipfile Pipfile.lock ./
RUN --mount=type=cache,target=/root/.cache/pipenv \
pipenv install --deploy --verbose
From base as base-dev
RUN --mount=type=cache,target=/root/.cache/pipenv \
pipenv install --dev --deploy --verbose
FROM python:${PYTHON_VERSION}-slim as dev
ENV VIRTUAL_ENV=/app/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
WORKDIR /app
# Runtime dependencies
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,sharing=locked,target=/var/lib/apt/lists \
apt-get update && \
apt-get install --no-install-recommends -y \
graphviz \
libpq5
COPY --from=base-dev $VIRTUAL_ENV $VIRTUAL_ENV
COPY . .
RUN flask translate compile
EXPOSE 5000
EXPOSE 5678
ENTRYPOINT ["gunicorn", "--reload"]
FROM python:${PYTHON_VERSION}-slim as prod
ENV VIRTUAL_ENV=/app/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
WORKDIR /app
# Runtime dependencies
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,sharing=locked,target=/var/lib/apt/lists \
apt-get update && \
apt-get install --no-install-recommends -y \
graphviz \
libpq5
COPY --from=base $VIRTUAL_ENV $VIRTUAL_ENV
COPY . .
# RUN flask translate compile
EXPOSE 5000
ENTRYPOINT ["gunicorn"]