with service ?
Some checks failed
Build and Push Ansible Container / build-and-push (arm64) (push) Failing after 30s
Build and Push Ansible Container / build-and-push (amd64) (push) Failing after 31s
Build and Push Ansible Container / manifest (push) Has been skipped
Build and Push Docker-in-Docker Container / build-and-push (amd64) (push) Failing after 45s
Build and Push Docker-in-Docker Container / build-and-push (arm64) (push) Failing after 47s
Build and Push Docker-in-Docker Container / create-manifest (push) Has been skipped
Some checks failed
Build and Push Ansible Container / build-and-push (arm64) (push) Failing after 30s
Build and Push Ansible Container / build-and-push (amd64) (push) Failing after 31s
Build and Push Ansible Container / manifest (push) Has been skipped
Build and Push Docker-in-Docker Container / build-and-push (amd64) (push) Failing after 45s
Build and Push Docker-in-Docker Container / build-and-push (arm64) (push) Failing after 47s
Build and Push Docker-in-Docker Container / create-manifest (push) Has been skipped
This commit is contained in:
parent
28e2f61a42
commit
e8920989dd
2 changed files with 104 additions and 34 deletions
|
|
@ -1,10 +1,14 @@
|
||||||
|
# Workflow name
|
||||||
|
name: Build and Push Ansible Container
|
||||||
|
|
||||||
|
# Run-name for each workflow run
|
||||||
run-name: Build and Push Ansible Container
|
run-name: Build and Push Ansible Container
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- 'containers/${{ github.workflow }}/**' # This path will look for 'containers/Build and Push Ansible Container/**'
|
- 'containers/ansible/**'
|
||||||
- '.forgejo/workflows/ansible.yml'
|
- '.forgejo/workflows/ansible.yml'
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
schedule:
|
schedule:
|
||||||
|
|
@ -16,20 +20,29 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
arch: [ amd64, arm64 ]
|
arch: [ amd64, arm64 ]
|
||||||
runs-on: ${{ matrix.arch }}
|
runs-on: ${{ matrix.arch }}
|
||||||
container:
|
services:
|
||||||
image: node:latest
|
dind:
|
||||||
volumes:
|
image: docker:dind
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
privileged: true
|
||||||
|
env:
|
||||||
|
DOCKER_HOST: tcp://dind:2375
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Install Docker CLI
|
|
||||||
run: |
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y docker.io
|
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Wait for Docker to start
|
||||||
|
run: |
|
||||||
|
i=0
|
||||||
|
while ! docker info >/dev/null 2>&1;
|
||||||
|
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
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
|
@ -40,30 +53,40 @@ jobs:
|
||||||
username: ${{ secrets.CI_REGISTRY_USER }}
|
username: ${{ secrets.CI_REGISTRY_USER }}
|
||||||
password: ${{ secrets.CI_TOKEN }}
|
password: ${{ secrets.CI_TOKEN }}
|
||||||
|
|
||||||
# Removed the `cd` step as `context` and `file` can handle the path directly.
|
|
||||||
|
|
||||||
- name: Build and push (${{ matrix.arch }})
|
- name: Build and push (${{ matrix.arch }})
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: ./containers/${{ github.workflow }}/ # Relative to the checkout root
|
context: ./containers/ansible/
|
||||||
file: ./containers/${{ github.workflow }}/Dockerfile # Relative to the checkout root
|
file: ./containers/ansible/Dockerfile
|
||||||
platforms: linux/${{ matrix.arch }}
|
platforms: linux/${{ matrix.arch }}
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:${{ matrix.arch }}-latest
|
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:${{ matrix.arch }}-latest
|
||||||
cache-from: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:buildcache-${{ matrix.arch }} # Add caching
|
cache-from: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:buildcache-${{ matrix.arch }}
|
||||||
cache-to: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:buildcache-${{ matrix.arch }},mode=max # Add caching
|
cache-to: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:buildcache-${{ matrix.arch }},mode=max
|
||||||
|
|
||||||
manifest:
|
manifest:
|
||||||
needs: build-and-push
|
needs: build-and-push
|
||||||
runs-on: ubuntu-latest # or amd64 if you have a specific AMD64 runner for manifest creation
|
runs-on: amd64
|
||||||
|
services:
|
||||||
|
dind:
|
||||||
|
image: docker:dind
|
||||||
|
privileged: true
|
||||||
|
env:
|
||||||
|
DOCKER_HOST: tcp://dind:2375
|
||||||
steps:
|
steps:
|
||||||
- name: Install Docker CLI
|
- name: Wait for Docker to start
|
||||||
run: |
|
run: |
|
||||||
# Ensure docker CLI is available in the runner environment for `docker manifest`
|
i=0
|
||||||
# Most `ubuntu-latest` runners already have it, but explicit is better.
|
while ! docker info >/dev/null 2>&1;
|
||||||
sudo apt-get update
|
i=$((i+1))
|
||||||
sudo apt-get install -y docker-ce-cli # Install only the client if the runner is not dind
|
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
|
||||||
|
|
||||||
- name: Login to Forgejo Registry
|
- name: Login to Forgejo Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
|
@ -74,8 +97,7 @@ jobs:
|
||||||
|
|
||||||
- name: Create and push multi-arch manifest
|
- name: Create and push multi-arch manifest
|
||||||
run: |
|
run: |
|
||||||
# Use the explicit "docker" command which should be available
|
docker manifest create ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:latest \
|
||||||
docker manifest create ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:latest \
|
--amend ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:amd64-latest \
|
||||||
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:amd64-latest \
|
--amend ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:arm64-latest
|
||||||
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:arm64-latest
|
docker manifest push ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:latest
|
||||||
docker manifest push ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:latest
|
|
||||||
|
|
|
||||||
|
|
@ -28,16 +28,40 @@ jobs:
|
||||||
# Use a runner that matches the architecture.
|
# Use a runner that matches the architecture.
|
||||||
# This assumes you have runners tagged with 'amd64' and 'arm64'.
|
# 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
|
# 1. Check out the repository code
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# 2. Set up Docker Buildx for multi-platform builds
|
# 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
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
# 3. Login to the 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.
|
# Requires CI_REGISTRY, CI_REGISTRY_USER, and CI_TOKEN secrets to be set in Forgejo.
|
||||||
- name: Login to Forgejo Registry
|
- name: Login to Forgejo Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
|
@ -46,7 +70,7 @@ jobs:
|
||||||
username: ${{ secrets.CI_REGISTRY_USER }}
|
username: ${{ secrets.CI_REGISTRY_USER }}
|
||||||
password: ${{ secrets.CI_TOKEN }}
|
password: ${{ secrets.CI_TOKEN }}
|
||||||
|
|
||||||
# 4. Build and push the Docker image for the specific architecture
|
# 5. Build and push the Docker image for the specific architecture
|
||||||
- name: Build and push (${{ matrix.arch }})
|
- name: Build and push (${{ matrix.arch }})
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
|
|
@ -65,8 +89,32 @@ jobs:
|
||||||
needs: build-and-push
|
needs: build-and-push
|
||||||
# A standard runner is sufficient for creating a manifest
|
# 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:
|
||||||
|
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. Login to the Forgejo container registry again
|
# 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
|
- name: Login to Forgejo Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
|
@ -74,7 +122,7 @@ jobs:
|
||||||
username: ${{ secrets.CI_REGISTRY_USER }}
|
username: ${{ secrets.CI_REGISTRY_USER }}
|
||||||
password: ${{ secrets.CI_TOKEN }}
|
password: ${{ secrets.CI_TOKEN }}
|
||||||
|
|
||||||
# 2. Create and push the multi-arch manifest
|
# 3. Create and push the multi-arch manifest
|
||||||
# This combines the amd64 and arm64 images under a single 'latest' tag.
|
# This combines the amd64 and arm64 images under a single 'latest' tag.
|
||||||
- name: Create and push multi-arch manifest
|
- name: Create and push multi-arch manifest
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue