Skip to content

Commit

Permalink
Containerise f3 binary and publish to ghcr (#398)
Browse files Browse the repository at this point in the history
Define `Dockerfile` to build and containerise the `f3` CLI, build the
container on pull request on CI and publish it on GitHub Container
Registry on merge to main and tagged versions.
  • Loading branch information
masih authored Jul 4, 2024
1 parent 02ee45c commit 2834f11
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/publish-ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Continuous Integration

on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:

jobs:
publish:
name: Publish Container
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{raw}}
type=ref,event=branch
type=raw,value=${{ github.ref }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.21-bullseye as build

WORKDIR /go/src/f3

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 go build -o /go/bin/f3 ./cmd/f3

FROM gcr.io/distroless/static-debian11
COPY --from=build /go/bin/f3 /usr/bin/

ENTRYPOINT ["/usr/bin/f3"]

0 comments on commit 2834f11

Please sign in to comment.