-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
42 lines (33 loc) · 1.12 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
# syntax=docker/dockerfile:1
ARG PYTHON_TAG=alpine
FROM python:${PYTHON_TAG} AS build
WORKDIR /src
# use python venv
ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY flask_app/requirements.txt requirements.txt
# install pip requirments
RUN apk -U upgrade --no-cache && \
apk add --no-cache --virtual .build-deps libpq-dev build-base && \
python3 -m venv $VIRTUAL_ENV && \
python3 -m ensurepip --upgrade && \
python3 -m pip install --upgrade pip setuptools wheel --no-cache-dir && \
python3 -m pip install -r requirements.txt --no-cache-dir && \
apk --purge del .build-deps
FROM python:${PYTHON_TAG} AS run
WORKDIR /app
# use python venv (same as build venv)
ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY --from=build /venv /venv
# copy source code
COPY /flask_app /app
# create directory for mounting configs
RUN mkdir -p /config
# install required Alpine packages
RUN apk -U upgrade --no-cache && \
apk add --no-cache mariadb-client mysql-client postgresql-libs curl wget
# Gunicorn entrypoint
COPY entrypoint.sh entrypoint.sh
EXPOSE 5000/tcp
ENTRYPOINT [ "/bin/sh", "entrypoint.sh" ]