diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 304bfdb..d0efdad 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -42,41 +42,45 @@ jobs: cd /workspace/repo scp -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key slipmatz-web.tar.gz docker-compose.yml "$DEPLOY_USER@$DEPLOY_HOST:/tmp/" - ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key "$DEPLOY_USER@$DEPLOY_HOST" " - DEPLOY_DIR='/var/www/apps/slipmatz-web' - mkdir -p \$DEPLOY_DIR + ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key "$DEPLOY_USER@$DEPLOY_HOST" ' + DEPLOY_DIR="/var/www/apps/slipmatz-web" + mkdir -p $DEPLOY_DIR cd /tmp docker load < slipmatz-web.tar.gz - echo 'Removing old slipmatz-web images' - docker images | grep slipmatz-web | grep -v "\$(docker images slipmatz-web:latest -q)" | awk '{print \$3}' | xargs -r docker rmi -f || true + echo "Removing old slipmatz-web images" + CURRENT_IMAGE=$(docker images slipmatz-web:latest -q) + docker images | grep slipmatz-web | grep -v "$CURRENT_IMAGE" | awk "{print \$3}" | xargs -r docker rmi -f || true - cp docker-compose.yml \$DEPLOY_DIR/ - cd \$DEPLOY_DIR + cp docker-compose.yml $DEPLOY_DIR/ + cd $DEPLOY_DIR - # .env file should already exist on server with all required variables - # Required: NUXT_PUBLIC_*, STRIPE_SECRET_KEY, etc. - # If it doesn't exist, deployment will fail (this is intentional for security) + echo "Checking .env file" + if [ ! -f .env ]; then + echo "Error: .env file not found at $DEPLOY_DIR/.env" + exit 1 + fi docker compose down || true docker image prune -f docker network inspect traefik-public >/dev/null 2>&1 || docker network create traefik-public + docker network inspect crew-app-net >/dev/null 2>&1 || docker network create crew-app-net export DOMAIN=slipmatz.com docker compose up -d sleep 10 rm -f /tmp/slipmatz-web.tar.gz /tmp/docker-compose.yml - echo 'Aggressive Docker cleanup to reclaim space' + echo "Aggressive Docker cleanup to reclaim space" docker image prune -af --filter "until=24h" || true docker container prune -f || true docker volume prune -f || true docker builder prune -af --filter "until=48h" || true - echo 'Docker space usage:' + echo "Docker space usage:" docker system df - echo 'Production deployment completed successfully!' - echo 'Application available at: https://slipmatz.com' - " + echo "Production deployment completed successfully!" + echo "Application available at: https://slipmatz.com" + ' env: DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }} DEPLOY_USER: ${{ secrets.DEPLOY_USER }}