-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.agent
More file actions
33 lines (30 loc) · 1.18 KB
/
Dockerfile.agent
File metadata and controls
33 lines (30 loc) · 1.18 KB
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
# syntax=docker/dockerfile:1
FROM golang:1.25-alpine AS agent-builder
WORKDIR /workspace
COPY go.mod go.sum ./
RUN --mount=type=cache,id=agent-gomod,target=/root/go/pkg/mod go mod download
COPY api/ api/
COPY cmd/agent/ cmd/agent/
COPY internal/ internal/
ARG TARGETARCH
RUN --mount=type=cache,id=agent-gomod,target=/root/go/pkg/mod \
--mount=type=cache,id=agent-gobuild,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o agent ./cmd/agent
FROM golang:1.25-alpine AS guest-agent-builder
WORKDIR /workspace
COPY go.mod go.sum ./
RUN --mount=type=cache,id=guest-gomod,target=/root/go/pkg/mod go mod download
COPY api/ api/
COPY cmd/guest-agent/ cmd/guest-agent/
COPY internal/ internal/
ARG TARGETARCH
RUN --mount=type=cache,id=guest-gomod,target=/root/go/pkg/mod \
--mount=type=cache,id=guest-gobuild,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o guest-agent ./cmd/guest-agent
FROM alpine:3.21 AS runtime
WORKDIR /
RUN apk add --no-cache e2fsprogs
COPY --from=agent-builder /workspace/agent /agent
COPY --from=guest-agent-builder /workspace/guest-agent /opt/imp/guest-agent
USER 65532:65532
ENTRYPOINT ["/agent"]