docker in docker tests
Some checks failed
Build and Push Docker-in-Docker Container / create-manifest (push) Has been cancelled
Build and Push Docker-in-Docker Container / build-and-push (amd64) (push) Has been cancelled
Build and Push Docker-in-Docker Container / build-and-push (arm64) (push) Has been cancelled
Docker-in-Docker CI/CD Pipeline / Build and Push Docker-in-Docker Images (push) Failing after 1m46s
Docker-in-Docker CI/CD Pipeline / Create and Publish Multi-Arch Manifest (push) Has been skipped
Some checks failed
Build and Push Docker-in-Docker Container / create-manifest (push) Has been cancelled
Build and Push Docker-in-Docker Container / build-and-push (amd64) (push) Has been cancelled
Build and Push Docker-in-Docker Container / build-and-push (arm64) (push) Has been cancelled
Docker-in-Docker CI/CD Pipeline / Build and Push Docker-in-Docker Images (push) Failing after 1m46s
Docker-in-Docker CI/CD Pipeline / Create and Publish Multi-Arch Manifest (push) Has been skipped
This commit is contained in:
parent
e8920989dd
commit
96aa7ac932
2 changed files with 145 additions and 66 deletions
132
.forgejo/workflows/dockerindocker-old.yml
Normal file
132
.forgejo/workflows/dockerindocker-old.yml
Normal file
|
|
@ -0,0 +1,132 @@
|
||||||
|
# Workflow name
|
||||||
|
name: Build and Push Docker-in-Docker Container
|
||||||
|
|
||||||
|
# Run-name for each workflow run
|
||||||
|
run-name: Build and Push Docker-in-Docker Container for ${{ github.ref_name }}
|
||||||
|
|
||||||
|
# Triggers for the workflow
|
||||||
|
on:
|
||||||
|
# On pushes to the main branch if relevant files change
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'containers/dockerindocker/**'
|
||||||
|
- '.forgejo/workflows/dockerindocker.yml'
|
||||||
|
# Allows manual triggering from the Forgejo UI
|
||||||
|
workflow_dispatch: {}
|
||||||
|
# Scheduled run every Friday at 8 PM UTC
|
||||||
|
schedule:
|
||||||
|
- cron: '0 20 * * 5'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
# Strategy to build for multiple architectures
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
arch: [ amd64, arm64 ]
|
||||||
|
# Use a runner that matches the architecture.
|
||||||
|
# This assumes you have runners tagged with 'amd64' and 'arm64'.
|
||||||
|
runs-on: ${{ matrix.arch }}
|
||||||
|
# Add a Docker-in-Docker service to the job.
|
||||||
|
# This is necessary to build Docker images.
|
||||||
|
# The 'privileged' flag is required for the Docker daemon to run.
|
||||||
|
services:
|
||||||
|
dind:
|
||||||
|
image: docker:dind
|
||||||
|
privileged: true
|
||||||
|
# Set the DOCKER_HOST environment variable to connect to the dind service.
|
||||||
|
env:
|
||||||
|
DOCKER_HOST: tcp://dind:2375
|
||||||
|
steps:
|
||||||
|
# 1. Check out the repository code
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# 2. Wait for the Docker daemon to be ready
|
||||||
|
- name: Wait for Docker to start
|
||||||
|
run: |
|
||||||
|
i=0
|
||||||
|
while ! docker info >/dev/null 2>&1; do
|
||||||
|
i=$((i+1))
|
||||||
|
if [ $i -ge 15 ]; then
|
||||||
|
echo "Docker did not start within 15 seconds"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Waiting for Docker to start..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# 3. Set up Docker Buildx for multi-platform builds
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
# 4. Login to the Forgejo container registry
|
||||||
|
# Requires CI_REGISTRY, CI_REGISTRY_USER, and CI_TOKEN secrets to be set in Forgejo.
|
||||||
|
- name: Login to Forgejo Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.CI_REGISTRY }}
|
||||||
|
username: ${{ secrets.CI_REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.CI_TOKEN }}
|
||||||
|
|
||||||
|
# 5. Build and push the Docker image for the specific architecture
|
||||||
|
- name: Build and push (${{ matrix.arch }})
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: ./containers/dockerindocker/
|
||||||
|
file: ./containers/dockerindocker/Dockerfile
|
||||||
|
platforms: linux/${{ matrix.arch }}
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:${{ matrix.arch }}-latest
|
||||||
|
# Enable caching to speed up subsequent builds
|
||||||
|
cache-from: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:buildcache-${{ matrix.arch }}
|
||||||
|
cache-to: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:buildcache-${{ matrix.arch }},mode=max
|
||||||
|
|
||||||
|
# This job runs after all 'build-and-push' jobs have succeeded
|
||||||
|
create-manifest:
|
||||||
|
needs: build-and-push
|
||||||
|
# A standard runner is sufficient for creating a manifest
|
||||||
|
runs-on: amd64
|
||||||
|
# Add a Docker-in-Docker service to the job.
|
||||||
|
# This is necessary to create the manifest.
|
||||||
|
# The 'privileged' flag is required for the Docker daemon to run.
|
||||||
|
services:
|
||||||
|
dind:
|
||||||
|
image: docker:dind
|
||||||
|
privileged: true
|
||||||
|
# Set the DOCKER_HOST environment variable to connect to the dind service.
|
||||||
|
env:
|
||||||
|
DOCKER_HOST: tcp://dind:2375
|
||||||
|
steps:
|
||||||
|
# 1. Wait for the Docker daemon to be ready
|
||||||
|
- name: Wait for Docker to start
|
||||||
|
run: |
|
||||||
|
i=0
|
||||||
|
while ! docker info >/dev/null 2>&1; do
|
||||||
|
i=$((i+1))
|
||||||
|
if [ $i -ge 15 ]; then
|
||||||
|
echo "Docker did not start within 15 seconds"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Waiting for Docker to start..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# 2. Login to the Forgejo container registry again
|
||||||
|
- name: Login to Forgejo Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.CI_REGISTRY }}
|
||||||
|
username: ${{ secrets.CI_REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.CI_TOKEN }}
|
||||||
|
|
||||||
|
# 3. Create and push the multi-arch manifest
|
||||||
|
# This combines the amd64 and arm64 images under a single 'latest' tag.
|
||||||
|
- name: Create and push multi-arch manifest
|
||||||
|
run: |
|
||||||
|
docker manifest create ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:latest \
|
||||||
|
--amend ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:amd64-latest \
|
||||||
|
--amend ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:arm64-latest
|
||||||
|
docker manifest push ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:latest
|
||||||
|
|
@ -1,78 +1,37 @@
|
||||||
# Workflow name
|
name: Docker-in-Docker CI/CD Pipeline
|
||||||
name: Build and Push Docker-in-Docker Container
|
|
||||||
|
|
||||||
# Run-name for each workflow run
|
run-name: Build, Push, and Publish Multi-Arch Docker-in-Docker for ${{ github.ref_name }}
|
||||||
run-name: Build and Push Docker-in-Docker Container for ${{ github.ref_name }}
|
|
||||||
|
|
||||||
# Triggers for the workflow
|
|
||||||
on:
|
on:
|
||||||
# On pushes to the main branch if relevant files change
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- 'containers/dockerindocker/**'
|
- 'containers/dockerindocker/**'
|
||||||
- '.forgejo/workflows/dockerindocker.yml'
|
- '.forgejo/workflows/dockerindocker.yml'
|
||||||
# Allows manual triggering from the Forgejo UI
|
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
# Scheduled run every Friday at 8 PM UTC
|
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 20 * * 5'
|
- cron: '0 20 * * 5'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
# Strategy to build for multiple architectures
|
name: Build and Push Docker-in-Docker Images
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
arch: [ amd64, arm64 ]
|
arch: [ amd64, arm64 ]
|
||||||
# Use a runner that matches the architecture.
|
|
||||||
# This assumes you have runners tagged with 'amd64' and 'arm64'.
|
|
||||||
runs-on: ${{ matrix.arch }}
|
runs-on: ${{ matrix.arch }}
|
||||||
# Add a Docker-in-Docker service to the job.
|
|
||||||
# This is necessary to build Docker images.
|
|
||||||
# The 'privileged' flag is required for the Docker daemon to run.
|
|
||||||
services:
|
|
||||||
dind:
|
|
||||||
image: docker:dind
|
|
||||||
privileged: true
|
|
||||||
# Set the DOCKER_HOST environment variable to connect to the dind service.
|
|
||||||
env:
|
|
||||||
DOCKER_HOST: tcp://dind:2375
|
|
||||||
steps:
|
steps:
|
||||||
# 1. Check out the repository code
|
- name: Checkout Source Code
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# 2. Wait for the Docker daemon to be ready
|
|
||||||
- name: Wait for Docker to start
|
|
||||||
run: |
|
|
||||||
i=0
|
|
||||||
while ! docker info >/dev/null 2>&1; do
|
|
||||||
i=$((i+1))
|
|
||||||
if [ $i -ge 15 ]; then
|
|
||||||
echo "Docker did not start within 15 seconds"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Waiting for Docker to start..."
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
# 3. Set up Docker Buildx for multi-platform builds
|
|
||||||
- name: Setup Docker Buildx
|
- name: Setup Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Login to Forgejo Container Registry
|
||||||
# 4. Login to the Forgejo container registry
|
|
||||||
# Requires CI_REGISTRY, CI_REGISTRY_USER, and CI_TOKEN secrets to be set in Forgejo.
|
|
||||||
- name: Login to Forgejo Registry
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.CI_REGISTRY }}
|
registry: ${{ secrets.CI_REGISTRY }}
|
||||||
username: ${{ secrets.CI_REGISTRY_USER }}
|
username: ${{ secrets.CI_REGISTRY_USER }}
|
||||||
password: ${{ secrets.CI_TOKEN }}
|
password: ${{ secrets.CI_TOKEN }}
|
||||||
|
- name: Build and Push Image for ${{ matrix.arch }}
|
||||||
# 5. Build and push the Docker image for the specific architecture
|
uses: docker/build-push-action@v6
|
||||||
- name: Build and push (${{ matrix.arch }})
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
with:
|
||||||
context: ./containers/dockerindocker/
|
context: ./containers/dockerindocker/
|
||||||
file: ./containers/dockerindocker/Dockerfile
|
file: ./containers/dockerindocker/Dockerfile
|
||||||
|
|
@ -80,28 +39,21 @@ jobs:
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:${{ matrix.arch }}-latest
|
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:${{ matrix.arch }}-latest
|
||||||
# Enable caching to speed up subsequent builds
|
|
||||||
cache-from: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:buildcache-${{ matrix.arch }}
|
cache-from: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:buildcache-${{ matrix.arch }}
|
||||||
cache-to: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:buildcache-${{ matrix.arch }},mode=max
|
cache-to: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:buildcache-${{ matrix.arch }},mode=max
|
||||||
|
|
||||||
# This job runs after all 'build-and-push' jobs have succeeded
|
|
||||||
create-manifest:
|
create-manifest:
|
||||||
|
name: Create and Publish Multi-Arch Manifest
|
||||||
needs: build-and-push
|
needs: build-and-push
|
||||||
# A standard runner is sufficient for creating a manifest
|
|
||||||
runs-on: amd64
|
runs-on: amd64
|
||||||
# Add a Docker-in-Docker service to the job.
|
|
||||||
# This is necessary to create the manifest.
|
|
||||||
# The 'privileged' flag is required for the Docker daemon to run.
|
|
||||||
services:
|
services:
|
||||||
dind:
|
dind:
|
||||||
image: docker:dind
|
image: docker:dind
|
||||||
privileged: true
|
privileged: true
|
||||||
# Set the DOCKER_HOST environment variable to connect to the dind service.
|
|
||||||
env:
|
env:
|
||||||
DOCKER_HOST: tcp://dind:2375
|
DOCKER_HOST: tcp://dind:2375
|
||||||
steps:
|
steps:
|
||||||
# 1. Wait for the Docker daemon to be ready
|
- name: Wait for Docker Daemon
|
||||||
- name: Wait for Docker to start
|
|
||||||
run: |
|
run: |
|
||||||
i=0
|
i=0
|
||||||
while ! docker info >/dev/null 2>&1; do
|
while ! docker info >/dev/null 2>&1; do
|
||||||
|
|
@ -113,18 +65,13 @@ jobs:
|
||||||
echo "Waiting for Docker to start..."
|
echo "Waiting for Docker to start..."
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
- name: Login to Forgejo Container Registry
|
||||||
# 2. Login to the Forgejo container registry again
|
|
||||||
- name: Login to Forgejo Registry
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.CI_REGISTRY }}
|
registry: ${{ secrets.CI_REGISTRY }}
|
||||||
username: ${{ secrets.CI_REGISTRY_USER }}
|
username: ${{ secrets.CI_REGISTRY_USER }}
|
||||||
password: ${{ secrets.CI_TOKEN }}
|
password: ${{ secrets.CI_TOKEN }}
|
||||||
|
- name: Create and Push Multi-Arch Manifest
|
||||||
# 3. Create and push the multi-arch manifest
|
|
||||||
# This combines the amd64 and arm64 images under a single 'latest' tag.
|
|
||||||
- name: Create and push multi-arch manifest
|
|
||||||
run: |
|
run: |
|
||||||
docker manifest create ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:latest \
|
docker manifest create ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:latest \
|
||||||
--amend ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:amd64-latest \
|
--amend ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/dockerindocker:amd64-latest \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue