Skip to content

Commit

Permalink
Split up docker image building for re-use
Browse files Browse the repository at this point in the history
  • Loading branch information
rnijveld committed Apr 7, 2024
1 parent a96a09d commit 83261ab
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 29 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Docker Image

on:
workflow_call:
inputs:
tags:
description: "List of image tags (newline separated) for the resulting docker image"
required: true
type: string
push:
description: "If true, the image will be pushed to the registry"
required: false
default: false
type: boolean
platforms:
description: "Comma separated list of platforms to build the image for"
required: false
default: "linux/amd64,linux/arm64"
type: string
context:
description: "Context directory for the docker build"
required: false
default: "."
type: string
build-args:
description: "List of build arguments (newline separated) to be inserted in the docker build"
required: false
default: ""
type: string
file:
description: "Name of the dockerfile to build"
required: false
default: "Dockerfile"
type: string

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0

- name: Login to GitHub Container Registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
context: "${{ inputs.context }}"
file: "${{ inputs.file }}"
platforms: "${{ inputs.platforms }}"
no-cache: true
pull: true
build-args: "${{ inputs.build-args }}"
push: ${{ inputs.push }}
tags: "${{ inputs.tags }}"
36 changes: 7 additions & 29 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: Docker

on:
workflow_call: {}
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
Expand All @@ -18,34 +17,13 @@ jobs:
- version: bullseye
latest: false
alt: oldstable
steps:
- name: Checkout sources
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0

- name: Login to GitHub Container Registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
context: .
platforms: linux/amd64,linux/arm64
no-cache: true
pull: true
build-args: |
uses: "./.github/workflows/docker-image.yml"
secrets: inherit
with:
push: ${{ github.ref == 'refs/heads/main' }}
build-args: |
DEBIAN_VERSION=${{matrix.version}}
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
tags: |
ghcr.io/tweedegolf/debian:${{matrix.version}}
ghcr.io/tweedegolf/debian:${{matrix.alt}}
${{ matrix.latest && 'ghcr.io/tweedegolf/debian:latest' || '' }}

0 comments on commit 83261ab

Please sign in to comment.