Skip to content

Commit

Permalink
Add GitHub workflow to build container image
Browse files Browse the repository at this point in the history
Signed-off-by: Ionut Balutoiu <[email protected]>
  • Loading branch information
ionutbalutoiu committed Aug 7, 2023
1 parent 705b8dd commit 5be9221
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/container-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: localshowd

on:
push:
branches:
- main

jobs:
container-image:
runs-on: ubuntu-latest

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

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

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

- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/localshowd
flavor: |
latest=${{ github.ref == 'refs/heads/main' }}
tags: |
type=sha
- name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64, linux/arm64, linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: .
pull: true
push: ${{ github.event_name != 'pull_request' }}
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:latest as gobuilder
ADD . /localshow
WORKDIR /localshow
ENV CGO_ENABLED=0
RUN go build -ldflags="-s -w" -o ./localshowd ./cmd/localshowd

FROM scratch
COPY --from=gobuilder /localshow/localshowd /localshowd
CMD ["/localshowd", "--config", "/config/config.toml"]

0 comments on commit 5be9221

Please sign in to comment.