From 8721ad5189460609499d7db76bd724def20e2750 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 25 Oct 2021 14:46:28 -0700 Subject: [PATCH] feat(docker): fixup and utilize AURWEB_(SSHD|FASTAPI|PHP)_PREFIX Previously CGIT_CLONE_PREFIX_(PHP|FASTAPI), we found that we could use the same env var in multiple places, including non-cgit-clone-prefix areas. So, they were renamed, and one additional prefix was added. - CGIT_CLONE_PREFIX_PHP -> AURWEB_PHP_PREFIX - Used for cgit's clone prefix and AUR_CONFIG's aur_location for PHP - CGIT_CLONE_PREFIX_FASTAPI -> AURWEB_FASTAPI_PREFIX - Used for cgit's clone prefix and AUR_CONFIG's aur_location for FastAPI - AURWEB_SSHD_PREFIX - Used for aurweb's sshd clone prefix shown on package pages Signed-off-by: Kevin Morris --- .env | 5 +++-- .gitlab-ci.yml | 4 ++++ docker-compose.aur-dev.yml | 6 ++++++ docker-compose.yml | 8 ++++++-- docker/fastapi-entrypoint.sh | 6 +++--- docker/php-entrypoint.sh | 6 +++--- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.env b/.env index 06e862c1..c95a67d5 100644 --- a/.env +++ b/.env @@ -1,7 +1,8 @@ FASTAPI_BACKEND="uvicorn" FASTAPI_WORKERS=2 MARIADB_SOCKET_DIR="/var/run/mysqld/" -CGIT_CLONE_PREFIX_PHP=https://localhost:8443 -CGIT_CLONE_PREFIX_FASTAPI=https://localhost:8444 +AURWEB_PHP_PREFIX=https://localhost:8443 +AURWEB_FASTAPI_PREFIX=https://localhost:8444 +AURWEB_SSHD_PREFIX=ssh://aur@localhost:2222 GIT_DATA_DIR="./aur.git/" TEST_RECURSION_LIMIT=10000 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d53805ac..8c037b47 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,6 +48,10 @@ deploy: - secure rules: - if: $CI_COMMIT_BRANCH == "docker-deploy" + variables: + AURWEB_PHP_PREFIX: https://aur-dev.archlinux.org + AURWEB_FASTAPI_PREFIX: https://aur-dev.archlinux.org + AURWEB_SSHD_PREFIX: ssh://aur@aur-dev.archlinux.org:2222 script: - pacman -Syu --noconfirm docker-compose socat openssh - chmod 600 ${SSH_KEY} diff --git a/docker-compose.aur-dev.yml b/docker-compose.aur-dev.yml index 2e7610dc..075b5bb2 100644 --- a/docker-compose.aur-dev.yml +++ b/docker-compose.aur-dev.yml @@ -39,6 +39,9 @@ services: php-fpm: restart: always + environment: + - AURWEB_PHP_PREFIX=${AURWEB_PHP_PREFIX} + - AURWEB_SSHD_PREFIX=${AURWEB_SSHD_PREFIX} volumes: - cache:/cache @@ -46,6 +49,9 @@ services: restart: always environment: - FASTAPI_BACKEND="gunicorn" + - FASTAPI_WORKERS=${FASTAPI_WORKERS} + - AURWEB_FASTAPI_PREFIX=${AURWEB_FASTAPI_PREFIX} + - AURWEB_SSHD_PREFIX=${AURWEB_SSHD_PREFIX} volumes: - cache:/cache diff --git a/docker-compose.yml b/docker-compose.yml index 195be637..2b25c7d8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -106,7 +106,7 @@ services: init: true environment: - AUR_CONFIG=/aurweb/conf/config - - CGIT_CLONE_PREFIX=$CGIT_CLONE_PREFIX_PHP + - CGIT_CLONE_PREFIX=${AURWEB_PHP_PREFIX} entrypoint: /docker/cgit-entrypoint.sh command: /docker/scripts/run-cgit.sh 3000 healthcheck: @@ -124,7 +124,7 @@ services: init: true environment: - AUR_CONFIG=/aurweb/conf/config - - CGIT_CLONE_PREFIX=$CGIT_CLONE_PREFIX_FASTAPI + - CGIT_CLONE_PREFIX=${AURWEB_FASTAPI_PREFIX} entrypoint: /docker/cgit-entrypoint.sh command: /docker/scripts/run-cgit.sh 3000 healthcheck: @@ -142,6 +142,8 @@ services: init: true environment: - AUR_CONFIG=/aurweb/conf/config + - AURWEB_PHP_PREFIX=${AURWEB_PHP_PREFIX} + - AURWEB_SSHD_PREFIX=${AURWEB_SSHD_PREFIX} entrypoint: /docker/php-entrypoint.sh command: /docker/scripts/run-php.sh healthcheck: @@ -164,6 +166,8 @@ services: environment: - AUR_CONFIG=conf/config - FASTAPI_WORKERS=${FASTAPI_WORKERS} + - AURWEB_FASTAPI_PREFIX=${AURWEB_FASTAPI_PREFIX} + - AURWEB_SSHD_PREFIX=${AURWEB_SSHD_PREFIX} entrypoint: /docker/fastapi-entrypoint.sh command: /docker/scripts/run-fastapi.sh "${FASTAPI_BACKEND}" healthcheck: diff --git a/docker/fastapi-entrypoint.sh b/docker/fastapi-entrypoint.sh index 9dba5562..6d91a16d 100755 --- a/docker/fastapi-entrypoint.sh +++ b/docker/fastapi-entrypoint.sh @@ -5,13 +5,13 @@ set -eou pipefail cp -vf conf/config.dev conf/config sed -i "s;YOUR_AUR_ROOT;$(pwd);g" conf/config -sed -ri "s;^(aur_location) = .+;\1 = https://localhost:8444;" conf/config +sed -ri "s;^(aur_location) = .+;\1 = ${AURWEB_FASTAPI_PREFIX};" conf/config # Setup Redis for FastAPI. sed -ri 's/^(cache) = .+/\1 = redis/' conf/config sed -ri 's|^(redis_address) = .+|\1 = redis://redis|' conf/config -sed -ri "s|^(git_clone_uri_anon) = .+|\1 = https://localhost:8444/%s.git|" conf/config.defaults -sed -ri "s|^(git_clone_uri_priv) = .+|\1 = ssh://aur@localhost:2222/%s.git|" conf/config.defaults +sed -ri "s|^(git_clone_uri_anon) = .+|\1 = ${AURWEB_FASTAPI_PREFIX}/%s.git|" conf/config.defaults +sed -ri "s|^(git_clone_uri_priv) = .+|\1 = ${AURWEB_SSHD_PREFIX}/%s.git|" conf/config.defaults exec "$@" diff --git a/docker/php-entrypoint.sh b/docker/php-entrypoint.sh index 5292fa93..81f70673 100755 --- a/docker/php-entrypoint.sh +++ b/docker/php-entrypoint.sh @@ -5,13 +5,13 @@ set -eou pipefail cp -vf conf/config.dev conf/config sed -i "s;YOUR_AUR_ROOT;$(pwd);g" conf/config -sed -ri "s;^(aur_location) = .+;\1 = https://localhost:8443;" conf/config +sed -ri "s;^(aur_location) = .+;\1 = ${AURWEB_PHP_PREFIX};" conf/config # Enable memcached. sed -ri 's/^(cache) = .+$/\1 = memcache/' conf/config -sed -ri "s|^(git_clone_uri_anon) = .+|\1 = https://localhost:8443/%s.git|" conf/config.defaults -sed -ri "s|^(git_clone_uri_priv) = .+|\1 = ssh://aur@localhost:2222/%s.git|" conf/config.defaults +sed -ri "s|^(git_clone_uri_anon) = .+|\1 = ${AURWEB_PHP_PREFIX}/%s.git|" conf/config.defaults +sed -ri "s|^(git_clone_uri_priv) = .+|\1 = ${AURWEB_SSHD_PREFIX}/%s.git|" conf/config.defaults sed -ri 's/^(listen).*/\1 = 0.0.0.0:9000/' /etc/php/php-fpm.d/www.conf sed -ri 's/^;?(clear_env).*/\1 = no/' /etc/php/php-fpm.d/www.conf