-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (26 loc) · 956 Bytes
/
Dockerfile
File metadata and controls
34 lines (26 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# syntax=docker/dockerfile:1.20
############################
# Etapa de build ARM64
############################
FROM --platform=$BUILDPLATFORM golang:1.26.1 AS builder
WORKDIR /src
ENV GOPROXY=https://proxy.golang.org,direct
# 1) Deps (capa estable + cache)
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download
# 2) Codi
COPY . .
ARG TARGETARCH
# 3) Build (cache de compilació)
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -o /out/pinger ./cmd/pinger
# --- runtime ---
FROM alpine:3.22
# instal·la ping + setcap a la imatge final
RUN apk add --no-cache iputils libcap
# copia el teu binari
COPY --from=builder /out/pinger /usr/local/bin/pinger
# aplica capabilities al ping de la imatge final
RUN setcap cap_net_raw+ep "$(command -v ping)" && getcap "$(command -v ping)"
ENTRYPOINT ["/usr/local/bin/pinger"]