Skip to content

Commit cdcc1bb

Browse files
committed
chore: Add reproducible build docker and github release workflow
1 parent 8e5c9a1 commit cdcc1bb

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build-and-push:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
strategy:
20+
matrix:
21+
binary: [proxy-client, proxy-server]
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # Needed for git describe to work properly
28+
29+
# Add buildx setup
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
with:
33+
buildkitd-flags: --debug
34+
35+
- name: Log in to the Container registry
36+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Extract metadata (tags, labels) for Docker
43+
id: meta
44+
uses: docker/metadata-action@9ec57ed1fcdf50867830130cc04c4d1bb9de141d
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.binary }}
47+
tags: |
48+
type=semver,pattern={{version}}
49+
type=semver,pattern={{major}}.{{minor}}
50+
type=sha
51+
52+
- name: Build and push Docker image
53+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
54+
with:
55+
context: .
56+
file: Dockerfile
57+
platforms: linux/amd64
58+
provenance: false # Disable build metadata that could affect reproducibility
59+
build-args: |
60+
BINARY=${{ matrix.binary }}
61+
push: true
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM golang:1.24rc2-bullseye@sha256:236da40764c1bcf469fcaf6ca225ca881c3f06cbd1934e392d6e4af3484f6cac AS builder
2+
3+
ARG BINARY=proxy-client
4+
WORKDIR /app
5+
COPY ./ /app
6+
RUN make build-${BINARY}
7+
8+
FROM gcr.io/distroless/cc-debian12:nonroot-6755e21ccd99ddead6edc8106ba03888cbeed41a
9+
ARG BINARY
10+
COPY --from=builder /app/build/${BINARY} /app
11+
ENTRYPOINT [ "/app" ]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ build: clean build-proxy-client build-proxy-server ## Build the proxy client and
2626
.PHONY: build-proxy-client
2727
build-proxy-client: ## Build the proxy client
2828
@mkdir -p ./build
29-
go build -trimpath -ldflags "-X github.com/flashbots/cvm-reverse-proxy/common.Version=${VERSION}" -v -o ./build/proxy-client cmd/proxy-client/main.go
29+
go build -trimpath -ldflags "-s -w -buildid= -X github.com/flashbots/cvm-reverse-proxy/common.Version=${VERSION}" -v -o ./build/proxy-client cmd/proxy-client/main.go
3030

3131
.PHONY: build-proxy-server
3232
build-proxy-server: ## Build the proxy server
3333
@mkdir -p ./build
34-
go build -trimpath -ldflags "-X github.com/flashbots/cvm-reverse-proxy/common.Version=${VERSION}" -v -o ./build/proxy-server cmd/proxy-server/main.go
34+
go build -trimpath -ldflags "-s -w -buildid= -X github.com/flashbots/cvm-reverse-proxy/common.Version=${VERSION}" -v -o ./build/proxy-server cmd/proxy-server/main.go
3535

3636
##@ Test & Development
3737

0 commit comments

Comments
 (0)