-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
39 lines (36 loc) · 1.41 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
# The application Dockerfile
#
# Copyright (c) 2020, Alexandre Hamelin <alexandre.hamelin gmail.com>
#
FROM python:3-alpine AS builder
LABEL maintainer="Alexandre Hamelin <alexandre.hamelin gmail.com>" \
copyright="Copyright (c) 2020, Alexandre Hamelin <alexandre.hamelin gmail.com>" \
license="MIT"
# Update pip and build the requirements as wheel files.
RUN pip install -qU pip
RUN apk update -q
RUN apk add -q openssl-dev libffi-dev build-base
COPY . /app
WORKDIR /app
# Don't bake the wheels directory into the image
RUN [ -d wheels ] || pip wheel -qw wheels -r requirements.txt && rm -f pip-selfcheck.json
#----------------------------------------------------------------------------
FROM python:3-alpine
LABEL maintainer="Alexandre Hamelin <alexandre.hamelin gmail.com>" \
copyright="Copyright (c) 2020, Alexandre Hamelin <alexandre.hamelin gmail.com>" \
license="MIT"
ARG FLASK_APP
ARG FLASK_ENV
# Update pip in the container and grab the app from the builder container.
# No need for virtualenv, which will cause otherwise some problems when the app
# is mounted from the host for development (permissions, especially if running
# in user namespace, etc.).
RUN pip install -qU pip
COPY --from=builder /app /app
WORKDIR /app
RUN pip install -q wheels/*.whl
RUN adduser -D app && chown -R app:app /app
USER app
ENV FLASK_ENV=${FLASK_ENV:-development}
ENV FLASK_APP=${FLASK_APP:-changeme}
CMD exec flask run -h ::