Skip to content

Commit

Permalink
Build docker image with GHA
Browse files Browse the repository at this point in the history
Also ensure cleanup is run on build completion
  • Loading branch information
tim-eves committed Jan 9, 2024
1 parent 1f85ab2 commit dfb1cfc
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Prune images
on:
workflow_run:
workflows: [Build Docker fastcgi image]
types: [completed]

jobs:
prune:
runs-on: ubuntu-latest
steps:
- name: prune
uses: vlaurin/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: silnrsi
container: typetunerweb
dry-run: false
keep-younger-than: 7
keep-last: 6
prune-tags-regexes: ^.*$
prune-untagged: true
59 changes: 59 additions & 0 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build Docker fastcgi image
on:
push:
branches: [ "main", "dockerization" ]
paths-ignore:
- kubernetes/**
- LICENSE
- README.md
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry except on PR
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{date 'GGWWEHHmm'}}
type=raw,value=latest
labels: |
org.opencontainers.image.description=TypeTunerWeb for customising default OpenType features on selected fonts
# Build and push Docker image with Buildx (don't push on PR)
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# syntax=docker/dockerfile:1
FROM alpine
LABEL org.opencontainers.image.source=https://github.com/silnrsi/typetunerweb
LABEL org.opencontainers.image.description="TypeTunerWeb for customising default OpenType features on selected fonts"
LABEL org.opencontainers.image.licenses=MIT
COPY --link web/server/fonts?go.cgi /var/www/typetunerweb/web/server/
COPY --link web/server/TypeTuner/typetuner.pl /var/www/typetunerweb/web/server/TypeTuner/
VOLUME /tunable-fonts
Expand Down

0 comments on commit dfb1cfc

Please sign in to comment.