-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile
31 lines (28 loc) · 1.14 KB
/
Containerfile
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
# Build a virtualenv using miniconda
# * Install required compilation tools for wheels via apt
FROM quay.io/condaforge/miniforge3:latest AS build-venv
RUN apt -qq update && apt -qq install -y build-essential
RUN conda create -p /venv python=3.11
RUN /venv/bin/pip install --upgrade -q pip wheel setuptools
# Install packages into the virtualenv as a separate step
# * 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 -q . --no-cache-dir --no-binary=package-name
# 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-reqs AS build-app
COPY src src
COPY .git .git
COPY README.md README.md
RUN /venv/bin/pip install .
# Copy the virtualenv into a distroless image
# * These are small images that only contain the runtime dependencies
FROM gcr.io/distroless/python3-debian11
WORKDIR /app
COPY --from=build-app /venv /venv
HEALTHCHECK CMD ["/venv/bin/packagename", "check"]
ENTRYPOINT ["/venv/bin/packagename"]