Skip to content

Commit

Permalink
Enhancement: Add ansible 10.2.0 variants
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh committed Jul 27, 2024
1 parent 56e0c73 commit 0891d8a
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 2 deletions.
191 changes: 190 additions & 1 deletion .github/workflows/ci-master-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,193 @@ jobs:
run: |
git diff --exit-code
build-10-2-0:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
lscpu
free
df -h
pwd
docker info
docker version
# See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-10.2.0-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-10.2.0-
${{ runner.os }}-buildx-
- name: Login to Docker Hub registry
# Run on master and tags
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}

# This step generates the docker tags
- name: Prepare
id: prep-10-2-0-alpine-edge
run: |
set -e
# Get ref, i.e. <branch_name> from refs/heads/<branch_name>, or <tag-name> from refs/tags/<tag_name>. E.g. 'master' or 'v0.0.0'
REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev )
# Get short commit hash E.g. 'abc0123'
SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 )
# Generate docker image tags
# E.g. 'v0.0.0-<variant>' and 'v0.0.0-abc0123-<variant>'
# E.g. 'master-<variant>' and 'master-abc0123-<variant>'
VARIANT="10.2.0-alpine-edge"
REF_VARIANT="${REF}-${VARIANT}"
REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}"
# Pass variables to next step
echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT
echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT
echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT
echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT
- name: 10.2.0-alpine-edge - Build (PRs)
# Run only on pull requests
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
context: variants/10.2.0-alpine-edge
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x
push: false
tags: |
${{ github.repository }}:${{ steps.prep-10-2-0-alpine-edge.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-10-2-0-alpine-edge.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: 10.2.0-alpine-edge - Build and push (master)
# Run only on master
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v5
with:
context: variants/10.2.0-alpine-edge
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x
push: true
tags: |
${{ github.repository }}:${{ steps.prep-10-2-0-alpine-edge.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-10-2-0-alpine-edge.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: 10.2.0-alpine-edge - Build and push (release)
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
context: variants/10.2.0-alpine-edge
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x
push: true
tags: |
${{ github.repository }}:${{ steps.prep-10-2-0-alpine-edge.outputs.VARIANT }}
${{ github.repository }}:${{ steps.prep-10-2-0-alpine-edge.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-10-2-0-alpine-edge.outputs.REF_SHA_VARIANT }}
${{ github.repository }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# This step generates the docker tags
- name: Prepare
id: prep-10-2-0-sops-ssh-alpine-edge
run: |
set -e
# Get ref, i.e. <branch_name> from refs/heads/<branch_name>, or <tag-name> from refs/tags/<tag_name>. E.g. 'master' or 'v0.0.0'
REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev )
# Get short commit hash E.g. 'abc0123'
SHA=$( echo "${GITHUB_SHA}" | cut -c1-7 )
# Generate docker image tags
# E.g. 'v0.0.0-<variant>' and 'v0.0.0-abc0123-<variant>'
# E.g. 'master-<variant>' and 'master-abc0123-<variant>'
VARIANT="10.2.0-sops-ssh-alpine-edge"
REF_VARIANT="${REF}-${VARIANT}"
REF_SHA_VARIANT="${REF}-${SHA}-${VARIANT}"
# Pass variables to next step
echo "VARIANT_BUILD_DIR=$VARIANT_BUILD_DIR" >> $GITHUB_OUTPUT
echo "VARIANT=$VARIANT" >> $GITHUB_OUTPUT
echo "REF_VARIANT=$REF_VARIANT" >> $GITHUB_OUTPUT
echo "REF_SHA_VARIANT=$REF_SHA_VARIANT" >> $GITHUB_OUTPUT
- name: 10.2.0-sops-ssh-alpine-edge - Build (PRs)
# Run only on pull requests
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
context: variants/10.2.0-sops-ssh-alpine-edge
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x
push: false
tags: |
${{ github.repository }}:${{ steps.prep-10-2-0-sops-ssh-alpine-edge.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-10-2-0-sops-ssh-alpine-edge.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: 10.2.0-sops-ssh-alpine-edge - Build and push (master)
# Run only on master
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v5
with:
context: variants/10.2.0-sops-ssh-alpine-edge
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x
push: true
tags: |
${{ github.repository }}:${{ steps.prep-10-2-0-sops-ssh-alpine-edge.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-10-2-0-sops-ssh-alpine-edge.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: 10.2.0-sops-ssh-alpine-edge - Build and push (release)
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
context: variants/10.2.0-sops-ssh-alpine-edge
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x
push: true
tags: |
${{ github.repository }}:${{ steps.prep-10-2-0-sops-ssh-alpine-edge.outputs.VARIANT }}
${{ github.repository }}:${{ steps.prep-10-2-0-sops-ssh-alpine-edge.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-10-2-0-sops-ssh-alpine-edge.outputs.REF_SHA_VARIANT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-9-5-1:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -141,7 +328,6 @@ jobs:
${{ github.repository }}:${{ steps.prep-9-5-1-alpine-3-20.outputs.VARIANT }}
${{ github.repository }}:${{ steps.prep-9-5-1-alpine-3-20.outputs.REF_VARIANT }}
${{ github.repository }}:${{ steps.prep-9-5-1-alpine-3-20.outputs.REF_SHA_VARIANT }}
${{ github.repository }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

Expand Down Expand Up @@ -2454,6 +2640,7 @@ jobs:
update-draft-release:
needs:
- build-10-2-0
- build-9-5-1
- build-8-6-1
- build-7-5-0
Expand All @@ -2480,6 +2667,7 @@ jobs:

publish-draft-release:
needs:
- build-10-2-0
- build-9-5-1
- build-8-6-1
- build-7-5-0
Expand Down Expand Up @@ -2508,6 +2696,7 @@ jobs:

update-dockerhub-description:
needs:
- build-10-2-0
- build-9-5-1
- build-8-6-1
- build-7-5-0
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Dockerized `ansible` with useful tools.

| Tag | Dockerfile Build Context |
|:-------:|:---------:|
| `:9.5.1-alpine-3.20`, `:latest` | [View](variants/9.5.1-alpine-3.20) |
| `:10.2.0-alpine-edge`, `:latest` | [View](variants/10.2.0-alpine-edge) |
| `:10.2.0-sops-ssh-alpine-edge` | [View](variants/10.2.0-sops-ssh-alpine-edge) |
| `:9.5.1-alpine-3.20` | [View](variants/9.5.1-alpine-3.20) |
| `:9.5.1-sops-ssh-alpine-3.20` | [View](variants/9.5.1-sops-ssh-alpine-3.20) |
| `:8.6.1-alpine-3.19` | [View](variants/8.6.1-alpine-3.19) |
| `:8.6.1-sops-ssh-alpine-3.19` | [View](variants/8.6.1-sops-ssh-alpine-3.19) |
Expand Down
10 changes: 10 additions & 0 deletions generate/definitions/VARIANTS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
# See: https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#where-did-all-the-modules-go
# See: https://wiki.archlinux.org/index.php?title=Ansible&action=history
$local:VARIANTS_MATRIX = @(
@{
package = 'ansible'
package_version = '10.2.0'
distro = 'alpine'
distro_version = 'edge'
subvariants = @(
@{ components = @() }
@{ components = @( 'sops', 'ssh' ) }
)
}
@{
package = 'ansible'
package_version = '9.5.1'
Expand Down
16 changes: 16 additions & 0 deletions variants/10.2.0-alpine-edge/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM alpine:edge
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"

# Install ansible
RUN set -eux; \
apk add --no-cache ansible~=10.2.0; \
ansible --version

RUN apk add --no-cache ca-certificates

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x docker-entrypoint.sh

ENTRYPOINT [ "/docker-entrypoint.sh" ]
8 changes: 8 additions & 0 deletions variants/10.2.0-alpine-edge/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -eu

if [ $# -gt 0 ] && [ "${1#-}" != "$1" ]; then
set -- ansible "$@"
fi

exec "$@"
26 changes: 26 additions & 0 deletions variants/10.2.0-sops-ssh-alpine-edge/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM alpine:edge
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"

# Install ansible
RUN set -eux; \
apk add --no-cache ansible~=10.2.0; \
ansible --version

RUN apk add --no-cache ca-certificates

RUN set -eux; \
wget -qO- https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux > /usr/local/bin/sops; \
chmod +x /usr/local/bin/sops; \
sha256sum /usr/local/bin/sops | grep '^53aec65e45f62a769ff24b7e5384f0c82d62668dd96ed56685f649da114b4dbb '; \
sops --version

RUN apk add --no-cache gnupg

RUN apk add --no-cache openssh-client

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x docker-entrypoint.sh

ENTRYPOINT [ "/docker-entrypoint.sh" ]
8 changes: 8 additions & 0 deletions variants/10.2.0-sops-ssh-alpine-edge/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -eu

if [ $# -gt 0 ] && [ "${1#-}" != "$1" ]; then
set -- ansible "$@"
fi

exec "$@"

0 comments on commit 0891d8a

Please sign in to comment.