generated from geoadmin/template-service-flask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
71 lines (51 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
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
# Buster slim python 3.9 base image.
FROM python:3.9.16-slim-bullseye as base
RUN groupadd -r geoadmin && useradd -r -s /bin/false -g geoadmin geoadmin
# HERE : install relevant packages
# NOTE: curl is required for vhost health check, could be removed when moving to k8s
RUN apt-get update \
&& apt-get install -y gcc python3-dev libpq-dev curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install pipenv \
&& pipenv --version
COPY Pipfile* /tmp/
RUN cd /tmp && \
pipenv install --system --deploy --ignore-pipfile
WORKDIR /service-wmts
COPY --chown=geoadmin:geoadmin ./app /service-wmts/app/
COPY --chown=geoadmin:geoadmin ./config/ /service-wmts/config/
COPY --chown=geoadmin:geoadmin openapi.yml wsgi.py /service-wmts/
ARG GIT_HASH=unknown
ARG GIT_BRANCH=unknown
ARG GIT_DIRTY=""
ARG VERSION=unknown
ARG AUTHOR=unknown
ARG WMTS_PORT=9000
LABEL git.hash=$GIT_HASH
LABEL git.branch=$GIT_BRANCH
LABEL git.dirty="$GIT_DIRTY"
LABEL version=$VERSION
LABEL author=$AUTHOR
# Overwrite the version.py from source with the actual version
RUN echo "APP_VERSION = '$VERSION'" > /service-wmts/app/version.py
# ##################################################
# Testing target
FROM base as unittest
LABEL target=unittest
COPY --chown=geoadmin:geoadmin ./scripts /scripts/
COPY --chown=geoadmin:geoadmin ./tests /service-wmts/tests/
RUN cd /tmp && \
pipenv install --system --deploy --ignore-pipfile --dev
USER geoadmin
EXPOSE $WMTS_PORT
# Use a real WSGI server
ENTRYPOINT ["python3", "wsgi.py"]
# ##################################################
# Production target
FROM base as production
LABEL target=production
USER geoadmin
EXPOSE $WMTS_PORT
# Use a real WSGI server
ENTRYPOINT ["python3", "wsgi.py"]