Skip to content

Commit

Permalink
Add Dockerfile and workflows to build images (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuzu authored Jun 30, 2023
1 parent 0705df8 commit e7b0964
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build container images

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
branches:
- master
pull_request:

jobs:
docker:
runs-on: ubuntu-latest
permissions:
packages: write
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
with:
platforms: linux/amd64,linux/arm64
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
-
name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM --platform=$BUILDPLATFORM golang:1.20 AS builder

WORKDIR /workspace
COPY . /workspace

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o annict-epgstation-connector ./cmd/annict-epgstation-connector

FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/annict-epgstation-connector .
USER 65532:65532

ENTRYPOINT ["/annict-epgstation-connector"]

0 comments on commit e7b0964

Please sign in to comment.