ci: add CI image builder workflow and Dockerfile
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
# CI Image Builder Workflow
|
||||
# Automatically builds and pushes CI images when dependencies change
|
||||
# Uses GitHub Container Registry (GHCR) or any container registry
|
||||
|
||||
name: CI Image Builder
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'package.json'
|
||||
- 'package-lock.json'
|
||||
- 'Dockerfile.ci'
|
||||
- '.gitea/workflows/ci-image-builder.yml'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
force_rebuild:
|
||||
description: 'Force rebuild even if no changes detected'
|
||||
required: false
|
||||
default: 'false'
|
||||
type: boolean
|
||||
|
||||
env:
|
||||
# Use GHCR or your own registry
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}/ci-runner
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
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: Log in to Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=sha,prefix={{branch}}-
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push CI image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.ci
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Update workflow documentation
|
||||
run: |
|
||||
echo "CI Image built and pushed successfully!"
|
||||
echo ""
|
||||
echo "Available tags:"
|
||||
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
|
||||
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
|
||||
echo ""
|
||||
echo "To use in workflows:"
|
||||
echo " container:"
|
||||
echo " image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
|
||||
@@ -0,0 +1,46 @@
|
||||
# CI Runner Image for EuchreCamp
|
||||
# Pre-installed with all dependencies to speed up CI runs
|
||||
# This image is rebuilt automatically when package.json changes
|
||||
|
||||
FROM node:20-alpine
|
||||
|
||||
# Install system dependencies needed for various tasks
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
git \
|
||||
curl \
|
||||
python3 \
|
||||
make \
|
||||
g++ \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files first (for better caching)
|
||||
COPY package*.json ./
|
||||
|
||||
# Install ALL dependencies including dev dependencies
|
||||
# This is done at image build time, not at CI runtime
|
||||
RUN npm ci
|
||||
|
||||
# Copy Prisma schema (needed for Prisma client generation)
|
||||
COPY prisma/schema.prisma ./prisma/
|
||||
|
||||
# Generate Prisma client
|
||||
RUN npx prisma generate
|
||||
|
||||
# Copy the rest of the application
|
||||
COPY . .
|
||||
|
||||
# Set environment variables for CI environment
|
||||
ENV NODE_ENV=production
|
||||
ENV DATABASE_PROVIDER=sqlite
|
||||
ENV DATABASE_URL=file:./prisma/ci.db
|
||||
ENV BETTER_AUTH_SECRET=test-secret-key-for-ci-only
|
||||
|
||||
# Verify installations
|
||||
RUN node --version && npm --version && git --version && npx prisma --version
|
||||
|
||||
# Default command
|
||||
CMD ["/bin/sh"]
|
||||
Reference in New Issue
Block a user