Skip to content

Commit

Permalink
docker: support for building all dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
bouttier committed Nov 28, 2022
1 parent c659a7c commit dedd216
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
-
name: Checkout
uses: actions/checkout@v3
with:
submodules: ${{ ! (github.event_name == 'release' && github.event.action == 'published') }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -39,6 +41,9 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
target: prod
build-args:
DEPS=${{ (github.event_name == 'release' && github.event.action == 'published') && 'pypi' || 'build' }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
50 changes: 43 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
# syntax=docker/dockerfile:1.2

ARG DEPS=build

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

WORKDIR /dist/taxhub

FROM build AS build-utils
WORKDIR /build/
COPY /dependencies/Utils-Flask-SQLAlchemy .
RUN python setup.py bdist_wheel


FROM build AS build-refgeo
WORKDIR /build/
COPY /dependencies/RefGeo .
RUN python setup.py bdist_wheel


FROM build AS build-usershub-auth-module
WORKDIR /build/
COPY /dependencies/UsersHub-authentification-module .
RUN python setup.py bdist_wheel


FROM build AS build-taxhub
WORKDIR /build/
COPY /setup.py .
COPY /requirements-common.in .
COPY /requirements-dependencies.in .
Expand All @@ -27,7 +49,7 @@ RUN --mount=type=cache,target=/root/.npm \
npm ci --omit=dev


FROM python:3.9-bullseye AS prod
FROM python:3.9-bullseye AS app

WORKDIR /dist/

Expand All @@ -36,18 +58,32 @@ RUN --mount=type=cache,target=/root/.cache \
pip install --upgrade pip setuptools wheel

COPY --from=node /dist/node_modules ./static/node_modules
COPY /static ./static

FROM app AS app-build

COPY /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-utils /build/dist/*.whl .
COPY --from=build-refgeo /build/dist/*.whl .
COPY --from=build-usershub-auth-module /build/dist/*.whl .


FROM app AS app-pypi

COPY /requirements.txt .
RUN --mount=type=cache,target=/root/.cache \
pip install -r requirements.txt

COPY /static ./static

COPY /requirements-common.in .
COPY /requirements-dependencies.in .
COPY --from=build /dist/taxhub/dist/taxhub-*.whl .
FROM app-${DEPS} AS prod

COPY --from=build-taxhub /build/dist/*.whl .
RUN --mount=type=cache,target=/root/.cache \
pip install taxhub-*.whl
pip install *.whl

ENV FLASK_APP=apptax.app:create_app
ENV PYTHONPATH=/dist/config/
Expand Down

0 comments on commit dedd216

Please sign in to comment.