-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
111 lines (89 loc) · 2.89 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
FROM ubuntu:focal as base
# stage with general requirements
ARG UID=1000
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV LANG=C.UTF-8
ENV TZ=UTC
ENV SERVER_NAME=localhost
ENV CONVERSION_HOST=convertit
ENV CAPTURE_HOST=screamshotter
ENV POSTGRES_HOST=postgres
ENV PGPORT=5432
ENV CUSTOM_SETTINGS_FILE=/opt/georiviere-admin/var/conf/custom.py
RUN mkdir -p /opt/georiviere-admin/var
RUN useradd -ms /bin/bash django --uid ${UID}
RUN chown -R django:django /opt
COPY .docker/* /usr/local/bin/
RUN chown -R django:django /usr/local/bin/load_data.sh
WORKDIR /opt/georiviere-admin
RUN apt-get update -qq && apt-get install -y -qq \
python3.9 \
gettext \
# geodjango \
binutils \
gdal-bin \
libproj-dev \
# manage \
netcat \
tzdata \
# mapentity
iproute2 \
# weasyprint
fonts-liberation \
libcairo2 \
libfreetype6 \
libgdk-pixbuf2.0 \
libpango1.0-0 \
libpangocairo-1.0-0 \
libpq5 \
postgresql-client && \
apt-get install -y -qq --no-install-recommends postgis && \
apt-get clean all && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/*
USER django
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 8000
FROM base as build
# stage with build requirements
USER root
RUN apt-get update -qq && apt-get install -y -qq \
git \
python3.9-dev \
python3.9-venv \
build-essential \
graphviz \
libffi-dev \
libfreetype6-dev \
libgdk-pixbuf2.0-dev \
libssl-dev \
libpq-dev \
libxml2-dev \
libxslt-dev \
libgraphviz-dev \
pkg-config && \
apt-get clean all && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/*
USER django
RUN python3.9 -m venv /opt/venv
RUN /opt/venv/bin/pip install --no-cache-dir pip==24.0 setuptools wheel -U
# geotrek setup fix : it required django before being installed... TODO: fix it in geotrek setup.py
RUN /opt/venv/bin/pip install --no-cache-dir django==2.2.*
COPY requirements.txt /opt/requirements.txt
RUN /opt/venv/bin/pip install --no-cache-dir -r /opt/requirements.txt
FROM build as dev
# stage with dev requirements
COPY dev-requirements.txt /opt/dev-requirements.txt
RUN /opt/venv/bin/pip install --no-cache-dir -r /opt/dev-requirements.txt
CMD ./manage.py runserver 0.0.0.0:8000
FROM base as prod
# stage with prod requirements only
ENV GUNICORN_CMD_ARGS="--workers 1 --timeout 3600 --bind 0.0.0.0:8000 --timeout 3600"
USER root
RUN apt-get update -qq && \
apt-get full-upgrade -y -qq && \
apt-get clean all && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/*
COPY --chown=django:django --from=build /opt/venv /opt/venv
COPY --chown=django:django georiviere /opt/georiviere-admin/georiviere
COPY --chown=django:django manage.py /opt/georiviere-admin/manage.py
USER django
RUN CONVERSION_HOST=localhost CAPTURE_HOST=localhost SECRET_KEY=temp-secret-key /opt/venv/bin/python ./manage.py compilemessages
CMD ["gunicorn", "georiviere.wsgi:application"]