Add containerfile linter and lint containerfile

Exclude poetry venv from container source tree
This commit is contained in:
Ethan Paul 2023-10-15 18:29:34 -04:00
parent 8da0315319
commit 0481bf2d97
Signed by: enpaul
GPG Key ID: 07F53B438281D181
3 changed files with 15 additions and 7 deletions

1
.containerignore Normal file
View File

@ -0,0 +1 @@
.venv/*

3
.hadolint.yaml Normal file
View File

@ -0,0 +1,3 @@
---
ignored:
- DL3008

View File

@ -3,8 +3,8 @@
FROM docker.io/library/python:3.11 AS build-borg FROM docker.io/library/python:3.11 AS build-borg
# Install borg build dependencies # Install borg build dependencies
RUN apt update --yes RUN apt-get update --yes
RUN apt install --yes \ RUN apt-get install --yes --no-install-recommends \
libacl1-dev \ libacl1-dev \
libacl1 \ libacl1 \
libssl-dev \ libssl-dev \
@ -19,7 +19,8 @@ RUN python -m pip install \
Cython==3.0.3 \ Cython==3.0.3 \
pkgconfig==1.5.5 \ pkgconfig==1.5.5 \
--disable-pip-version-check \ --disable-pip-version-check \
--upgrade --upgrade \
--no-cache-dir
# Build borg dist wheel # Build borg dist wheel
COPY . /source COPY . /source
@ -27,7 +28,8 @@ WORKDIR /source/borgbackup
RUN python -m pip wheel .[pyfuse3] \ RUN python -m pip wheel .[pyfuse3] \
--wheel-dir /wheels \ --wheel-dir /wheels \
--prefer-binary \ --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 # Stage 3: Final distribution image
FROM docker.io/library/python:3.11-slim AS publish FROM docker.io/library/python:3.11-slim AS publish
RUN apt update --yes && \ RUN apt-get update --yes && \
apt install openssh-client --yes && \ apt-get install openssh-client --yes --no-install-recommends && \
apt clean all && \ apt-get clean all && \
rm --recursive --force /var/lib/apt/lists/* && \
mkdir /repo /data /keys && \ mkdir /repo /data /keys && \
useradd borg --uid 1000 --home-dir /home/borg --create-home && \ useradd borg --uid 1000 --home-dir /home/borg --create-home && \
chown --recursive borg:borg /repo && \ chown --recursive borg:borg /repo && \
@ -67,6 +70,7 @@ RUN apt update --yes && \
COPY --from=build-borg /wheels /wheels/borg COPY --from=build-borg /wheels /wheels/borg
COPY --from=build-drone /wheels /wheels/drone COPY --from=build-drone /wheels /wheels/drone
COPY --from=build-drone /requirements.txt /wheels/drone.txt COPY --from=build-drone /requirements.txt /wheels/drone.txt
# hadolint ignore=DL3013
RUN python -m pip install borgbackup[pyfuse3] \ RUN python -m pip install borgbackup[pyfuse3] \
--upgrade \ --upgrade \
--pre \ --pre \