From f8f9c205bed5372a2a57421c50efafc9fe8d8b96 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Wed, 1 Apr 2026 14:29:31 -0700 Subject: [PATCH] feat(ci): build custom Docker images for Gitea Actions compatibility - Create Dockerfile.ci-base with Bun, Node.js, and Playwright pre-installed - Add build-ci-images workflow that triggers on package.json changes - Update PR workflow to use custom ci-base image instead of GitHub Actions - Update Release workflow to use custom ci-base image - Remove dependency on oven/setup-bun@v2 GitHub Action - Remove dependency on docker/setup-buildx-action GitHub Action - Images are automatically built when dependencies in package.json update - Weekly scheduled rebuild ensures tools stay current This resolves the 'authentication required: Repository not found' error when Gitea Actions tries to clone GitHub Actions from external repositories. --- .gitea/workflows/build-ci-images.yml | 71 ++++++++++++++++++++++++++++ .gitea/workflows/pr.yml | 9 +--- .gitea/workflows/release.yml | 12 ++--- Dockerfile.ci-base | 32 +++++++++++++ 4 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 .gitea/workflows/build-ci-images.yml create mode 100644 Dockerfile.ci-base diff --git a/.gitea/workflows/build-ci-images.yml b/.gitea/workflows/build-ci-images.yml new file mode 100644 index 0000000..806f5a1 --- /dev/null +++ b/.gitea/workflows/build-ci-images.yml @@ -0,0 +1,71 @@ +name: Build CI Images + +on: + push: + branches: + - main + paths: + - 'Dockerfile.ci-base' + - 'package.json' + - 'bun.lockb' + - '.gitea/workflows/build-ci-images.yml' + schedule: + # Weekly rebuild to get latest Playwright/Bun versions + - cron: '0 2 * * 0' # Every Sunday at 2 AM + workflow_dispatch: # Manual trigger + +env: + REGISTRY: docker.notsosm.art + IMAGE_NAME: euchre-camp + +jobs: + build-ci-base: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Registry + run: | + echo "${{ secrets.DOCKER_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u ${{ secrets.DOCKER_LOGIN }} --password-stdin + + - name: Extract metadata for CI base image + id: meta + run: | + # Get Playwright version from package.json + PLAYWRIGHT_VERSION=$(grep -o '"@playwright/test": "[^"]*"' package.json | cut -d'"' -f4) + echo "playwright_version=${PLAYWRIGHT_VERSION}" >> $GITHUB_OUTPUT + + # Get Bun version (latest) + BUN_VERSION=$(bun --version 2>/dev/null || echo "latest") + echo "bun_version=${BUN_VERSION}" >> $GITHUB_OUTPUT + + # Set tags + echo "tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:playwright-${PLAYWRIGHT_VERSION},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:${{ github.sha }}" >> $GITHUB_OUTPUT + + - name: Build and push CI base image + run: | + # Build with multiple tags + docker build \ + --file Dockerfile.ci-base \ + --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:latest \ + --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:playwright-${{ steps.meta.outputs.playwright_version }} \ + --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:${{ github.sha }} \ + . + + # Push all tags + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:latest + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:playwright-${{ steps.meta.outputs.playwright_version }} + docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:${{ github.sha }} + + - name: Clean up + if: always() + run: | + docker logout ${{ env.REGISTRY }} \ No newline at end of file diff --git a/.gitea/workflows/pr.yml b/.gitea/workflows/pr.yml index 3128818..2b829d0 100644 --- a/.gitea/workflows/pr.yml +++ b/.gitea/workflows/pr.yml @@ -9,7 +9,7 @@ jobs: unit-tests: runs-on: ubuntu-latest container: - image: oven/bun:alpine + image: docker.notsosm.art/euchre-camp/ci-base:latest options: --user root steps: @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest needs: unit-tests container: - image: mcr.microsoft.com/playwright:v1.58.0-jammy + image: docker.notsosm.art/euchre-camp/ci-base:latest options: --user root env: DATABASE_PROVIDER: sqlite @@ -42,11 +42,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Bun - uses: oven/setup-bun@v2 - with: - bun-version: latest - - name: Install dependencies run: bun install diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index cf9d236..f71ccc1 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -14,6 +14,9 @@ jobs: runs-on: ubuntu-latest # Skip if this is an auto-generated version bump commit if: "!contains(github.event.head_commit.message, 'chore: bump version')" + container: + image: docker.notsosm.art/euchre-camp/ci-base:latest + options: --user root steps: - name: Checkout code @@ -63,11 +66,6 @@ jobs: fi fi - - name: Setup Bun - uses: oven/setup-bun@v2 - with: - bun-version: latest - - name: Bump version id: version run: | @@ -109,10 +107,6 @@ jobs: git push origin "$TAG_NAME" fi - - name: Set up Docker Buildx - if: steps.commit.outputs.committed == 'true' - uses: docker/setup-buildx-action@v3 - - name: Build test-capable image if: steps.commit.outputs.committed == 'true' run: | diff --git a/Dockerfile.ci-base b/Dockerfile.ci-base new file mode 100644 index 0000000..4b518f1 --- /dev/null +++ b/Dockerfile.ci-base @@ -0,0 +1,32 @@ +# Base CI image with Bun, Node.js, Playwright, and build tools +# Used for Gitea Actions CI workflows +# Uses Microsoft Playwright image as base (Ubuntu-based) with Bun added + +FROM mcr.microsoft.com/playwright:v1.58.0-jammy AS base + +# Install unzip (required for Bun installation) and other tools +RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/* + +# Install Bun (latest version) +# Note: The playwright image already has Node.js pre-installed +RUN curl -fsSL https://bun.sh/install | bash + +# Add Bun to PATH for subsequent commands +ENV PATH="/root/.bun/bin:$PATH" + +# Verify installations +RUN echo "=== Bun Version ===" && bun --version && \ + echo "=== Node.js Version ===" && node --version && \ + echo "=== Playwright Version ===" && bun x playwright --version + +WORKDIR /app + +# Set default environment variables +ENV DATABASE_PROVIDER=sqlite +ENV DATABASE_URL=file:./prisma/ci.db +ENV BETTER_AUTH_SECRET=test-secret-key-for-ci-only +ENV NODE_ENV=test + +# Health check command (can be overridden) +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD bun --version \ No newline at end of file