Skip to content

Commit

Permalink
feat: implement container images builds
Browse files Browse the repository at this point in the history
  • Loading branch information
0x416e746f6e committed Feb 23, 2024
1 parent 8bd9f9f commit 5241f74
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 7 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!include:.gitignore
34 changes: 34 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: release

on:
workflow_dispatch:
push:
tags:
- "v*"

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: setup dependencies
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: build and publish release
uses: goreleaser/goreleaser-action@v5
with:
args: release --clean
distribution: goreleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 25 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,30 @@ archives:
checksum:
name_template: 'checksums.txt'

signs:
- artifacts: checksum

release:
prerelease: auto

dockers:
- dockerfile: Dockerfile.goreleaser
goarch: amd64
goos: linux
use: buildx
build_flag_templates:
- --platform=linux/amd64
image_templates:
- "ghcr.io/flashbots/prometheus-sns-lambda-webhook:{{ .Tag }}-amd64"

- dockerfile: Dockerfile.goreleaser
goarch: arm64
goos: linux
use: buildx
build_flag_templates:
- --platform=linux/arm64
image_templates:
- "ghcr.io/flashbots/prometheus-sns-lambda-webhook:{{ .Tag }}-arm64"

docker_manifests:
- name_template: "ghcr.io/flashbots/prometheus-sns-lambda-webhook:{{ .Tag }}"
image_templates:
- "ghcr.io/flashbots/prometheus-sns-lambda-webhook:{{ .Tag }}-amd64"
- "ghcr.io/flashbots/prometheus-sns-lambda-webhook:{{ .Tag }}-arm64"
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# stage: build

FROM golang:1.22-alpine as builder

ARG VERSION=development

WORKDIR /go/src/flashbots/prometheus-sns-lambda-webhook
COPY go.* ./

RUN go mod download
COPY . ./

ENV CGO_ENABLED=0
RUN go build \
-ldflags "-X main.version=${VERSION}" \
-o ./bin/prometheus-sns-lambda-webhook \
github.com/flashbots/prometheus-sns-lambda-webhook/cmd

# stage: run

FROM gcr.io/distroless/static-debian12 as runner

WORKDIR /app

COPY --from=builder /go/src/flashbots/prometheus-sns-lambda-webhook/bin/prometheus-sns-lambda-webhook /

ENTRYPOINT [ "./prometheus-sns-lambda-webhook" ]
9 changes: 9 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# stage: run

FROM gcr.io/distroless/static-debian12 as runner

WORKDIR /app

COPY prometheus-sns-lambda-webhook /

ENTRYPOINT [ "./prometheus-sns-lambda-webhook" ]
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ default: build
.PHONY: build
build:
CGO_ENABLED=0 \
go build \
@go build \
-ldflags "-X main.version=${VERSION}" \
-o ./bin/prometheus-sns-lambda-slack \
-o ./bin/prometheus-sns-lambda-webhook \
github.com/flashbots/prometheus-sns-lambda-webhook/cmd

.PHONY: snapshot
snapshot:
goreleaser release --snapshot --rm-dist
@goreleaser release --snapshot --clean

.PHONY: release
release:
@rm -rf ./dist
GITHUB_TOKEN=$$( gh auth token ) goreleaser release
@if [[ -z $${GITHUB_TOKEN} ]]; then GITHUB_TOKEN=$$( gh auth token ) goreleaser release; else goreleaser release; fi

0 comments on commit 5241f74

Please sign in to comment.