Skip to content

Commit c925985

Browse files
CopilotxDarksome
andcommitted
Implement multi-arch Docker builds (amd64, arm64)
Co-authored-by: xDarksome <22872975+xDarksome@users.noreply.github.com>
1 parent 6fb88c3 commit c925985

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@ jobs:
2828
with:
2929
submodules: recursive
3030

31-
- name: Set up Go
32-
uses: actions/setup-go@v4
33-
with:
34-
go-version-file: go.mod
31+
- name: Set up QEMU
32+
uses: docker/setup-qemu-action@v3
3533

36-
- name: Build binary
37-
run: |
38-
CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath -o prom2parquet ./cmd/.
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v3
3936

4037
- name: Log in to Container Registry
4138
if: github.event_name != 'pull_request'
@@ -63,6 +60,7 @@ jobs:
6360
with:
6461
context: .
6562
file: ./images/Dockerfile.prom2parquet
63+
platforms: linux/amd64,linux/arm64
6664
push: ${{ github.event_name != 'pull_request' }}
6765
tags: ${{ steps.meta.outputs.tags }}
6866
labels: ${{ steps.meta.outputs.labels }}

images/Dockerfile.prom2parquet

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
FROM golang:1.24-alpine
1+
FROM golang:1.24-alpine AS builder
22

3-
RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64
4-
RUN chmod +x /usr/local/bin/dumb-init
3+
WORKDIR /build
4+
COPY . .
5+
RUN CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath -o prom2parquet ./cmd/.
56

6-
RUN go install github.com/go-delve/delve/cmd/dlv@latest
7+
FROM alpine:latest
78

8-
COPY prom2parquet /prom2parquet
9+
ARG TARGETARCH
10+
RUN apk add --no-cache wget && \
11+
case ${TARGETARCH} in \
12+
"amd64") DUMB_INIT_ARCH=x86_64 ;; \
13+
"arm64") DUMB_INIT_ARCH=aarch64 ;; \
14+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
15+
esac && \
16+
wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_${DUMB_INIT_ARCH} && \
17+
chmod +x /usr/local/bin/dumb-init && \
18+
apk del wget
19+
20+
COPY --from=builder /build/prom2parquet /prom2parquet
921

1022
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]

0 commit comments

Comments
 (0)