From 1abecfa8dd46dae05f1651b63c0d47852b6261ce Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Thu, 18 May 2023 02:06:33 +0200 Subject: [PATCH] feat(paperless-ngx): Add missing var and a health check to upstream repo patch --- paperless_ngx/README.md | 18 ++++++++++++++---- paperless_ngx/build-context/Dockerfile | 18 +++++------------- paperless_ngx/docker-compose.override.yml | 7 +++---- ...fully.qualified.domain.name_ctx.env.example | 1 + 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/paperless_ngx/README.md b/paperless_ngx/README.md index beeaaa9..afaac3e 100644 --- a/paperless_ngx/README.md +++ b/paperless_ngx/README.md @@ -10,18 +10,28 @@ Examples assume we're using the `docker-compose.postgres-tika.yml` file which sp * Set env vars ``` - export COMPOSE_DIR='/opt/git/github.com/paperless-ngx/paperless-ngx/branches/dev/docker/compose' + export UPSTREAM_REPO_DIR='/opt/git/github.com/paperless-ngx/paperless-ngx/branches/dev' + export UPSTREAM_COMPOSE_DIR="${UPSTREAM_REPO_DIR%/}"'/docker/compose' + export UPSTREAM_COMPOSE_FILE="${UPSTREAM_COMPOSE_DIR%/}"'/docker-compose.postgres-tika.yml' export COMPOSE_CTX='hr_juba' export COMPOSE_PROJECT_NAME='paperless_ngx-'"${COMPOSE_CTX}" - export COMPOSE_FILE="${COMPOSE_DIR%/}"'/docker-compose.postgres-tika.yml' + export COMPOSE_PROJECT_DIR='/opt/containers/paperless_ngx' + export COMPOSE_OVERRIDE_FILE="${COMPOSE_PROJECT_DIR%/}"'/docker-compose.override.yml' export COMPOSE_ENV_FILE= ``` -Also check out the example env file at [env/fully.qualified.domain.name_ctx.env.example](env/fully.qualified.domain.name_ctx.env.example). + Also check out the example env file at [env/fully.qualified.domain.name_ctx.env.example](env/fully.qualified.domain.name_ctx.env.example). + +* Build + ``` + docker compose --project-directory "${COMPOSE_PROJECT_DIR}" --file "${UPSTREAM_COMPOSE_FILE}" --file "${COMPOSE_OVERRIDE_FILE}" --env-file "${COMPOSE_ENV_FILE}" --profile 'build' build + ``` + + We're building a custom PostgreSQL image with `ping` installed. We're using that to do a health check on our virtual IP (VIP) address. We've added a dependency to the main `paperless-ngx` web server container so that it only starts after the PostgreSQL container with its health check confirms that the VIP is reachable. * Start containers ``` - docker compose --project-name "${COMPOSE_PROJECT_NAME}" --file "${COMPOSE_FILE}" --env-file "${COMPOSE_ENV_FILE}" up --detach + docker compose --project-name "${COMPOSE_PROJECT_NAME}" --file "${UPSTREAM_COMPOSE_FILE}" --env-file "${COMPOSE_ENV_FILE}" up --detach ``` # Prep work diff --git a/paperless_ngx/build-context/Dockerfile b/paperless_ngx/build-context/Dockerfile index df7c3eb..a314d7f 100644 --- a/paperless_ngx/build-context/Dockerfile +++ b/paperless_ngx/build-context/Dockerfile @@ -1,14 +1,6 @@ -# For the remainder of this Dockerfile EXAMPLE_ARG_FOR_DOCKERFILE will be -# available with a value of 'must_be_available_in_dockerfile', check out the env -# file at 'env/fully.qualified.domain.name.example' for reference. -# ARG EXAMPLE_ARG_FOR_DOCKERFILE +ARG PGSQL_VERSION -# Another env var, this one's needed in the example build step below: -# ARG PAPERLESS_NGX_VERSION - -# Example -# FROM "paperless_ngx:${PAPERLESS_NGX_VERSION}" -# RUN apt-get update && \ -# apt-get -y install \ -# somepackage-6.q16-6-extra && \ -# rm -rf /var/lib/apt/lists/* +FROM "docker.io/library/postgres:${PGSQL_VERSION}" +RUN apt-get update && \ + apt-get -y install iputils-ping && \ + rm -rf /var/lib/apt/lists/* diff --git a/paperless_ngx/docker-compose.override.yml b/paperless_ngx/docker-compose.override.yml index a45fb95..f632ea8 100644 --- a/paperless_ngx/docker-compose.override.yml +++ b/paperless_ngx/docker-compose.override.yml @@ -1,10 +1,9 @@ services: paperless_ngx-build: - image: "paperless_ngx:${PAPERLESS_NGX_VERSION}" + image: "docker.io/library/postgres:${PGSQL_VERSION}" profiles: ["build"] build: - context: "build-context/paperless_ngx" + context: "build-context" dockerfile: Dockerfile args: - EXAMPLE_ARG_FOR_DOCKERFILE: "${EXAMPLE_ARG_FROM_ENV_FILE}" - PAPERLESS_NGX_VERSION: "${PAPERLESS_NGX_VERSION}" + PGSQL_VERSION: "${PGSQL_VERSION}" diff --git a/paperless_ngx/env/fully.qualified.domain.name_ctx.env.example b/paperless_ngx/env/fully.qualified.domain.name_ctx.env.example index 3a9942d..7c5fc93 100644 --- a/paperless_ngx/env/fully.qualified.domain.name_ctx.env.example +++ b/paperless_ngx/env/fully.qualified.domain.name_ctx.env.example @@ -8,6 +8,7 @@ PAPERLESS_OCR_LANGUAGES=bos PAPERLESS_SECRET_KEY=face-roll-your-keyboard-here PAPERLESS_TIME_ZONE=Africa/Juba PAPERLESS_URL=https://fully.qualified.domain.name +PGSQL_VERSION=13 SUBNET=172.22.17.0/24 TIMEZONE=Africa/Juba WEBSERVER_PORT=8080