feat: Add Docker containerization with Gitea Actions #2

Open
pat wants to merge 6 commits from ci/#1-dockerize-actions into main
6 changed files with 515 additions and 0 deletions
Showing only changes of commit 9363f50fdd - Show all commits

View File

@@ -13,56 +13,26 @@ jobs:
build: build:
runs-on: linux runs-on: linux
steps: steps:
- name: Checkout code - name: Build Docker image
uses: actions/checkout@v4 run: |
echo "Building Docker image..."
- name: Set up Docker Buildx docker build -t karaokepedia:latest .
uses: docker/setup-buildx-action@v3 docker tag karaokepedia:latest karaokepedia:${{ github.sha }}
echo "✅ Image built successfully"
- name: Log in to Docker Hub - name: Log in to Docker Hub
uses: docker/login-action@v3 run: |
with: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} - name: Push Docker image
run: |
# Uncomment if using GitHub Container Registry # Push with registry prefix if secrets are configured
# - name: Log in to GitHub Container Registry if [ -n "${{ secrets.DOCKER_USERNAME }}" ]; then
# uses: docker/login-action@v3 docker tag karaokepedia:latest ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest
# with: docker tag karaokepedia:latest ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:main-${{ github.sha }}
# registry: ghcr.io docker push ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest
# username: ${{ github.actor }} docker push ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:main-${{ github.sha }}
# password: ${{ secrets.GITHUB_TOKEN }} echo "✅ Pushed to Docker Hub: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}"
else
# Uncomment if using Gitea Container Registry echo "⚠️ Docker Hub credentials not configured, skipping push"
# - name: Log in to Gitea Container Registry fi
# uses: docker/login-action@v3
# with:
# registry: gitea.yourdomain.com
# username: ${{ secrets.GITEA_USERNAME }}
# password: ${{ secrets.GITEA_PASSWORD }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
# Use this for GHCR:
# images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
# Use this for Gitea:
# images: gitea.yourdomain.com/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=sha,prefix={{branch}}-
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
run: echo ${{ steps.meta.outputs.digest }}

View File

@@ -49,9 +49,6 @@ jobs:
validate-docker: validate-docker:
runs-on: linux runs-on: linux
steps: steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate Dockerfile syntax - name: Validate Dockerfile syntax
run: | run: |
if [ -f "Dockerfile" ]; then if [ -f "Dockerfile" ]; then
@@ -86,22 +83,7 @@ jobs:
build-test: build-test:
runs-on: linux runs-on: linux
steps: steps:
- name: Checkout code - name: Build and test Docker image
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image (no push)
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: karaokepedia:pr-${{ github.event.pull_request.number }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test container starts
run: | run: |
docker build -t karaokepedia:test . docker build -t karaokepedia:test .
CONTAINER_ID=$(docker run -d -p 8080:80 karaokepedia:test) CONTAINER_ID=$(docker run -d -p 8080:80 karaokepedia:test)
@@ -145,9 +127,6 @@ jobs:
check-files: check-files:
runs-on: linux runs-on: linux
steps: steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check required files exist - name: Check required files exist
run: | run: |
REQUIRED_FILES=( REQUIRED_FILES=(