Skip to content

Commit

Permalink
add docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
bouttier committed Dec 5, 2022
1 parent 7f7134b commit cbdee79
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
backend/venv/
backend/static/node_modules/
frontend/node_modules/
161 changes: 161 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# syntax=docker/dockerfile:1.2

FROM python:3.9-bullseye 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 prod

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/

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 .

ENV GEONATURE_CONFIG_FILE ""

EXPOSE 8000

CMD ["gunicorn", "geonature:create_app()", "--bind=0.0.0.0:8000"]


FROM prod AS prod-light

WORKDIR /dist/geonature
RUN --mount=type=cache,target=/root/.cache \
pip install *.whl
RUN rm -f *.whl


FROM prod AS prod-full

WORKDIR /dist/geonature
COPY --from=build-occtax /build/dist/*.whl .
COPY --from=build-occhab /build/dist/*.whl .
COPY --from=build-validation /build/dist/*.whl .
RUN --mount=type=cache,target=/root/.cache \
pip install *.whl
RUN rm -f *.whl
70 changes: 70 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FROM node:16-bullseye AS source

WORKDIR /build/

COPY ./frontend/package.json .
COPY ./frontend/package-lock.json .
RUN --mount=type=cache,target=/root/.npm \
npm ci --omit=dev

COPY ./frontend/angular.json .
COPY ./frontend/tsconfig.json .
COPY ./frontend/external_modules external_modules
COPY ./frontend/src src
RUN cp -n src/assets/custom.sample.css src/assets/custom.css
RUN cp -n src/custom/components/footer/footer.component.html.sample src/custom/components/footer/footer.component.html
RUN cp -n src/custom/components/footer/footer.component.ts.sample src/custom/components/footer/footer.component.ts
RUN cp -n src/custom/components/introduction/introduction.component.html.sample src/custom/components/introduction/introduction.component.html
RUN cp -n src/custom/components/introduction/introduction.component.ts.sample src/custom/components/introduction/introduction.component.ts
RUN cp -n src/custom/components/introduction/introduction.component.scss.sample src/custom/components/introduction/introduction.component.scss


FROM source AS source-full

WORKDIR /build/external_modules/occtax
COPY ./contrib/occtax/frontend/ .
#RUN --mount=type=cache,target=/root/.npm \
# npm ci --omit=dev

WORKDIR /build/external_modules/occhab
COPY ./contrib/gn_module_occhab/frontend/ .
#RUN --mount=type=cache,target=/root/.npm \
# npm ci --omit=dev

WORKDIR /build/external_modules/validation
COPY ./contrib/gn_module_validation/frontend/ .
RUN --mount=type=cache,target=/root/.npm \
npm ci --omit=dev


FROM source AS build-light

WORKDIR /build/
RUN npm run build


FROM source-full AS build-full

WORKDIR /build/
RUN npm run build


FROM nginx:mainline-alpine AS prod

ENV NGINX_PORT 80
ENV NGINX_HOST localhost
ENV NGINX_LOCATION /

COPY ./frontend/nginx.conf /etc/nginx/templates/default.conf.template

EXPOSE 80


FROM prod AS prod-light

COPY --from=build-light /build/dist /usr/share/nginx/html


FROM prod AS prod-full

COPY --from=build-full /build/dist /usr/share/nginx/html
9 changes: 9 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen ${NGINX_PORT};
server_name ${NGINX_HOST};

location ${NGINX_LOCATION} {
alias /usr/share/nginx/html;
index index.html index.htm;
}
}

0 comments on commit cbdee79

Please sign in to comment.