Move docker build/push from deploy-ift to CI (EventHubBack pattern). Deploy no longer needs docker.sock on the WSL runner. Add ensure-docker-daemon.sh for Docker Desktop on host runner.
This commit is contained in:
+47
-1
@@ -6,14 +6,20 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# Один runner (DESKTOP-SIR8B3R): параллельные workflow ломают кэш act/actions.
|
||||||
concurrency:
|
concurrency:
|
||||||
group: eventhub-frontadmin-ci-${{ github.ref }}
|
group: eventhub-frontadmin-ci-${{ github.ref }}
|
||||||
cancel-in-progress: false
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
BUILDKIT_PROGRESS: quiet
|
||||||
|
DOCKER_BUILDKIT: 1
|
||||||
|
REGISTRY: git.sabilin.com/eventhub
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
timeout-minutes: 45
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -25,3 +31,43 @@ jobs:
|
|||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
|
||||||
|
- name: Wait for Docker daemon
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
run: bash scripts/ensure-docker-daemon.sh 240
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build admin-ui image
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
bash scripts/retry-docker-build.sh 5 60 -- \
|
||||||
|
docker buildx build \
|
||||||
|
--network=host \
|
||||||
|
--file Dockerfile \
|
||||||
|
--tag eventhub-admin-ui:local \
|
||||||
|
--load \
|
||||||
|
--provenance=false \
|
||||||
|
--sbom=false \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Login to registry
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: git.sabilin.com
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Push admin-ui image
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
TAG="sha-${GITHUB_SHA:0:12}"
|
||||||
|
docker tag eventhub-admin-ui:local "${REGISTRY}/eventhub-admin-ui:${TAG}"
|
||||||
|
docker tag eventhub-admin-ui:local "${REGISTRY}/eventhub-admin-ui:ift"
|
||||||
|
bash scripts/retry-docker-build.sh 5 30 -- docker push "${REGISTRY}/eventhub-admin-ui:${TAG}"
|
||||||
|
bash scripts/retry-docker-build.sh 5 30 -- docker push "${REGISTRY}/eventhub-admin-ui:ift"
|
||||||
|
|||||||
@@ -11,23 +11,14 @@ concurrency:
|
|||||||
group: eventhub-frontadmin-deploy-ift
|
group: eventhub-frontadmin-deploy-ift
|
||||||
cancel-in-progress: false
|
cancel-in-progress: false
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: git.sabilin.com/eventhub
|
|
||||||
BUILDKIT_PROGRESS: quiet
|
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy-ift-admin:
|
deploy-ift-admin:
|
||||||
if: |
|
if: |
|
||||||
github.event_name == 'workflow_dispatch' ||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
|
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 90
|
timeout-minutes: 30
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
|
|
||||||
|
|
||||||
- name: Compute image tag
|
- name: Compute image tag
|
||||||
id: meta
|
id: meta
|
||||||
run: |
|
run: |
|
||||||
@@ -39,60 +30,6 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo "tag=sha-${SHA:0:12}" >> "$GITHUB_OUTPUT"
|
echo "tag=sha-${SHA:0:12}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm run build
|
|
||||||
|
|
||||||
- name: Wait for Docker daemon
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
for i in $(seq 1 36); do
|
|
||||||
if docker info >/dev/null 2>&1; then
|
|
||||||
echo "Docker ready"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "waiting for docker (${i}/36)..."
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
echo "Docker daemon not available"
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to registry
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: git.sabilin.com
|
|
||||||
username: ${{ secrets.REGISTRY_USER }}
|
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build admin-ui image
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
bash scripts/retry-docker-build.sh 5 60 -- \
|
|
||||||
docker buildx build \
|
|
||||||
--network=host \
|
|
||||||
--file Dockerfile \
|
|
||||||
--tag eventhub-admin-ui:local \
|
|
||||||
--load \
|
|
||||||
--provenance=false \
|
|
||||||
--sbom=false \
|
|
||||||
.
|
|
||||||
|
|
||||||
- name: Push admin-ui image
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
TAG="${{ steps.meta.outputs.tag }}"
|
|
||||||
docker tag eventhub-admin-ui:local "${REGISTRY}/eventhub-admin-ui:${TAG}"
|
|
||||||
docker tag eventhub-admin-ui:local "${REGISTRY}/eventhub-admin-ui:ift"
|
|
||||||
bash scripts/retry-docker-build.sh 5 30 -- docker push "${REGISTRY}/eventhub-admin-ui:${TAG}"
|
|
||||||
bash scripts/retry-docker-build.sh 5 30 -- docker push "${REGISTRY}/eventhub-admin-ui:ift"
|
|
||||||
|
|
||||||
- name: Deploy admin on IFT via SSH
|
- name: Deploy admin on IFT via SSH
|
||||||
uses: appleboy/ssh-action@v0.1.5
|
uses: appleboy/ssh-action@v0.1.5
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Ensure Docker daemon is reachable on WSL host runner (Docker Desktop integration).
|
||||||
|
# Usage: ensure-docker-daemon.sh [max_wait_seconds]
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
MAX_WAIT="${1:-240}"
|
||||||
|
INTERVAL=5
|
||||||
|
DEADLINE=$((SECONDS + MAX_WAIT))
|
||||||
|
|
||||||
|
docker_ok() {
|
||||||
|
timeout 8 docker info >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
find_docker_host() {
|
||||||
|
local candidates=(
|
||||||
|
"${DOCKER_HOST:-}"
|
||||||
|
"unix:///var/run/docker.sock"
|
||||||
|
"unix:///mnt/wsl/docker-desktop/shared-sockets/guest-services/docker.sock"
|
||||||
|
"unix:///mnt/wsl/docker-desktop/shared-sockets/guest-services/docker.proxy.sock"
|
||||||
|
"unix:///mnt/wsl/docker-desktop/shared-sockets/guest-services/docker.container-proxy.sock"
|
||||||
|
)
|
||||||
|
local host path
|
||||||
|
for host in "${candidates[@]}"; do
|
||||||
|
[[ -n "${host}" ]] || continue
|
||||||
|
path="${host#unix://}"
|
||||||
|
if [[ -S "${path}" ]] && DOCKER_HOST="${host}" docker_ok; then
|
||||||
|
export DOCKER_HOST="${host}"
|
||||||
|
echo "Docker ready (${host})"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if docker_ok; then
|
||||||
|
echo "Docker ready (default socket)"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
start_docker_desktop() {
|
||||||
|
local exe="/mnt/c/Program Files/Docker/Docker/Docker Desktop.exe"
|
||||||
|
if [[ -f "${exe}" ]]; then
|
||||||
|
echo "Starting Docker Desktop..."
|
||||||
|
powershell.exe -NoProfile -Command "Start-Process 'C:\\Program Files\\Docker\\Docker\\Docker Desktop.exe'" >/dev/null 2>&1 || true
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
echo "Docker Desktop executable not found"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
attempt=0
|
||||||
|
while (( SECONDS < DEADLINE )); do
|
||||||
|
attempt=$((attempt + 1))
|
||||||
|
if find_docker_host; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if (( attempt == 1 || attempt == 7 )); then
|
||||||
|
start_docker_desktop || true
|
||||||
|
fi
|
||||||
|
echo "waiting for docker (${attempt}, $((DEADLINE - SECONDS))s left)..."
|
||||||
|
sleep "${INTERVAL}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Docker daemon not available after ${MAX_WAIT}s"
|
||||||
|
echo "Hint: start Docker Desktop on Windows and enable WSL integration."
|
||||||
|
exit 1
|
||||||
Reference in New Issue
Block a user