-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathDockerfile
178 lines (130 loc) · 4.34 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# syntax=docker/dockerfile:1.2
FROM python:3.11-bookworm AS build
ENV PIP_ROOT_USER_ACTION=ignore
RUN --mount=type=cache,target=/root/.cache \
pip install --upgrade pip setuptools wheel
FROM build AS build-habref
WORKDIR /build/
COPY /backend/dependencies/Habref-api-module .
RUN python setup.py bdist_wheel
FROM build AS build-nomenclature
WORKDIR /build/
COPY /backend/dependencies/Nomenclature-api-module .
RUN python setup.py bdist_wheel
FROM build AS build-refgeo
WORKDIR /build/
COPY /backend/dependencies/RefGeo .
RUN python setup.py bdist_wheel
FROM build AS build-taxhub
WORKDIR /build/
COPY /backend/dependencies/TaxHub .
RUN python setup.py bdist_wheel
FROM build AS build-usershub
WORKDIR /build/
COPY /backend/dependencies/UsersHub .
RUN python setup.py bdist_wheel
FROM build AS build-usershub-module
WORKDIR /build/
COPY /backend/dependencies/UsersHub-authentification-module .
RUN python setup.py bdist_wheel
FROM build AS build-utils
WORKDIR /build/
COPY /backend/dependencies/Utils-Flask-SQLAlchemy .
RUN python setup.py bdist_wheel
FROM build AS build-utils-geo
WORKDIR /build/
COPY /backend/dependencies/Utils-Flask-SQLAlchemy-Geo .
RUN python setup.py bdist_wheel
FROM build AS build-geonature
WORKDIR /build/
COPY /backend ./backend
COPY /setup.py .
COPY /MANIFEST.in .
COPY /VERSION .
COPY /LICENSE .
COPY /README.md .
RUN python setup.py bdist_wheel
FROM build AS build-occtax
WORKDIR /build/
COPY /contrib/occtax/backend ./backend
COPY /contrib/occtax/setup.py .
COPY /contrib/occtax/requirements.in .
COPY /contrib/occtax/MANIFEST.in .
COPY /contrib/occtax/VERSION .
COPY /contrib/occtax/README.rst .
RUN python setup.py bdist_wheel
FROM build AS build-occhab
WORKDIR /build/
COPY /contrib/gn_module_occhab/backend ./backend
COPY /contrib/gn_module_occhab/setup.py .
COPY /contrib/gn_module_occhab/requirements.in .
COPY /contrib/gn_module_occhab/MANIFEST.in .
COPY /contrib/gn_module_occhab/VERSION .
COPY /contrib/gn_module_occhab/README.rst .
RUN python setup.py bdist_wheel
FROM build AS build-validation
WORKDIR /build/
COPY /contrib/gn_module_validation/backend ./backend
COPY /contrib/gn_module_validation/setup.py .
COPY /contrib/gn_module_validation/requirements.in .
COPY /contrib/gn_module_validation/MANIFEST.in .
COPY /contrib/gn_module_validation/VERSION .
COPY /contrib/gn_module_validation/README.rst .
RUN python setup.py bdist_wheel
FROM node:alpine AS node
WORKDIR /dist/
COPY /backend/static/package*.json .
RUN --mount=type=cache,target=/root/.npm \
npm ci --omit=dev
FROM python:3.9-bullseye AS wheels-light
ENV PIP_ROOT_USER_ACTION=ignore
RUN --mount=type=cache,target=/root/.cache \
pip install --upgrade pip setuptools wheel
WORKDIR /dist
ENV GEONATURE_STATIC_FOLDER=/dist/static/
COPY /backend/static/ ./static/
COPY --from=node /dist/node_modules/ ./static/node_modules/
ENV GEONATURE_CUSTOM_STATIC_FOLDER=/dist/custom/
RUN mkdir custom
ENV GEONATURE_MEDIA_FOLDER=/dist/media/
RUN mkdir -p media/attachments
WORKDIR /dist/geonature
COPY /backend/requirements-dev.txt .
RUN sed -i 's/^-e .*/# &/' requirements-dev.txt
RUN --mount=type=cache,target=/root/.cache \
pip install -r requirements-dev.txt
COPY --from=build-habref /build/dist/*.whl .
COPY --from=build-nomenclature /build/dist/*.whl .
COPY --from=build-refgeo /build/dist/*.whl .
COPY --from=build-usershub /build/dist/*.whl .
COPY --from=build-usershub-module /build/dist/*.whl .
COPY --from=build-taxhub /build/dist/*.whl .
COPY --from=build-utils /build/dist/*.whl .
COPY --from=build-utils-geo /build/dist/*.whl .
COPY --from=build-geonature /build/dist/*.whl .
COPY --chmod=755 /install/03b_populate_db.sh /populate_db.sh
COPY --chmod=755 /install/assets/docker_entrypoint.sh /entrypoint.sh
ENV GEONATURE_CONFIG_FILE ""
EXPOSE 8000
ENTRYPOINT ["/entrypoint.sh"]
CMD [ "gunicorn", "geonature:create_app()", \
"--name=geonature", \
"--workers=2", \
"--threads=2", \
"--access-logfile=-", \
"--bind=0.0.0.0:8000" \
]
FROM wheels-light AS wheels
COPY --from=build-occtax /build/dist/*.whl .
COPY --from=build-occhab /build/dist/*.whl .
COPY --from=build-validation /build/dist/*.whl .
FROM wheels-light AS prod-light
WORKDIR /dist/geonature
RUN --mount=type=cache,target=/root/.cache \
pip install *.whl
RUN rm -f *.whl
FROM wheels AS prod
WORKDIR /dist/geonature
RUN --mount=type=cache,target=/root/.cache \
pip install *.whl
RUN rm -f *.whl