Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 51 additions & 20 deletions .github/workflows/chromium-headful-image.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
name: chromium-headful-image

on:
push:
branches: [ main ]
pull_request:
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm64
runs-on: ${{ matrix.runner }}
permissions:
contents: read
env:
UKC_TOKEN: dummy
UKC_METRO: ci
NAME: ci-chromium-headful
DETACH: "true"
SERVICE_EXCEPTIONS: pulseaudio
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Compute short SHA
id: vars
- name: Build image
shell: bash
run: echo "short_sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
run: |
bash images/chromium-headful/build-docker.sh

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run container
shell: bash
run: |
bash images/chromium-headful/run-docker.sh

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Wait for supervisor services (allow pulseaudio non-RUNNING)
shell: bash
run: |
trap "docker stop ci-chromium-headful >/dev/null 2>&1 || true" EXIT
attempts=30
sleep_seconds=1
for i in $(seq 1 "$attempts"); do
out=$(docker exec ci-chromium-headful supervisorctl status || true)
echo "$out"
total=$(echo "$out" | grep -v '^$' | wc -l | tr -d ' ')
exceptions="${SERVICE_EXCEPTIONS:-}"
pattern=$(printf '%s' "$exceptions" | tr ', ' '\n' | sed '/^$/d' | paste -sd '|' -)
ok=$(echo "$out" | awk -v pat="$pattern" 'BEGIN{IGNORECASE=1} { if (pat != "" && $0 ~ pat) print; else if ($0 ~ /RUNNING/) print }' | wc -l | tr -d ' ')
if [ "$total" -gt 0 ] && [ "$ok" -eq "$total" ]; then
echo "All required services are RUNNING"
exit 0
fi
sleep "$sleep_seconds"
done
echo "Supervisor services not ready in time"
docker logs --tail=200 ci-chromium-headful || true
exit 1

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: images/chromium-headful/Dockerfile
push: true
tags: onkernel/chromium-headful:${{ steps.vars.outputs.short_sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
71 changes: 51 additions & 20 deletions .github/workflows/chromium-headless-image.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
name: chromium-headless-image

on:
push:
branches: [ main ]
pull_request:
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm64
runs-on: ${{ matrix.runner }}
permissions:
contents: read
env:
UKC_TOKEN: dummy
UKC_METRO: ci
NAME: ci-chromium-headless
DETACH: "true"
SERVICE_EXCEPTIONS: pulseaudio
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Compute short SHA
id: vars
- name: Build image
shell: bash
run: echo "short_sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
run: |
bash images/chromium-headless/build-docker.sh

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run container
shell: bash
run: |
bash images/chromium-headless/run-docker.sh

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Wait for supervisor services (allow pulseaudio non-RUNNING)
shell: bash
run: |
trap "docker stop ci-chromium-headless >/dev/null 2>&1 || true" EXIT
attempts=30
sleep_seconds=1
for i in $(seq 1 "$attempts"); do
out=$(docker exec ci-chromium-headless supervisorctl status || true)
echo "$out"
total=$(echo "$out" | grep -v '^$' | wc -l | tr -d ' ')
exceptions="${SERVICE_EXCEPTIONS:-}"
pattern=$(printf '%s' "$exceptions" | tr ', ' '\n' | sed '/^$/d' | paste -sd '|' -)
ok=$(echo "$out" | awk -v pat="$pattern" 'BEGIN{IGNORECASE=1} { if (pat != "" && $0 ~ pat) print; else if ($0 ~ /RUNNING/) print }' | wc -l | tr -d ' ')
if [ "$total" -gt 0 ] && [ "$ok" -eq "$total" ]; then
echo "All required services are RUNNING"
exit 0
fi
sleep "$sleep_seconds"
done
echo "Supervisor services not ready in time"
docker logs --tail=200 ci-chromium-headless || true
exit 1

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: images/chromium-headless/image/Dockerfile
push: true
tags: onkernel/chromium-headless:${{ steps.vars.outputs.short_sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
7 changes: 6 additions & 1 deletion images/chromium-headful/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,9 @@ if [[ "${ENABLE_WEBRTC:-}" == "true" ]]; then
fi

docker rm -f "$NAME" 2>/dev/null || true
docker run -it "${RUN_ARGS[@]}" "$IMAGE"

if [[ "${DETACH:-false}" == "true" ]]; then
docker run -d --rm "${RUN_ARGS[@]}" "$IMAGE"
else
docker run -it "${RUN_ARGS[@]}" "$IMAGE"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Bug

Inconsistent container cleanup behavior: interactive mode (line 88) is missing the --rm flag while detached mode (line 86) has it. This causes containers to persist after exit when run interactively but be auto-removed when run detached. The chromium-headless script consistently uses --rm in both modes (lines 31 and 33), which is the correct pattern. This inconsistency will lead to container accumulation when running in interactive mode.

Fix in Cursor Fix in Web

fi
7 changes: 6 additions & 1 deletion images/chromium-headless/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ if [[ $# -ge 1 && -n "$1" ]]; then
fi

docker rm -f "$NAME" 2>/dev/null || true
docker run -it --rm "${ENTRYPOINT_ARG[@]}" "${RUN_ARGS[@]}" "$IMAGE"

if [[ "${DETACH:-false}" == "true" ]]; then
docker run -d --rm "${ENTRYPOINT_ARG[@]}" "${RUN_ARGS[@]}" "$IMAGE"
else
docker run -it --rm "${ENTRYPOINT_ARG[@]}" "${RUN_ARGS[@]}" "$IMAGE"
fi
Loading