Support registry token for VPN image pulls
Build & Deploy / Build & Push Docker Image (push) Successful in 2m50s
Test / Type Check (all packages) (push) Successful in 50s
Build & Deploy / Deploy to VPS (push) Successful in 4s
Test / API Unit Tests (push) Successful in 45s
Test / Homepage Unit Tests (push) Successful in 42s
Test / Storefront Unit Tests (push) Successful in 40s
Test / Admin Unit Tests (push) Successful in 41s
Test / Dashboard Unit Tests (push) Successful in 40s
Test / API Integration Tests (push) Successful in 59s

This commit is contained in:
root
2026-07-02 11:49:58 -04:00
parent 0394f0ea2a
commit 1fd1ddf3f2
6 changed files with 38 additions and 14 deletions
@@ -14,6 +14,7 @@ APP_IMAGE=10.0.0.4/melabidi/carmanagement
# External image registry host. REGISTRY_USER and REGISTRY_PASSWORD are only needed when docker login is required. # External image registry host. REGISTRY_USER and REGISTRY_PASSWORD are only needed when docker login is required.
REGISTRY_HOST=10.0.0.4 REGISTRY_HOST=10.0.0.4
REGISTRY_USER=melabidi REGISTRY_USER=melabidi
REGISTRY_TOKEN=
REGISTRY_PASSWORD= REGISTRY_PASSWORD=
# Optional shared folder for image archives. Leave empty when the VPS can pull from the VPN registry directly. # Optional shared folder for image archives. Leave empty when the VPS can pull from the VPN registry directly.
+2 -1
View File
@@ -40,7 +40,7 @@ At minimum, verify or rotate:
If Docker needs to log in before pulling the app image, also set: If Docker needs to log in before pulling the app image, also set:
- `REGISTRY_USER` - `REGISTRY_USER`
- `REGISTRY_PASSWORD` - `REGISTRY_TOKEN`
For the current VPN-reachable image registry, use direct pulls from the VPS. For the current VPN-reachable image registry, use direct pulls from the VPS.
The registry is `10.0.0.4`, and the VPS WireGuard address is `10.0.0.1`. The registry is `10.0.0.4`, and the VPS WireGuard address is `10.0.0.1`.
@@ -49,6 +49,7 @@ The registry is `10.0.0.4`, and the VPS WireGuard address is `10.0.0.1`.
APP_IMAGE=10.0.0.4/melabidi/carmanagement APP_IMAGE=10.0.0.4/melabidi/carmanagement
REGISTRY_HOST=10.0.0.4 REGISTRY_HOST=10.0.0.4
REGISTRY_USER=melabidi REGISTRY_USER=melabidi
REGISTRY_TOKEN=<registry-token>
IMAGE_ARCHIVE_DIR= IMAGE_ARCHIVE_DIR=
IMAGE_ARCHIVE_REQUIRED=false IMAGE_ARCHIVE_REQUIRED=false
``` ```
+12 -1
View File
@@ -117,10 +117,16 @@ load_prod_env_exports() {
REGISTRY_HOST \ REGISTRY_HOST \
REGISTRY_USER \ REGISTRY_USER \
REGISTRY_PASSWORD \ REGISTRY_PASSWORD \
REGISTRY_TOKEN \
VPN_CONTAINER VPN_CONTAINER
do do
export_env_value_if_unset "${key}" export_env_value_if_unset "${key}"
done done
if [[ -z "${REGISTRY_PASSWORD:-}" && -n "${REGISTRY_TOKEN:-}" ]]; then
REGISTRY_PASSWORD="${REGISTRY_TOKEN}"
export REGISTRY_PASSWORD
fi
} }
validate_prod_env_file() { validate_prod_env_file() {
@@ -228,6 +234,11 @@ require_release_image() {
login_registry_if_configured() { login_registry_if_configured() {
local archive_disabled="${IMAGE_ARCHIVE_DISABLED:-false}" local archive_disabled="${IMAGE_ARCHIVE_DISABLED:-false}"
if [[ -z "${REGISTRY_PASSWORD:-}" && -n "${REGISTRY_TOKEN:-}" ]]; then
REGISTRY_PASSWORD="${REGISTRY_TOKEN}"
export REGISTRY_PASSWORD
fi
if [[ "${IMAGE_ARCHIVE_REQUIRED:-false}" == "true" || "${IMAGE_ARCHIVE_REQUIRED:-0}" == "1" ]]; then if [[ "${IMAGE_ARCHIVE_REQUIRED:-false}" == "true" || "${IMAGE_ARCHIVE_REQUIRED:-0}" == "1" ]]; then
if [[ "${archive_disabled}" != "true" && "${archive_disabled}" != "1" ]]; then if [[ "${archive_disabled}" != "true" && "${archive_disabled}" != "1" ]]; then
echo "IMAGE_ARCHIVE_REQUIRED is enabled; skipping docker login." echo "IMAGE_ARCHIVE_REQUIRED is enabled; skipping docker login."
@@ -258,7 +269,7 @@ login_registry_if_configured() {
fi fi
if [[ -z "${REGISTRY_HOST:-}" || -z "${REGISTRY_USER:-}" || -z "${REGISTRY_PASSWORD:-}" ]]; then if [[ -z "${REGISTRY_HOST:-}" || -z "${REGISTRY_USER:-}" || -z "${REGISTRY_PASSWORD:-}" ]]; then
echo "REGISTRY_HOST, REGISTRY_USER, and REGISTRY_PASSWORD are all required when registry credentials are configured." >&2 echo "REGISTRY_HOST, REGISTRY_USER, and REGISTRY_PASSWORD or REGISTRY_TOKEN are required when registry credentials are configured." >&2
exit 1 exit 1
fi fi
@@ -55,19 +55,19 @@ prompt_registry_password_if_needed() {
return 0 return 0
fi fi
if [[ -n "${REGISTRY_PASSWORD:-}" ]]; then if [[ -n "${REGISTRY_PASSWORD:-}" || -n "${REGISTRY_TOKEN:-}" ]]; then
return 0 return 0
fi fi
if [[ ! -t 0 ]]; then if [[ ! -t 0 ]]; then
echo "REGISTRY_PASSWORD is not set and no interactive terminal is available for a prompt." >&2 echo "REGISTRY_TOKEN or REGISTRY_PASSWORD is not set and no interactive terminal is available for a prompt." >&2
exit 1 exit 1
fi fi
printf 'Registry password for %s@%s: ' "${REGISTRY_USER}" "${REGISTRY_HOST}" >&2 printf 'Registry token for %s@%s: ' "${REGISTRY_USER}" "${REGISTRY_HOST}" >&2
read -r -s REGISTRY_PASSWORD read -r -s REGISTRY_TOKEN
printf '\n' >&2 printf '\n' >&2
export REGISTRY_PASSWORD export REGISTRY_TOKEN
} }
echo "Starting production services from pulled image ${APP_IMAGE}:${APP_VERSION}" echo "Starting production services from pulled image ${APP_IMAGE}:${APP_VERSION}"
+13 -2
View File
@@ -111,10 +111,16 @@ load_prod_env_exports() {
IMAGE_ARCHIVE_REQUIRED \ IMAGE_ARCHIVE_REQUIRED \
REGISTRY_HOST \ REGISTRY_HOST \
REGISTRY_USER \ REGISTRY_USER \
REGISTRY_PASSWORD REGISTRY_PASSWORD \
REGISTRY_TOKEN
do do
export_env_value_if_unset "${key}" export_env_value_if_unset "${key}"
done done
if [[ -z "${REGISTRY_PASSWORD:-}" && -n "${REGISTRY_TOKEN:-}" ]]; then
REGISTRY_PASSWORD="${REGISTRY_TOKEN}"
export REGISTRY_PASSWORD
fi
} }
validate_prod_env_file() { validate_prod_env_file() {
@@ -239,6 +245,11 @@ require_release_image() {
} }
login_registry_if_configured() { login_registry_if_configured() {
if [[ -z "${REGISTRY_PASSWORD:-}" && -n "${REGISTRY_TOKEN:-}" ]]; then
REGISTRY_PASSWORD="${REGISTRY_TOKEN}"
export REGISTRY_PASSWORD
fi
if [[ "${IMAGE_ARCHIVE_REQUIRED:-false}" == "true" || "${IMAGE_ARCHIVE_REQUIRED:-0}" == "1" ]]; then if [[ "${IMAGE_ARCHIVE_REQUIRED:-false}" == "true" || "${IMAGE_ARCHIVE_REQUIRED:-0}" == "1" ]]; then
echo "IMAGE_ARCHIVE_REQUIRED is enabled; skipping docker login." echo "IMAGE_ARCHIVE_REQUIRED is enabled; skipping docker login."
return 0 return 0
@@ -267,7 +278,7 @@ login_registry_if_configured() {
fi fi
if [[ -z "${REGISTRY_HOST:-}" || -z "${REGISTRY_USER:-}" || -z "${REGISTRY_PASSWORD:-}" ]]; then if [[ -z "${REGISTRY_HOST:-}" || -z "${REGISTRY_USER:-}" || -z "${REGISTRY_PASSWORD:-}" ]]; then
echo "REGISTRY_HOST, REGISTRY_USER, and REGISTRY_PASSWORD are all required when registry credentials are configured." >&2 echo "REGISTRY_HOST, REGISTRY_USER, and REGISTRY_PASSWORD or REGISTRY_TOKEN are required when registry credentials are configured." >&2
exit 1 exit 1
fi fi
+5 -5
View File
@@ -55,19 +55,19 @@ prompt_registry_password_if_needed() {
return 0 return 0
fi fi
if [[ -n "${REGISTRY_PASSWORD:-}" ]]; then if [[ -n "${REGISTRY_PASSWORD:-}" || -n "${REGISTRY_TOKEN:-}" ]]; then
return 0 return 0
fi fi
if [[ ! -t 0 ]]; then if [[ ! -t 0 ]]; then
echo "REGISTRY_PASSWORD is not set and no interactive terminal is available for a prompt." >&2 echo "REGISTRY_TOKEN or REGISTRY_PASSWORD is not set and no interactive terminal is available for a prompt." >&2
exit 1 exit 1
fi fi
printf 'Registry password for %s@%s: ' "${REGISTRY_USER}" "${REGISTRY_HOST}" >&2 printf 'Registry token for %s@%s: ' "${REGISTRY_USER}" "${REGISTRY_HOST}" >&2
read -r -s REGISTRY_PASSWORD read -r -s REGISTRY_TOKEN
printf '\n' >&2 printf '\n' >&2
export REGISTRY_PASSWORD export REGISTRY_TOKEN
} }
echo "Starting production services from pulled image ${APP_IMAGE}:${APP_VERSION}" echo "Starting production services from pulled image ${APP_IMAGE}:${APP_VERSION}"