-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
159 lines (134 loc) · 5.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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Base of all section, install the apt packages
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.10.0 AS base-all
LABEL maintainer Camptocamp "[email protected]"
# Fail on error on pipe, see: https://github.com/hadolint/hadolint/wiki/DL4006.
# Treat unset variables as an error when substituting.
# Print commands and their arguments as they are executed.
SHELL ["/bin/bash", "-o", "pipefail", "-cux"]
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get upgrade --assume-yes \
&& apt-get install --assume-yes --no-install-recommends \
libmapnik3.1 mapnik-utils \
libdb5.3 \
fonts-dejavu \
optipng jpegoptim \
postgresql-client net-tools iputils-ping \
python3-pip python3-venv \
&& python3 -m venv /venv
ENV PATH=/venv/bin:$PATH
# Used to convert the locked packages by poetry to pip requirements format
# We don't directly use `poetry install` because it force to use a virtual environment.
FROM base-all AS poetry
# Install Poetry
WORKDIR /tmp
COPY requirements.txt ./
RUN --mount=type=cache,target=/root/.cache \
python3 -m pip install --disable-pip-version-check --requirement=requirements.txt
# Do the conversion
COPY poetry.lock pyproject.toml ./
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=0.0.0
RUN poetry export --output=requirements.txt \
&& poetry export --with=dev --output=requirements-dev.txt
# Base, the biggest thing is to install the Python packages
FROM base-all AS base
# hadolint ignore=SC2086
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
--mount=type=cache,target=/root/.cache \
--mount=type=bind,from=poetry,source=/tmp,target=/poetry \
DEV_PACKAGES="python3-dev build-essential libgeos-dev libmapnik-dev libpq-dev build-essential" \
&& apt-get update \
&& apt-get install --assume-yes --no-install-recommends ${DEV_PACKAGES} \
&& python3 -m pip install --disable-pip-version-check --no-deps --requirement=/poetry/requirements.txt \
&& python3 -m compileall /venv/lib/python* /usr/lib/python* \
&& strip /venv/lib/python*/site-packages/shapely/*.so \
&& apt-get remove --purge --autoremove --yes ${DEV_PACKAGES} binutils
# From c2cwsgiutils
CMD ["/venv/bin/pserve", "c2c:///app/application.ini"]
ENV LOG_TYPE=console \
DEVELOPMENT=0 \
PKG_CONFIG_ALLOW_SYSTEM_LIBS=OHYESPLEASE
ENV C2C_SECRET= \
C2C_BASE_PATH=/c2c \
C2C_REDIS_URL= \
C2C_REDIS_SENTINELS= \
C2C_REDIS_TIMEOUT=3 \
C2C_REDIS_SERVICENAME=mymaster \
C2C_REDIS_DB=0 \
C2C_BROADCAST_PREFIX=broadcast_api_ \
C2C_REQUEST_ID_HEADER= \
C2C_REQUESTS_DEFAULT_TIMEOUT= \
C2C_SQL_PROFILER_ENABLED=0 \
C2C_PROFILER_PATH= \
C2C_PROFILER_MODULES= \
C2C_DEBUG_VIEW_ENABLED=0 \
C2C_ENABLE_EXCEPTION_HANDLING=0
# End from c2cwsgiutils
ENV TILEGENERATION_CONFIGFILE=/etc/tilegeneration/config.yaml \
TILEGENERATION_MAIN_CONFIGFILE=/etc/tilegeneration/config.yaml \
TILEGENERATION_HOSTSFILE=/etc/tilegeneration/hosts.yaml \
TILECLOUD_CHAIN_LOG_LEVEL=INFO \
TILECLOUD_LOG_LEVEL=INFO \
C2CWSGIUTILS_LOG_LEVEL=WARN \
WAITRESS_LOG_LEVEL=INFO \
WSGI_LOG_LEVEL=INFO \
SQL_LOG_LEVEL=WARN \
OTHER_LOG_LEVEL=WARN \
VISIBLE_ENTRY_POINT=/ \
TILE_NB_THREAD=2 \
METATILE_NB_THREAD=25 \
SERVER_NB_THREAD=10 \
TILE_QUEUE_SIZE=2 \
TILE_CHUNK_SIZE=1 \
TILE_SERVER_LOGLEVEL=quiet \
TILE_MAPCACHE_LOGLEVEL=verbose \
WAITRESS_THREADS=10 \
PYRAMID_INCLUDES= \
DEBUGTOOLBAR_HOSTS=
EXPOSE 8080
WORKDIR /app/
# The final part
FROM base AS runner
COPY . /app/
ARG VERSION=dev
ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
RUN --mount=type=cache,target=/root/.cache \
POETRY_DYNAMIC_VERSIONING_BYPASS=${VERSION} python3 -m pip install --disable-pip-version-check --no-deps --editable=. \
&& mv docker/run /usr/bin/ \
&& python3 -m compileall -q /app/tilecloud_chain
# Do the lint, used by the tests
FROM base AS tests
# Fail on error on pipe, see: https://github.com/hadolint/hadolint/wiki/DL4006.
# Treat unset variables as an error when substituting.
# Print commands and their arguments as they are executed.
SHELL ["/bin/bash", "-o", "pipefail", "-cux"]
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
apt-get update \
&& apt-get install --assume-yes --no-install-recommends software-properties-common gpg-agent \
&& add-apt-repository ppa:savoury1/pipewire \
&& add-apt-repository ppa:savoury1/chromium \
&& apt-get install --assume-yes --no-install-recommends chromium-browser git curl gnupg
COPY .nvmrc /tmp
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache,sharing=locked \
NODE_MAJOR="$(cat /tmp/.nvmrc)" \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
&& curl --silent https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor --output=/etc/apt/keyrings/nodesource.gpg \
&& apt-get update \
&& apt-get install --assume-yes --no-install-recommends "nodejs=${NODE_MAJOR}.*"
COPY package.json package-lock.json ./
RUN npm install --dev --ignore-scripts
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
RUN --mount=type=cache,target=/root/.cache \
--mount=type=bind,from=poetry,source=/tmp,target=/poetry \
python3 -m pip install --disable-pip-version-check --no-deps --requirement=/poetry/requirements-dev.txt
COPY . ./
RUN --mount=type=cache,target=/root/.cache \
POETRY_DYNAMIC_VERSIONING_BYPASS=0.0.0 python3 -m pip install --disable-pip-version-check --no-deps --editable=. \
&& python3 -m pip freeze > /requirements.txt
ENV TILEGENERATION_MAIN_CONFIGFILE=
# Set runner as final
FROM runner