Use Docker-in-Docker container for builds
Some checks failed
Build and Push Docker Image / build (push) Failing after 9s
Some checks failed
Build and Push Docker Image / build (push) Failing after 9s
Root cause: act_runner provides minimal environment without sudo or Docker CLI. Cannot install packages in workflow. Solution: Use docker:24-dind container which includes Docker CLI and daemon. Runs with --privileged to allow nested containers. Changes: - Use docker:24-dind as job container - Remove installation steps (Docker pre-installed) - Keep simple login, build, push workflow Also added alternative solution file showing how to configure runner with Docker CLI for better performance. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9869355146
commit
683843458e
80
.gitea/workflows/build-deploy-alternative.yml.disabled
Normal file
80
.gitea/workflows/build-deploy-alternative.yml.disabled
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
# ALTERNATIVE SOLUTION: Configure runner with Docker CLI pre-installed
|
||||||
|
#
|
||||||
|
# This file shows how to set up the Gitea runner to have Docker CLI available
|
||||||
|
# by default, eliminating the need for Docker-in-Docker.
|
||||||
|
#
|
||||||
|
# SETUP INSTRUCTIONS:
|
||||||
|
#
|
||||||
|
# 1. SSH into your server where the Gitea runner is running
|
||||||
|
#
|
||||||
|
# 2. Find the runner container or installation:
|
||||||
|
# docker ps | grep act_runner
|
||||||
|
#
|
||||||
|
# 3. Option A: If runner is in Docker, create custom runner image
|
||||||
|
# Create a Dockerfile:
|
||||||
|
#
|
||||||
|
# FROM gitea/act_runner:latest
|
||||||
|
# RUN apk add --no-cache docker-cli
|
||||||
|
#
|
||||||
|
# Build and use:
|
||||||
|
# docker build -t gitea-runner-with-docker .
|
||||||
|
# # Update docker-compose or run command to use this image
|
||||||
|
#
|
||||||
|
# 4. Option B: If runner is installed on host, install Docker CLI:
|
||||||
|
#
|
||||||
|
# # For Ubuntu/Debian host
|
||||||
|
# curl -fsSL https://get.docker.com -o get-docker.sh
|
||||||
|
# sh get-docker.sh
|
||||||
|
#
|
||||||
|
# # Restart the runner service
|
||||||
|
# systemctl restart act_runner
|
||||||
|
#
|
||||||
|
# 5. Once Docker CLI is available in runner, use this simpler workflow:
|
||||||
|
|
||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Verify Docker is available
|
||||||
|
run: docker version
|
||||||
|
|
||||||
|
- name: Log in to Gitea Container Registry
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.GITHUB_TOKEN }}" | docker login code.puffinoffset.com -u ${{ github.actor }} --password-stdin
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
docker build -t code.puffinoffset.com/matt/puffin-app:latest \
|
||||||
|
-t code.puffinoffset.com/matt/puffin-app:main-${{ github.sha }} \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Push Docker images
|
||||||
|
run: |
|
||||||
|
docker push code.puffinoffset.com/matt/puffin-app:latest
|
||||||
|
docker push code.puffinoffset.com/matt/puffin-app:main-${{ github.sha }}
|
||||||
|
|
||||||
|
- name: Show image info
|
||||||
|
run: |
|
||||||
|
docker images | grep puffin-app
|
||||||
|
|
||||||
|
# BENEFITS OF THIS APPROACH:
|
||||||
|
# - Faster workflow execution (no container setup overhead)
|
||||||
|
# - Simpler workflow file
|
||||||
|
# - Better caching between builds
|
||||||
|
# - More control over runner environment
|
||||||
|
#
|
||||||
|
# WHEN TO USE:
|
||||||
|
# - If you have access to modify the runner
|
||||||
|
# - If you run multiple workflows that need Docker
|
||||||
|
# - For production environments where performance matters
|
||||||
@ -8,25 +8,14 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: docker:24-dind
|
||||||
|
options: --privileged
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Docker CLI
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y ca-certificates curl
|
|
||||||
sudo install -m 0755 -d /etc/apt/keyrings
|
|
||||||
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
|
||||||
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
|
||||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y docker-ce-cli
|
|
||||||
|
|
||||||
- name: Verify Docker installation
|
|
||||||
run: docker version
|
|
||||||
|
|
||||||
- name: Log in to Gitea Container Registry
|
- name: Log in to Gitea Container Registry
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.GITHUB_TOKEN }}" | docker login code.puffinoffset.com -u ${{ github.actor }} --password-stdin
|
echo "${{ secrets.GITHUB_TOKEN }}" | docker login code.puffinoffset.com -u ${{ github.actor }} --password-stdin
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user