Skip to content

Commit

Permalink
Merge pull request #28 from mumoshu/goreleaser
Browse files Browse the repository at this point in the history
Use goreleaser to build binaries and container images
  • Loading branch information
cw-atkhry authored Nov 1, 2024
2 parents d0afa14 + 8faf686 commit 4ba16f6
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 9 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ jobs:
DYNAMODB_TABLE: mytable
# This one is for setupSQSQueue in main_test
SQS_QUEUE_URL: https://sqs.ap-northeast-1.amazonaws.com/123456789012/myqueue
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Goreleaser image building test
uses: goreleaser/goreleaser-action@v6
args: release --snapshot
14 changes: 5 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
FROM golang:1.22
WORKDIR /app
FROM gcr.io/distroless/static-debian12

COPY go.mod ./
COPY go.sum ./
RUN go mod download
ARG TARGETOS
ARG TARGETARCH

COPY *.go ./
RUN go mod download
RUN CGO_ENABLED=0 go build -o /aws-checker
COPY aws-checker /usr/local/bin/aws-checker

EXPOSE 8080

CMD ["/aws-checker"]
CMD ["/usr/local/bin/aws-checker"]
57 changes: 57 additions & 0 deletions goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
project_name: aws-checker
env:
builds:
- id: aws-checker
main: ./
env:
- CGO_ENABLED=0
ldflags:
- -s -w
goos:
- darwin
- linux
goarch:
- amd64
- arm64
changelog:
use: github-native

release:
prerelease: auto

dockers:
# https://goreleaser.com/customization/docker/
- use: buildx
goos: linux
goarch: amd64
image_templates:
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:canary-amd64"
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:v{{ .Version }}-amd64"
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version=v{{.Version}}"
- use: buildx
goos: linux
goarch: arm64
image_templates:
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:canary-arm64"
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:v{{ .Version }}-arm64"
build_flag_templates:
- "--platform=linux/arm64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version=v{{.Version}}"

docker_manifests:
- name_template: "{{ .Env.REGISTRY }}/{{ .ProjectName }}:canary"
image_templates:
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:canary-amd64"
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:canary-arm64"
- name_template: "{{ .Env.REGISTRY }}/{{ .ProjectName }}:v{{ .Version }}"
image_templates:
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:v{{ .Version }}-amd64"
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:v{{ .Version }}-arm64"

0 comments on commit 4ba16f6

Please sign in to comment.