added deploy compose to repo to avoid volume mounts from workers
Some checks failed
Build and Deploy Backend / Run Linters and Tests (push) Successful in 44s
Build and Deploy Backend / Build and Deploy (push) Failing after 2m10s

This commit is contained in:
c-d-p
2025-04-30 22:56:51 +02:00
parent d05248a89e
commit 65ac965977
2 changed files with 89 additions and 20 deletions

View File

@@ -123,36 +123,42 @@ jobs:
run: |
#!/bin/bash -ex
# Set deployment path
DEPLOY_PATH="/config/stacks/maia"
# Define path to compose file WITHIN the checked-out workspace
COMPOSE_FILE="${{ gitea.workspace }}/backend/docker-compose.deploy.yml"
echo "--- Start Deploy Locally ---"
echo "Workspace: $(pwd)"
echo "Checking existence of DEPLOY_PATH: ${DEPLOY_PATH}"
ls -la /config # Check if the parent dir exists
ls -la "${DEPLOY_PATH}" # Check if the target dir exists and list contents/permissions
echo "--- Start Deploy Locally (using compose file from repo) ---"
echo "Workspace root: ${{ gitea.workspace }}"
echo "Using compose file: ${COMPOSE_FILE}"
# Verify compose file exists
if [ ! -f "${COMPOSE_FILE}" ]; then
echo "ERROR: Compose file not found at ${COMPOSE_FILE}"
ls -la "${{ gitea.workspace }}/backend/" # List contents for debugging
exit 1
fi
# Pull the specific image version built in this workflow
echo "Pulling image ${{ gitea.sha }}..."
docker pull ghcr.io/${{ secrets.DOCKER_REGISTRY_USERNAME }}/maia:${{ gitea.sha }}
echo "Pull complete."
# Change to the directory containing the compose file
echo "Changing directory to ${DEPLOY_PATH}"
cd "${DEPLOY_PATH}" || { echo "cd to ${DEPLOY_PATH} FAILED!"; exit 1; }
echo "Current directory: $(pwd)"
echo "Listing files in current directory:"
ls -la
# Pull the latest images for other services to ensure they stay up to date
# Pull other images defined in compose using the specific file
# Ensures base images like redis/db are up-to-date if specified in compose
echo "Pulling other compose services..."
docker compose -f docker-compose.yml pull redis db
docker compose -f "${COMPOSE_FILE}" pull redis db
echo "Other service pull complete."
echo "Running sed on docker-compose.yml..."
sed -i 's|image: ghcr.io/${{ secrets.DOCKER_REGISTRY_USERNAME }}/maia:.*|image: ghcr.io/${{ secrets.DOCKER_REGISTRY_USERNAME }}/maia:${{ gitea.sha }}|g' docker-compose.yml
# Update the image tag IN THE CHECKED-OUT COMPOSE FILE
# This change only exists within the job's workspace, it doesn't modify the repo source
echo "Running sed on ${COMPOSE_FILE}..."
sed -i 's|image: ghcr.io/${{ secrets.DOCKER_REGISTRY_USERNAME }}/maia:.*|image: ghcr.io/${{ secrets.DOCKER_REGISTRY_USERNAME }}/maia:${{ gitea.sha }}|g' "${COMPOSE_FILE}"
echo "sed complete. Showing updated line:"
grep "image: ghcr.io/${{ secrets.DOCKER_REGISTRY_USERNAME }}/maia" "${COMPOSE_FILE}" || echo "Image line not found after sed!"
# Restart the services using the updated compose file from the workspace
# Docker compose interacts with the HOST daemon via the mounted socket
echo "Bringing compose stack down and up with new image..."
docker compose up -d --force-recreate --remove-orphans
docker compose -f "${COMPOSE_FILE}" up -d --force-recreate --remove-orphans
echo "Docker compose up command finished."
echo "--- Local deployment complete! ---"