Skip to content

Commit

Permalink
Properly layer dockerfile to install requirements seperately to build…
Browse files Browse the repository at this point in the history
…ing src
  • Loading branch information
devsjc committed Aug 16, 2023
1 parent 0626707 commit b87412f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
15 changes: 9 additions & 6 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ RUN /venv/bin/pip install --upgrade pip wheel setuptools
RUN conda install -p /venv -y eccodes zarr

# Install packages into the virtualenv as a separate step
# * Only re-execute this step when the copied files change
# * This also builds the package into the virtualenv
# * Only re-execute this step when the requirements files change
FROM build-venv AS build-reqs
WORKDIR /app
COPY pyproject.toml pyproject.toml
RUN /venv/bin/pip install . --no-cache-dir --no-binary=nwp-consumer

# Build binary for the package
# * The package is versioned via setuptools_git_versioning
# hence the .git directory is required
# * The README.md is required for the long description
FROM build-venv AS build-wheels
WORKDIR /app
FROM build-reqs AS build-app
COPY src src
COPY pyproject.toml pyproject.toml
COPY .git .git
COPY README.md README.md
RUN /venv/bin/pip install .
Expand All @@ -25,7 +28,7 @@ RUN /venv/bin/pip install .
# * These are small images that only contain the runtime dependencies
FROM gcr.io/distroless/python3-debian11
WORKDIR /app
COPY --from=build-wheels /venv /venv
COPY --from=build-app /venv /venv
HEALTHCHECK CMD ["/venv/bin/nwp-consumer", "check"]
ENTRYPOINT ["/venv/bin/nwp-consumer"]
VOLUME /tmp/nwpc
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ nwp-consumer = "nwp_consumer.cmd.main:main" # Set the entrypoint for the CLI
[project.urls]
repository = "https://github.com/openclimatefix/nwp-consumer"

[tool.setuptools.packages.find]
where = ["src"]
include = ["nwp_consumer"]
exclude = ["*.tests", "*.tests.*", "tests.*", "tests"]

[tool.setuptools-git-versioning]
enabled = true

Expand Down

0 comments on commit b87412f

Please sign in to comment.