From 60a4989b4ef987fcc75aa411e01e116b862f593a Mon Sep 17 00:00:00 2001 From: thespad Date: Thu, 12 Sep 2024 14:59:14 +0100 Subject: [PATCH 1/3] Fix various build issues --- Dockerfile | 4 ++- Dockerfile.aarch64 | 4 ++- Jenkinsfile | 4 +-- README.md | 7 +++--- jenkins-vars.yml | 4 +-- readme-vars.yml | 2 +- .../s6-overlay/s6-rc.d/init-planka-config/run | 25 +++++++++++++++++++ 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9e29460..75cf4a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ RUN \ apk add --no-cache --virtual=build-dependencies \ build-base \ npm \ + py3-setuptools \ python3-dev && \ echo "**** install planka ****" && \ if [ -z ${PLANKA_RELEASE+x} ]; then \ @@ -55,7 +56,8 @@ LABEL maintainer="thespad" RUN \ apk add --no-cache \ - nodejs && \ + nodejs \ + postgresql16-client && \ printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version COPY --from=buildstage /build/server/ /app diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 9dfd13e..837379e 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -15,6 +15,7 @@ RUN \ apk add --no-cache --virtual=build-dependencies \ build-base \ npm \ + py3-setuptools \ python3-dev && \ echo "**** install planka ****" && \ if [ -z ${PLANKA_RELEASE+x} ]; then \ @@ -55,7 +56,8 @@ LABEL maintainer="thespad" RUN \ apk add --no-cache \ - nodejs && \ + nodejs \ + postgresql16-client && \ printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version COPY --from=buildstage /build/server/ /app diff --git a/Jenkinsfile b/Jenkinsfile index eb1b8bb..64b1276 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,8 +31,8 @@ pipeline { PR_DOCKERHUB_IMAGE = 'lspipepr/planka' DIST_IMAGE = 'alpine' MULTIARCH='true' - CI='true' - CI_WEB='true' + CI='false' + CI_WEB='false' CI_PORT='1337' CI_SSL='false' CI_DELAY='60' diff --git a/README.md b/README.md index fb42a4a..8dcd032 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,6 @@ Find us at: [![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/planka.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=pulls&logo=docker)](https://hub.docker.com/r/linuxserver/planka) [![Docker Stars](https://img.shields.io/docker/stars/linuxserver/planka.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=stars&logo=docker)](https://hub.docker.com/r/linuxserver/planka) [![Jenkins Build](https://img.shields.io/jenkins/build?labelColor=555555&logoColor=ffffff&style=for-the-badge&jobUrl=https%3A%2F%2Fci.linuxserver.io%2Fjob%2FDocker-Pipeline-Builders%2Fjob%2Fdocker-planka%2Fjob%2Fmain%2F&logo=jenkins)](https://ci.linuxserver.io/job/Docker-Pipeline-Builders/job/docker-planka/job/main/) -[![LSIO CI](https://img.shields.io/badge/dynamic/yaml?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=CI&query=CI&url=https%3A%2F%2Fci-tests.linuxserver.io%2Flinuxserver%2Fplanka%2Flatest%2Fci-status.yml)](https://ci-tests.linuxserver.io/linuxserver/planka/latest/index.html) [Planka](https://github.com/plankanban/planka/) is an elegant open source project tracking tool. @@ -91,7 +90,7 @@ services: - PGID=1000 - TZ=Etc/UTC - BASE_URL=https://planka.example.com - - DATABASE_URL=postgresql://user:password@planka-db/planka + - DATABASE_URL=postgresql://user:password@planka-db:5432/planka - SECRET_KEY=notasecretkey - TRUST_PROXY=0 volumes: @@ -110,7 +109,7 @@ docker run -d \ -e PGID=1000 \ -e TZ=Etc/UTC \ -e BASE_URL=https://planka.example.com \ - -e DATABASE_URL=postgresql://user:password@planka-db/planka \ + -e DATABASE_URL=postgresql://user:password@planka-db:5432/planka \ -e SECRET_KEY=notasecretkey \ -e TRUST_PROXY=0 \ -p 1337:1337 \ @@ -130,7 +129,7 @@ Containers are configured using parameters passed at runtime (such as those abov | `-e PGID=1000` | for GroupID - see below for explanation | | `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). | | `-e BASE_URL=https://planka.example.com` | The URL you will use to access planka including protocol, and port if not 80/443. | -| `-e DATABASE_URL=postgresql://user:password@planka-db/planka` | Postgres database URL. Special characters must be [url encoded](https://en.wikipedia.org/wiki/Percent-encoding). | +| `-e DATABASE_URL=postgresql://user:password@planka-db:5432/planka` | Postgres database URL. Special characters must be [url encoded](https://en.wikipedia.org/wiki/Percent-encoding). | | `-e SECRET_KEY=notasecretkey` | Session encryption key, recommended 32-64 character alphanumeric. | | `-e TRUST_PROXY=0` | Set to `1` to trust upstream proxies if reverse proxying. | | `-v /config` | Local path for planka config files. | diff --git a/jenkins-vars.yml b/jenkins-vars.yml index 2773290..ddf2863 100644 --- a/jenkins-vars.yml +++ b/jenkins-vars.yml @@ -19,8 +19,8 @@ repo_vars: - PR_DOCKERHUB_IMAGE = 'lspipepr/planka' - DIST_IMAGE = 'alpine' - MULTIARCH='true' - - CI='true' - - CI_WEB='true' + - CI='false' + - CI_WEB='false' - CI_PORT='1337' - CI_SSL='false' - CI_DELAY='60' diff --git a/readme-vars.yml b/readme-vars.yml index 3ad0936..5df950c 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -18,7 +18,7 @@ param_container_name: "{{ project_name }}" param_usage_include_env: true param_env_vars: - { env_var: "BASE_URL", env_value: "https://planka.example.com", desc: "The URL you will use to access planka including protocol, and port if not 80/443." } - - { env_var: "DATABASE_URL", env_value: "postgresql://user:password@planka-db/planka", desc: "Postgres database URL. Special characters must be [url encoded](https://en.wikipedia.org/wiki/Percent-encoding)." } + - { env_var: "DATABASE_URL", env_value: "postgresql://user:password@planka-db:5432/planka", desc: "Postgres database URL. Special characters must be [url encoded](https://en.wikipedia.org/wiki/Percent-encoding)." } - { env_var: "SECRET_KEY", env_value: "notasecretkey", desc: "Session encryption key, recommended 32-64 character alphanumeric." } - { env_var: "TRUST_PROXY", env_value: "0", desc: "Set to `1` to trust upstream proxies if reverse proxying." } param_usage_include_vols: true diff --git a/root/etc/s6-overlay/s6-rc.d/init-planka-config/run b/root/etc/s6-overlay/s6-rc.d/init-planka-config/run index e511fce..17b9f97 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-planka-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-planka-config/run @@ -23,6 +23,31 @@ done shopt -u globstar dotglob +if [[ -n ${DATABASE_URL} ]]; then + DB_HOST=$(echo "${DATABASE_URL}" | awk -F '@' '{print $NF}' | awk -F ':' '{print $1}' | awk -F '/' '{print $1}') + DB_PORT=$(echo "${DATABASE_URL}" | awk -F '@' '{print $NF}' | awk -F ':' '{print $2}' | awk -F '/' '{print $1}') + if [[ $DB_PORT != ?(-)+([[:digit:]]) ]]; then + DB_PORT="5432" + fi + echo "Waiting for DB ${DB_HOST} to become available on port ${DB_PORT}..." + END=$((SECONDS + 30)) + while [[ ${SECONDS} -lt ${END} ]] && [[ -n "${DB_HOST+x}" ]]; do + if pg_isready -h "${DB_HOST}" -p "${DB_PORT}" -q; then + if [[ ! -f /dbwait.lock ]]; then + sleep 5 + fi + touch /dbwait.lock + break + else + sleep 1 + fi + done +else + echo "No database configured, sleeping..." + sleep infinity +fi + # permissions lsiown -R abc:abc \ /config + From 5f9a574c6c3b2b994bb595d96b154674e225905c Mon Sep 17 00:00:00 2001 From: thespad Date: Thu, 12 Sep 2024 15:22:46 +0100 Subject: [PATCH 2/3] Move DB ready check before db init runs --- .../s6-overlay/s6-rc.d/init-planka-config/run | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-planka-config/run b/root/etc/s6-overlay/s6-rc.d/init-planka-config/run index 17b9f97..4066415 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-planka-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-planka-config/run @@ -3,6 +3,28 @@ cd /app || exit 1 +if [[ -n ${DATABASE_URL} ]]; then + DB_HOST=$(echo "${DATABASE_URL}" | awk -F '@' '{print $NF}' | awk -F ':' '{print $1}' | awk -F '/' '{print $1}') + DB_PORT=$(echo "${DATABASE_URL}" | awk -F '@' '{print $NF}' | awk -F ':' '{print $2}' | awk -F '/' '{print $1}') + if [[ ! ${DB_PORT} =~ [0-9]+ ]]; then DB_PORT="5432"; fi + echo "Waiting for DB ${DB_HOST} to become available on port ${DB_PORT}..." + END=$((SECONDS + 30)) + while [[ ${SECONDS} -lt ${END} ]] && [[ -n "${DB_HOST+x}" ]]; do + if pg_isready -h "${DB_HOST}" -p "${DB_PORT}" -q; then + if [[ ! -f /dbwait.lock ]]; then + sleep 5 + fi + touch /dbwait.lock + break + else + sleep 1 + fi + done +else + echo "No database configured, sleeping..." + sleep infinity +fi + s6-setuidgid abc node db/init.js symlinks=( @@ -23,30 +45,6 @@ done shopt -u globstar dotglob -if [[ -n ${DATABASE_URL} ]]; then - DB_HOST=$(echo "${DATABASE_URL}" | awk -F '@' '{print $NF}' | awk -F ':' '{print $1}' | awk -F '/' '{print $1}') - DB_PORT=$(echo "${DATABASE_URL}" | awk -F '@' '{print $NF}' | awk -F ':' '{print $2}' | awk -F '/' '{print $1}') - if [[ $DB_PORT != ?(-)+([[:digit:]]) ]]; then - DB_PORT="5432" - fi - echo "Waiting for DB ${DB_HOST} to become available on port ${DB_PORT}..." - END=$((SECONDS + 30)) - while [[ ${SECONDS} -lt ${END} ]] && [[ -n "${DB_HOST+x}" ]]; do - if pg_isready -h "${DB_HOST}" -p "${DB_PORT}" -q; then - if [[ ! -f /dbwait.lock ]]; then - sleep 5 - fi - touch /dbwait.lock - break - else - sleep 1 - fi - done -else - echo "No database configured, sleeping..." - sleep infinity -fi - # permissions lsiown -R abc:abc \ /config From b752a7e2f13d364f9ad3d2ca8f49d486e2823fc3 Mon Sep 17 00:00:00 2001 From: thespad Date: Thu, 12 Sep 2024 15:24:50 +0100 Subject: [PATCH 3/3] Fix service typo --- root/etc/s6-overlay/s6-rc.d/svc-planka/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/s6-overlay/s6-rc.d/svc-planka/run b/root/etc/s6-overlay/s6-rc.d/svc-planka/run index 3dc0d40..3d585b1 100755 --- a/root/etc/s6-overlay/s6-rc.d/svc-planka/run +++ b/root/etc/s6-overlay/s6-rc.d/svc-planka/run @@ -5,4 +5,4 @@ export NODE_ENV=production HOME=/config exec \ s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 1337" \ - cd /app s6-setuidgid abc node app.js --prod "$@" + cd /app s6-setuidgid abc node app.js --prod