Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker cleanup #3

Merged
merged 2 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
image:
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${{ inputs.push && ' 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 }}"
40 changes: 10 additions & 30 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Docker

on:
workflow_call: {}
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
docker:
strategy:
matrix:
include:
Expand All @@ -16,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' || '' }}