Skip to content

Commit

Permalink
trying to build multiple docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
elreydetoda committed Jan 2, 2025
1 parent 9faeff1 commit 8ba5491
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 18 deletions.
75 changes: 58 additions & 17 deletions .github/workflows/build-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
container:
- name: ansible
context: ./ansible
dockerfile: ./ansible/Dockerfile
tag: ansible:latest
- name: ansible-playbook
context: ./ansible-playbook
dockerfile: ./ansible-playbook/Dockerfile
tag: ansible-playbook:latest
- name: packer-vmware
context: ./packer-vmware
dockerfile: ./packer-vmware/Dockerfile
tag: packer-vmware:latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -26,27 +41,53 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push ansible
- name: Build and push ${{ matrix.container.name }}
uses: docker/build-push-action@v2
with:
context: ./ansible
file: ./ansible/Dockerfile
# platforms: linux/amd64
context: ${{ matrix.container.context }}
file: ${{ matrix.container.dockerfile }}
push: true
tags: ghcr.io/${{ github.repository_owner }}/ansible:latest
- name: Build and push
uses: docker/build-push-action@v2
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.container.tag }}

build-packer-vmware:
runs-on: ubuntu-latest
strategy:
matrix:
container:
- name: packer-vmware
context: ./packer-vmware
dockerfile: ./packer-vmware/Dockerfile
image_name: packer-vmware
build_args:
- name: UBUNTU_VERSION
version: 20.04
- name: UBUNTU_VERSION
version: 22.04
- name: UBUNTU_VERSION
version: 24.04

- name: Checkout repository
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
context: ./ansible-playbook
file: ./ansible-playbook/Dockerfile
# platforms: linux/amd64
push: true
tags: ghcr.io/${{ github.repository_owner }}/ansible-playbook:latest
- name: Build and push ansible
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push ${{ matrix.container.name }}
uses: docker/build-push-action@v2
with:
context: ./packer-vmware
file: ./packer-vmware/Dockerfile
# platforms: linux/amd64
context: ${{ matrix.container.context }}
file: ${{ matrix.container.dockerfile }}
push: true
tags: ghcr.io/${{ github.repository_owner }}/packer-vmware:latest
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.container.image_name }}:${{ matrix.build_args.version }}
build-args:
- ${{ matrix.build_args.name }}=${{ matrix.build_args.version }}
3 changes: 2 additions & 1 deletion packer-vmware/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG PACKER_VERSION=1.11.2
ARG UBUNTU_VERSION=24.04
FROM "docker.io/hashicorp/packer:light-${PACKER_VERSION}" as packer_bin
FROM docker.io/ubuntu:24.04
FROM docker.io/ubuntu:${UBUNTU_VERSION}
SHELL ["/bin/bash", "-euxc"]
COPY --from=packer_bin /bin/packer /usr/local/bin/packer
RUN set -o pipefail \
Expand Down

0 comments on commit 8ba5491

Please sign in to comment.