Skip to content

Commit

Permalink
chore(ci): workflow for build docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
shirok1 committed Jan 29, 2024
1 parent 22c9b02 commit 74d23b2
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: Build Docker Image

on:
push:
branches:
- master
tags:
- v*

env:
REGISTRY: ghcr.io
IMAGE_BASENAME: shirok1/palboard

jobs:
build-and-push:
strategy:
matrix:
context: [frontend, gateway]

runs-on: ubuntu-latest

permissions:
packages: write
contents: read

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

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

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

- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASENAME }}-${{ matrix.context }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: ${{ matrix.context }}
file: ./Dockerfile
target: final
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Inspect image
run: |
docker buildx imagetools inspect \
${{ env.REGISTRY }}/${{ env.IMAGE_BASENAME }}-${{ matrix.context }}:${{ steps.meta.outputs.version }}
3 changes: 3 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ RUN bun nuxt build
# runtime stage

FROM oven/bun:${BUN_VERSION}-slim AS final
LABEL org.opencontainers.image.source=https://github.com/shirok1/palboard
LABEL org.opencontainers.image.description="PalBoard frontend"
LABEL org.opencontainers.image.licenses=SSPL-1.0

COPY --from=build /app/.output /app

Expand Down
3 changes: 3 additions & 0 deletions gateway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ EOF
# runtime stage

FROM cm2network/steamcmd:latest AS final
LABEL org.opencontainers.image.source=https://github.com/shirok1/palboard
LABEL org.opencontainers.image.description="PalBoard gateway"
LABEL org.opencontainers.image.licenses=SSPL-1.0

COPY --from=build /bin/gateway /bin/

Expand Down

0 comments on commit 74d23b2

Please sign in to comment.