Skip to content

Commit

Permalink
build client in GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
timburks committed Oct 18, 2024
1 parent 948b6d9 commit 0b17a80
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/docker-publish-client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish docker images of client

on:
schedule:
- cron: '0 0 * * *' # each 12:00 UTC
push:
branches: [ main ]
tags: [ 'v*.*.*' ] # semver release
pull_request:
branches: [ main ]

env:
IMAGE: stores-client

jobs:

build-container:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Log into registry ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=schedule,pattern=nightly
type=raw,latest
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: "."
file: Dockerfile-client
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
10 changes: 10 additions & 0 deletions Dockerfile-client
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.22.5 as builder
WORKDIR /app
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -v -o stores-client ./cmd/stores-client

FROM alpine:3
RUN apk add --no-cache ca-certificates
COPY --from=builder /app/stores-client /usr/local/bin/stores-client
COPY --from=builder /app/roots.pem /roots.pem
ENTRYPOINT ["/usr/local/bin/stores-client"]

0 comments on commit 0b17a80

Please sign in to comment.