Skip to content
Snippets Groups Projects
Commit c7b64597 authored by Moul's avatar Moul
Browse files

containers: improve layers build

Create a cached layer for downloaded dependencies
which does not get invalidated by sources change

Copy pyproject.toml first,
install dependencies as a layer,
which is only invalidated when this file changes

Then copy sources and build layer
If the sources changes, the layer
cache is invalidated and therefore rebuilt
parent da8bce74
No related branches found
No related tags found
No related merge requests found
......@@ -9,10 +9,15 @@ RUN pip install "poetry>=1.8,<2.0"
WORKDIR /silkaj
# Copy source tree
# Copy pyproject.toml and install dependencies
# So this dependencies installation layer
# does not change when the sources changes
# https://python-poetry.org/docs/faq/#poetry-busts-my-docker-cache-because-it-requires-me-to-copy-my-source-files-in-before-installing-3rd-party-dependencies
COPY pyproject.toml .
RUN poetry install --only main --no-root
# Copy source tree, install and build Silkaj
COPY ./ ./
# Install Silkaj
RUN poetry install --only main --extras deathreaper
RUN poetry build
......
......@@ -6,6 +6,13 @@ FROM registry.duniter.org/docker/python3/poetry/${PYTHON_VERS}:latest AS build
WORKDIR /silkaj
# Copy pyproject.toml and install dependencies
# So this dependencies installation layer
# does not change when the sources changes
# https://python-poetry.org/docs/faq/#poetry-busts-my-docker-cache-because-it-requires-me-to-copy-my-source-files-in-before-installing-3rd-party-dependencies
COPY pyproject.toml .
RUN poetry install --only main --no-root
# Copy source tree
COPY ./ ./
......@@ -16,7 +23,6 @@ RUN poetry install --only main --extras deathreaper
# Final Stage
# ------------------------------------------------------------------------------
FROM registry.duniter.org/docker/python3/poetry/${PYTHON_VERS}:latest
ARG PYTHON_VERS
# Create silkaj group and user
RUN groupadd -g 1111 silkaj && \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment