-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'structure-local/py-ci-cli' into develop
- Loading branch information
Showing
33 changed files
with
805 additions
and
438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,7 @@ target/ | |
celerybeat-schedule | ||
|
||
# dotenv | ||
.env | ||
/.env | ||
|
||
# virtualenv | ||
venv/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,22 +2,44 @@ | |
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
## Container image for use by end users | ||
|
||
## Image layers shared between all variants. | ||
|
||
# Stay as close to a vanilla Python environment as possible | ||
ARG PYTHON_MINOR=3.10 | ||
FROM python:${PYTHON_MINOR} | ||
FROM python:${PYTHON_MINOR} AS base | ||
# Defensive shell options: | ||
SHELL ["/bin/bash", "-eu", "-o", "pipefail", "-c"] | ||
|
||
# Least volatile layers first: | ||
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys | ||
LABEL org.opencontainers.image.url="https://gitlab.com/rpatterson/prunerr" | ||
LABEL org.opencontainers.image.documentation="https://gitlab.com/rpatterson/prunerr" | ||
LABEL org.opencontainers.image.source="https://gitlab.com/rpatterson/prunerr" | ||
LABEL org.opencontainers.image.title="Prunerr" | ||
LABEL org.opencontainers.image.description="Remove Servarr download client items to preserve disk space according to rules." | ||
LABEL org.opencontainers.image.licenses="MIT" | ||
LABEL org.opencontainers.image.authors="Ross Patterson <[email protected]>" | ||
LABEL org.opencontainers.image.vendor="rpatterson.net" | ||
LABEL org.opencontainers.image.base.name="docker.io/library/python:${PYTHON_MINOR}" | ||
|
||
# Find the same home directory even when run as another user, e.g. `root`. | ||
ENV HOME="/home/prunerr" | ||
ENTRYPOINT [ "entrypoint" ] | ||
CMD [ "prunerr", "daemon" ] | ||
|
||
# Put the `ENTRYPOINT` on the `$PATH` | ||
COPY [ "./bin/entrypoint", "/usr/local/bin/entrypoint" ] | ||
|
||
# Install OS packages needed for the image `ENDPOINT`: | ||
RUN \ | ||
rm -f /etc/apt/apt.conf.d/docker-clean && \ | ||
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' \ | ||
>"/etc/apt/apt.conf.d/keep-cache" | ||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
--mount=type=cache,target=/var/lib/apt,sharing=locked \ | ||
apt-get update && \ | ||
apt-get install --no-install-recommends -y gosu=1.12-1+b6 | ||
# Put the `ENTRYPOINT` on the `$PATH` | ||
COPY [ "./bin/entrypoint", "/usr/local/bin/entrypoint" ] | ||
apt-get install --no-install-recommends -y "gosu=1.12-1+b6" | ||
|
||
WORKDIR "/usr/local/src/prunerr/" | ||
# Install dependencies with fixed versions in a separate layer to optimize build times | ||
|
@@ -26,32 +48,73 @@ ARG PYTHON_ENV=py310 | |
COPY [ "./requirements/${PYTHON_ENV}/user.txt", "./requirements/${PYTHON_ENV}/" ] | ||
# hadolint ignore=DL3042 | ||
RUN --mount=type=cache,target=/root/.cache,sharing=locked \ | ||
pip install -r "./requirements/${PYTHON_ENV}/user.txt" | ||
pip3 install -r "./requirements/${PYTHON_ENV}/user.txt" | ||
|
||
# Build-time `LABEL`s | ||
ARG VERSION= | ||
LABEL org.opencontainers.image.version=${VERSION} | ||
|
||
|
||
## Container image for use by end users. | ||
|
||
# Stay as close to a vanilla environment as possible: | ||
FROM base AS user | ||
# Defensive shell options: | ||
SHELL ["/bin/bash", "-eu", "-o", "pipefail", "-c"] | ||
|
||
# Least volatile layers first: | ||
WORKDIR "/home/prunerr/" | ||
|
||
# Install this package in the most common/standard Python way while still being able to | ||
# build the image locally. | ||
ARG PYTHON_WHEEL | ||
COPY [ "${PYTHON_WHEEL}", "${PYTHON_WHEEL}" ] | ||
# hadolint ignore=DL3013,DL3042 | ||
RUN --mount=type=cache,target=/root/.cache,sharing=locked \ | ||
pip install "${PYTHON_WHEEL}" && \ | ||
pip3 install "${PYTHON_WHEEL}" && \ | ||
rm -rfv "./dist/" | ||
|
||
# Find the same configuration file even when run as another user, e.g. `root`. | ||
ENV HOME="/home/prunerr/" | ||
WORKDIR "/home/prunerr/" | ||
ENTRYPOINT [ "entrypoint" ] | ||
CMD [ "prunerr", "daemon" ] | ||
|
||
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys | ||
LABEL org.opencontainers.image.url="https://gitlab.com/rpatterson/prunerr" | ||
LABEL org.opencontainers.image.documentation="https://gitlab.com/rpatterson/prunerr" | ||
LABEL org.opencontainers.image.source="https://gitlab.com/rpatterson/prunerr" | ||
LABEL org.opencontainers.image.title="Prunerr" | ||
## Container image for use by developers. | ||
|
||
# Stay as close to the end user image as possible for build cache efficiency: | ||
FROM base AS devel | ||
# Defensive shell options: | ||
SHELL ["/bin/bash", "-eu", "-o", "pipefail", "-c"] | ||
|
||
# Least volatile layers first: | ||
LABEL org.opencontainers.image.title="Prunerr Development" | ||
LABEL org.opencontainers.image.description="Remove Servarr download client items to preserve disk space according to rules." | ||
LABEL org.opencontainers.image.licenses="MIT" | ||
LABEL org.opencontainers.image.authors="Ross Patterson <[email protected]>" | ||
LABEL org.opencontainers.image.vendor="rpatterson.net" | ||
LABEL org.opencontainers.image.base.name="docker.io/library/python:${PYTHON_MINOR}" | ||
# Build-time `LABEL`s | ||
ARG VERSION= | ||
LABEL org.opencontainers.image.version=${VERSION} | ||
|
||
# Activate the Python virtual environment | ||
ENV VIRTUAL_ENV="/usr/local/src/prunerr/.tox/${PYTHON_ENV}" | ||
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" | ||
# Remain in the checkout `WORKDIR` and make the build tools the default | ||
# command to run. | ||
WORKDIR "/usr/local/src/prunerr/" | ||
# Have to use the shell form of `CMD` because we need variable substitution: | ||
# hadolint ignore=DL3025 | ||
CMD tox -e "${PYTHON_ENV}" | ||
|
||
# Then add everything that might contribute to efficient development. | ||
|
||
# Simulate the parts of the host install process from `./Makefile` needed for | ||
# development in the image: | ||
COPY [ "./build-host/requirements.txt.in", "./build-host/" ] | ||
# hadolint ignore=DL3042 | ||
RUN --mount=type=cache,target=/root/.cache,sharing=locked \ | ||
mkdir -pv "${HOME}/.local/var/log/" && \ | ||
pip3 install -r "./build-host/requirements.txt.in" | \ | ||
tee -a "${HOME}/.local/var/log/prunerr-host-install.log" | ||
|
||
# Match local development tool chain and avoid time consuming redundant package | ||
# installs. Initialize the `$ tox -e py3##` Python virtual environment to install this | ||
# package and all the development tools into the image: | ||
COPY [ \ | ||
"./requirements/${PYTHON_ENV}/test.txt", \ | ||
"./requirements/${PYTHON_ENV}/devel.txt", \ | ||
"./requirements/${PYTHON_ENV}/" \ | ||
] | ||
COPY [ "./tox.ini", "./" ] | ||
RUN --mount=type=cache,target=/root/.cache,sharing=locked \ | ||
tox --no-recreate-pkg --skip-pkg-install --notest -e "${PYTHON_ENV}" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.