Build and deploy immutable registry images
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
.git
|
||||||
|
.gitea
|
||||||
|
.angular
|
||||||
|
node_modules
|
||||||
|
frontend/dist
|
||||||
|
data
|
||||||
|
*.log
|
||||||
@@ -15,7 +15,10 @@ jobs:
|
|||||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
GITEA_REF: ${{ gitea.ref }}
|
GITEA_REF: ${{ gitea.ref }}
|
||||||
|
GITEA_SHA: ${{ gitea.sha }}
|
||||||
run: |
|
run: |
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -29,17 +32,34 @@ jobs:
|
|||||||
*) exit 0 ;;
|
*) exit 0 ;;
|
||||||
esac
|
esac
|
||||||
REPO_URL=ssh://git@git.dumas.ddns.net:222/chris.dumas/ComfyUiPortalNext.git
|
REPO_URL=ssh://git@git.dumas.ddns.net:222/chris.dumas/ComfyUiPortalNext.git
|
||||||
|
IMAGE_REF=git.dumas.ddns.net/chris.dumas/comfyui-portal-next:sha-${GITEA_SHA}
|
||||||
|
|
||||||
|
if [ -z "$REGISTRY_USERNAME" ] || [ -z "$REGISTRY_PASSWORD" ]; then
|
||||||
|
echo 'REGISTRY_USERNAME and REGISTRY_PASSWORD are required Gitea secrets'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%s' "$REGISTRY_PASSWORD" | ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" "docker login git.dumas.ddns.net --username '$REGISTRY_USERNAME' --password-stdin"
|
||||||
|
|
||||||
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" "
|
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" "
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
trap 'docker logout git.dumas.ddns.net >/dev/null 2>&1 || true' EXIT
|
||||||
mkdir -p '$TARGET_DIR'
|
mkdir -p '$TARGET_DIR'
|
||||||
if [ ! -d '$TARGET_DIR/.git' ]; then git init '$TARGET_DIR' && cd '$TARGET_DIR' && git remote add origin '$REPO_URL'; else cd '$TARGET_DIR' && git remote set-url origin '$REPO_URL'; fi
|
if [ ! -d '$TARGET_DIR/.git' ]; then git init '$TARGET_DIR' && cd '$TARGET_DIR' && git remote add origin '$REPO_URL'; else cd '$TARGET_DIR' && git remote set-url origin '$REPO_URL'; fi
|
||||||
cd '$TARGET_DIR'
|
cd '$TARGET_DIR'
|
||||||
GIT_SSH_COMMAND='ssh -p 222 -o StrictHostKeyChecking=no' git fetch origin '$BRANCH'
|
GIT_SSH_COMMAND='ssh -p 222 -o StrictHostKeyChecking=no' git fetch origin '$BRANCH'
|
||||||
git reset --hard 'origin/$BRANCH'
|
git reset --hard 'origin/$BRANCH'
|
||||||
git clean -fdx -e data/ -e data/**
|
git clean -fdx -e data/ -e data/**
|
||||||
|
if ! docker manifest inspect '$IMAGE_REF' >/dev/null 2>&1; then
|
||||||
|
docker build --tag '$IMAGE_REF' .
|
||||||
|
docker push '$IMAGE_REF'
|
||||||
|
else
|
||||||
|
echo 'Reusing existing immutable image $IMAGE_REF'
|
||||||
|
fi
|
||||||
docker ps -q --filter publish=$PORT | xargs -r docker rm -f
|
docker ps -q --filter publish=$PORT | xargs -r docker rm -f
|
||||||
docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' down --remove-orphans || true
|
docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' down --remove-orphans || true
|
||||||
docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' up -d --build
|
IMAGE_REF='$IMAGE_REF' docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' pull
|
||||||
|
IMAGE_REF='$IMAGE_REF' docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' up -d
|
||||||
"
|
"
|
||||||
for attempt in 1 2 3 4 5 6; do curl --fail --silent --show-error --max-time 15 "$HEALTH_URL/api/health" && exit 0 || sleep 5; done
|
for attempt in 1 2 3 4 5 6; do curl --fail --silent --show-error --max-time 15 "$HEALTH_URL/api/health" && exit 0 || sleep 5; done
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -14,3 +14,5 @@ The first run seeds `data/users.json` from `ADMIN_USERNAME` and `ADMIN_PASSWORD`
|
|||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
Gitea Actions deploys `develop`, `qa`, and `main` to the existing ComfyUiPortal target directories and preserves the existing 7002/6002/5002 port contract. On first startup of a fresh data directory, provide `ADMIN_USERNAME` and `ADMIN_PASSWORD` in the deployment host environment. Existing target data is retained during repository cutover.
|
Gitea Actions deploys `develop`, `qa`, and `main` to the existing ComfyUiPortal target directories and preserves the existing 7002/6002/5002 port contract. On first startup of a fresh data directory, provide `ADMIN_USERNAME` and `ADMIN_PASSWORD` in the deployment host environment. Existing target data is retained during repository cutover.
|
||||||
|
|
||||||
|
The deployment workflow builds an immutable image tagged with the source commit SHA and publishes it to the Gitea container registry. If that SHA-tagged image already exists, the workflow reuses it instead of rebuilding. Configure `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` as Gitea Actions secrets. Compose receives the exact image reference through `IMAGE_REF`, so the same artifact can be redeployed or promoted without rebuilding.
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
container_name: comfy-uiportal-dev
|
container_name: comfy-uiportal-next-dev
|
||||||
environment:
|
environment:
|
||||||
PORT: 7002
|
PORT: 7002
|
||||||
BRANCH_NAME: develop
|
BRANCH_NAME: develop
|
||||||
APP_DATA_DIR: /mnt/appdata/dev/ComfyUiPortal/data
|
APP_DATA_DIR: /mnt/appdata/dev/ComfyUiPortal/data
|
||||||
|
ADMIN_USERNAME: ${ADMIN_USERNAME:-}
|
||||||
|
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-}
|
||||||
ports:
|
ports:
|
||||||
- "7002:7002"
|
- "7002:7002"
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build: .
|
image: ${IMAGE_REF:-git.dumas.ddns.net/chris.dumas/comfyui-portal-next:latest}
|
||||||
image: comfy-uiportal:${BRANCH_NAME:-main}
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ${APP_DATA_DIR:-./data}:/app/data
|
- ${APP_DATA_DIR:-./data}:/app/data
|
||||||
|
|||||||
Reference in New Issue
Block a user