From daad634894831b410b9348587ffdde389bf72ae2 Mon Sep 17 00:00:00 2001 From: Trenton Holmes Date: Fri, 15 Jul 2022 13:45:23 -0700 Subject: [PATCH 1/4] Adds a CI job for hadolint over all the Dockerfiles, fixes the minor thing it complained about --- .github/workflows/reusable-ci-backend.yml | 23 +++++++++++++++++++ Dockerfile | 27 +++++++++++------------ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/.github/workflows/reusable-ci-backend.yml b/.github/workflows/reusable-ci-backend.yml index b6459c110..2b54c6a8f 100644 --- a/.github/workflows/reusable-ci-backend.yml +++ b/.github/workflows/reusable-ci-backend.yml @@ -106,3 +106,26 @@ jobs: run: | cd src/ pipenv run coveralls --service=github + + dockerfile-lint: + name: "Lint ${{ matrix.dockerfile }}" + runs-on: ubuntu-20.04 + strategy: + matrix: + dockerfile: + - Dockerfile + - docker-builders/Dockerfile.qpdf + - docker-builders/Dockerfile.jbig2enc + - docker-builders/Dockerfile.psycopg2 + - docker-builders/Dockerfile.pikepdf + fail-fast: false + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + uses: hadolint/hadolint-action@v2.0.0 + with: + failure-threshold: warning + dockerfile: ${{ matrix.dockerfile }} + ignore: DL3008,DL3013,DL3003 diff --git a/Dockerfile b/Dockerfile index 981a194c9..c57f0b806 100644 --- a/Dockerfile +++ b/Dockerfile @@ -117,19 +117,18 @@ COPY gunicorn.conf.py . # setup docker-specific things # Use mounts to avoid copying installer files into the image # These change sometimes, but rarely -ARG DOCKER_SRC=/usr/src/paperless/src/docker/ -WORKDIR ${DOCKER_SRC} +WORKDIR /usr/src/paperless/src/docker/ COPY [ \ - "docker/imagemagick-policy.xml", \ - "docker/supervisord.conf", \ - "docker/docker-entrypoint.sh", \ - "docker/docker-prepare.sh", \ - "docker/paperless_cmd.sh", \ - "docker/wait-for-redis.py", \ - "docker/management_script.sh", \ - "docker/install_management_commands.sh", \ - "${DOCKER_SRC}" \ + "docker/imagemagick-policy.xml", \ + "docker/supervisord.conf", \ + "docker/docker-entrypoint.sh", \ + "docker/docker-prepare.sh", \ + "docker/paperless_cmd.sh", \ + "docker/wait-for-redis.py", \ + "docker/management_script.sh", \ + "docker/install_management_commands.sh", \ + "/usr/src/paperless/src/docker/" \ ] RUN set -eux \ @@ -162,15 +161,15 @@ RUN --mount=type=bind,from=qpdf-builder,target=/qpdf \ && apt-get install --yes --no-install-recommends /qpdf/usr/src/qpdf/libqpdf28_*.deb \ && apt-get install --yes --no-install-recommends /qpdf/usr/src/qpdf/qpdf_*.deb \ && echo "Installing pikepdf and dependencies" \ + && python3 -m pip install --no-cache-dir /pikepdf/usr/src/wheels/pyparsing*.whl \ && python3 -m pip install --no-cache-dir /pikepdf/usr/src/wheels/packaging*.whl \ && python3 -m pip install --no-cache-dir /pikepdf/usr/src/wheels/lxml*.whl \ && python3 -m pip install --no-cache-dir /pikepdf/usr/src/wheels/Pillow*.whl \ - && python3 -m pip install --no-cache-dir /pikepdf/usr/src/wheels/pyparsing*.whl \ && python3 -m pip install --no-cache-dir /pikepdf/usr/src/wheels/pikepdf*.whl \ - && python -m pip list \ + && python3 -m pip list \ && echo "Installing psycopg2" \ && python3 -m pip install --no-cache-dir /psycopg2/usr/src/wheels/psycopg2*.whl \ - && python -m pip list + && python3 -m pip list # Python dependencies # Change pretty frequently From 329a317fdf04ce905b9e3bfcbefb7e3a21f04659 Mon Sep 17 00:00:00 2001 From: Trenton Holmes Date: Tue, 19 Jul 2022 13:54:33 -0700 Subject: [PATCH 2/4] Configure Hadolint in a single location for both hooks and CI --- .github/workflows/reusable-ci-backend.yml | 4 +--- .hadolint.yml | 8 ++++++++ .pre-commit-config.yaml | 7 ------- 3 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 .hadolint.yml diff --git a/.github/workflows/reusable-ci-backend.yml b/.github/workflows/reusable-ci-backend.yml index 2b54c6a8f..663a954b5 100644 --- a/.github/workflows/reusable-ci-backend.yml +++ b/.github/workflows/reusable-ci-backend.yml @@ -124,8 +124,6 @@ jobs: name: Checkout uses: actions/checkout@v3 - - uses: hadolint/hadolint-action@v2.0.0 + uses: hadolint/hadolint-action@v2.0 with: - failure-threshold: warning dockerfile: ${{ matrix.dockerfile }} - ignore: DL3008,DL3013,DL3003 diff --git a/.hadolint.yml b/.hadolint.yml new file mode 100644 index 000000000..e195127fe --- /dev/null +++ b/.hadolint.yml @@ -0,0 +1,8 @@ +failure-threshold: warning +ignored: + # https://github.com/hadolint/hadolint/wiki/DL3008 + - DL3008 + # https://github.com/hadolint/hadolint/wiki/DL3013 + - DL3013 + # https://github.com/hadolint/hadolint/wiki/DL3003 + - DL3003 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 46ad91ee8..70496a4d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -74,13 +74,6 @@ repos: rev: v2.10.0 hooks: - id: hadolint - args: - - --ignore - - DL3008 # https://github.com/hadolint/hadolint/wiki/DL3008 (should probably do this at some point) - - --ignore - - DL3013 # https://github.com/hadolint/hadolint/wiki/DL3013 (should probably do this too at some point) - - --ignore - - DL3003 # https://github.com/hadolint/hadolint/wiki/DL3003 (seems excessive to use WORKDIR so much) # Shell script hooks - repo: https://github.com/lovesegfault/beautysh rev: v6.2.1 From 27721aef71529e133487294e79585bc2c8f6f451 Mon Sep 17 00:00:00 2001 From: Trenton Holmes Date: Tue, 19 Jul 2022 14:01:47 -0700 Subject: [PATCH 3/4] Fixes and updates the Hadolint action version --- .github/workflows/reusable-ci-backend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-ci-backend.yml b/.github/workflows/reusable-ci-backend.yml index 663a954b5..333a94fc1 100644 --- a/.github/workflows/reusable-ci-backend.yml +++ b/.github/workflows/reusable-ci-backend.yml @@ -124,6 +124,6 @@ jobs: name: Checkout uses: actions/checkout@v3 - - uses: hadolint/hadolint-action@v2.0 + uses: hadolint/hadolint-action@v2.1.0 with: dockerfile: ${{ matrix.dockerfile }} From 16b0f7f9ee96a5fdf3c1c989dba0db9279bc907c Mon Sep 17 00:00:00 2001 From: Trenton Holmes Date: Tue, 19 Jul 2022 14:18:47 -0700 Subject: [PATCH 4/4] Removes a Dockerfile I can't find referenced anywhere --- docs/Dockerfile | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 docs/Dockerfile diff --git a/docs/Dockerfile b/docs/Dockerfile deleted file mode 100644 index bb4b35e2d..000000000 --- a/docs/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM python:3.5.1 - -# Install Sphinx and Pygments -RUN pip install --no-cache-dir Sphinx Pygments \ - # Setup directories, copy data - && mkdir /build - -COPY . /build -WORKDIR /build/docs - -# Build documentation -RUN make html - -# Start webserver -WORKDIR /build/docs/_build/html -EXPOSE 8000/tcp -CMD ["python3", "-m", "http.server"]