diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5af5f0fd..6ced5ae3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: uses: goreleaser/goreleaser-action@v4 with: version: latest - args: release --rm-dist + args: release --clean env: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # diff --git a/.goreleaser.yml b/.goreleaser.yml index c9d7afee..c4b25831 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -57,3 +57,17 @@ brews: tap: owner: equinix name: homebrew-tap + +dockers: + - image_templates: + - 'ghcr.io/{{ .Env.GITHUB_REPOSITORY }}:{{ .Tag }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - "--pull" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.name={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.source={{.GitURL}}" + - "--platform=linux/{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..31034098 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# syntax=docker/dockerfile:1 + +## Build +FROM golang:1.19-alpine AS build + +WORKDIR /app + +COPY go.mod ./ +COPY go.sum ./ +RUN go mod download + +COPY ./cmd/. ./cmd/ +COPY ./internal/. ./internal/ +RUN go build -o /metal ./cmd/metal + +## Image +FROM scratch + +WORKDIR / + +COPY --from=build /metal /metal + +USER nonroot:nonroot + +ENTRYPOINT ["/metal"]