fix prod ddeployment

This commit is contained in:
root
2026-06-02 12:53:45 -04:00
parent b5a974ee14
commit e9dfbeb591
9 changed files with 224 additions and 104 deletions
+19 -26
View File
@@ -5,6 +5,7 @@ stages:
variables:
DOCKERFILE_PATH: Dockerfile.production
DEPLOY_ROOT: /opt/rentaldrivego
# Required: disable TLS so the docker client can reach the dind daemon
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375
@@ -141,35 +142,27 @@ deploy_to_vps:
script:
- echo "--- Deploying $DOCKER_IMAGE to VPS ---"
- |
REGISTRY_PASSWORD_B64="$(printf '%s' "$REGISTRY_PASSWORD" | base64 | tr -d '\n')"
echo "-- Syncing deployment assets --"
ssh $VPS_USER@$VPS_IP "
set -e
cd /opt/rentaldrivego
mkdir -p '$DEPLOY_ROOT/scripts' '$DEPLOY_ROOT/docker/pgmanage'
"
scp docker-compose.production.yml docker-compose.portainer.production.yml traefik.yaml $VPS_USER@$VPS_IP:$DEPLOY_ROOT/
scp scripts/docker-prod-common.sh scripts/docker-prod-deploy.sh $VPS_USER@$VPS_IP:$DEPLOY_ROOT/scripts/
scp docker/pgmanage/override.py $VPS_USER@$VPS_IP:$DEPLOY_ROOT/docker/pgmanage/
echo '-- Pulling latest code --'
git pull
echo '-- Logging into registry --'
test -n '$REGISTRY_HOST' || { echo 'Registry host is not set.'; exit 1; }
test -n '$REGISTRY_USER' || { echo 'Registry user is not set.'; exit 1; }
test -n '$REGISTRY_PASSWORD' || { echo 'Registry password is not set.'; exit 1; }
echo '$REGISTRY_PASSWORD' | docker login '$REGISTRY_HOST' -u '$REGISTRY_USER' --password-stdin
echo '-- Pulling pre-built image --'
docker pull $DOCKER_IMAGE
echo '-- Ensuring uploads volume exists --'
docker volume create rentaldrivego-prod_api_uploads >/dev/null
echo '-- Restarting services --'
APP_IMAGE=$IMAGE_REPOSITORY \
APP_VERSION=$CI_COMMIT_SHORT_SHA \
docker compose -p rentaldrivego-prod \
--env-file .env.docker.production \
-f docker-compose.production.yml \
up -d --no-build
echo '-- Pruning old images --'
docker image prune -f
echo "-- Running deploy script on VPS --"
ssh $VPS_USER@$VPS_IP "
set -e
cd '$DEPLOY_ROOT'
APP_IMAGE='$IMAGE_REPOSITORY' \
APP_VERSION='$CI_COMMIT_SHORT_SHA' \
REGISTRY_HOST='$REGISTRY_HOST' \
REGISTRY_USER='$REGISTRY_USER' \
REGISTRY_PASSWORD=\$(printf '%s' '$REGISTRY_PASSWORD_B64' | base64 -d) \
bash scripts/docker-prod-deploy.sh
"
rules:
# Deploy only when both registry access and VPS credentials are available.