From 0481bf2d97cd26b0bbc1087e91c19ff9271493bf Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Sun, 15 Oct 2023 18:29:34 -0400 Subject: [PATCH] Add containerfile linter and lint containerfile Exclude poetry venv from container source tree --- .containerignore | 1 + .hadolint.yaml | 3 +++ Containerfile | 18 +++++++++++------- 3 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 .containerignore create mode 100644 .hadolint.yaml diff --git a/.containerignore b/.containerignore new file mode 100644 index 0000000..691037e --- /dev/null +++ b/.containerignore @@ -0,0 +1 @@ +.venv/* diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 0000000..26ae9ba --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,3 @@ +--- +ignored: +- DL3008 diff --git a/Containerfile b/Containerfile index 4406e0e..50564c6 100644 --- a/Containerfile +++ b/Containerfile @@ -3,8 +3,8 @@ FROM docker.io/library/python:3.11 AS build-borg # Install borg build dependencies -RUN apt update --yes -RUN apt install --yes \ +RUN apt-get update --yes +RUN apt-get install --yes --no-install-recommends \ libacl1-dev \ libacl1 \ libssl-dev \ @@ -19,7 +19,8 @@ RUN python -m pip install \ Cython==3.0.3 \ pkgconfig==1.5.5 \ --disable-pip-version-check \ - --upgrade + --upgrade \ + --no-cache-dir # Build borg dist wheel COPY . /source @@ -27,7 +28,8 @@ WORKDIR /source/borgbackup RUN python -m pip wheel .[pyfuse3] \ --wheel-dir /wheels \ --prefer-binary \ - --disable-pip-version-check + --disable-pip-version-check \ + --no-cache-dir # ====================================================== @@ -55,9 +57,10 @@ RUN python -m pip wheel \ # Stage 3: Final distribution image FROM docker.io/library/python:3.11-slim AS publish -RUN apt update --yes && \ - apt install openssh-client --yes && \ - apt clean all && \ +RUN apt-get update --yes && \ + apt-get install openssh-client --yes --no-install-recommends && \ + apt-get clean all && \ + rm --recursive --force /var/lib/apt/lists/* && \ mkdir /repo /data /keys && \ useradd borg --uid 1000 --home-dir /home/borg --create-home && \ chown --recursive borg:borg /repo && \ @@ -67,6 +70,7 @@ RUN apt update --yes && \ COPY --from=build-borg /wheels /wheels/borg COPY --from=build-drone /wheels /wheels/drone COPY --from=build-drone /requirements.txt /wheels/drone.txt +# hadolint ignore=DL3013 RUN python -m pip install borgbackup[pyfuse3] \ --upgrade \ --pre \