Skip to content

Commit

Permalink
Image build and publish workflow added
Browse files Browse the repository at this point in the history
  • Loading branch information
snorwin committed Dec 27, 2023
1 parent dc85d1e commit 136b9d3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: publish

on:
push:
branches:
- main
release:
types:
- published

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
- uses: docker/build-push-action@v5
with:
push: true
file: ./Containerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
provenance: false
19 changes: 19 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:1.21-bullseye as builder
RUN apt-get update && apt-get install -y upx

WORKDIR /workspace
COPY . /workspace
RUN go mod download

RUN GOOS=linux GOARCH=amd64 go build -a -o haproxy-operator main.go && \
upx -q haproxy-operator


FROM gcr.io/distroless/static:nonroot

WORKDIR /opt/go/
COPY --from=builder /workspace/haproxy-operator /opt/go/haproxy-operator

USER 1001:1001

ENTRYPOINT ["/opt/go/haproxy-operator"]

0 comments on commit 136b9d3

Please sign in to comment.