-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (55 loc) · 1.97 KB
/
Copy pathDockerfile
File metadata and controls
74 lines (55 loc) · 1.97 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Base image on Alpine / Golang
FROM golang:1.26-alpine3.23 AS build
# Download system package dependencies
RUN apk add cmake make gcc libtool git bash musl-dev zstd-dev lz4-dev
# Upload source code
WORKDIR /app
# Install Go dependencies (allow caching)
COPY go.mod .
COPY go.sum .
COPY go.work .
COPY plugins/ ./plugins/
RUN go mod download
# Upload source code
COPY . .
# Stamp version info into the build (passed via --build-arg)
ARG COMMIT_SHA=""
ARG SEM_VER=""
RUN cd ./pkg/version && go generate
RUN nice -15 go build -tags jsoniter,slimcap_nomock -o goprobe -pgo=auto ./cmd/goProbe
RUN nice -15 go build -tags jsoniter -o global-query -pgo=auto ./cmd/global-query
RUN nice -15 go build -o goquery -pgo=auto ./cmd/goQuery
RUN nice -15 go build -o gpctl -pgo=auto ./cmd/gpctl
###########################################################################
FROM alpine:3.23 AS sensor
# Download system package dependencies
RUN apk add libcap zstd-libs lz4-libs
# Add user
RUN set -ex \
&& adduser -G netdev -H -u 1000 -D goprobe
# Transfer binaries from build context
COPY --from=build /app/goprobe /bin/goprobe
COPY --from=build /app/goquery /bin/goquery
COPY --from=build /app/gpctl /bin/gpctl
# Set ownership
RUN set -ex \
&& chmod 750 /bin/goprobe /bin/goquery /bin/gpctl \
&& chown goprobe /bin/goprobe /bin/goquery /bin/gpctl \
&& chgrp netdev /bin/goprobe /bin/goquery /bin/gpctl
# Add inheritable NET_RAW capabilities to goprobe binary
RUN setcap cap_net_raw=eip /bin/goprobe
# De-escalate privileges and define entrypoint
USER goprobe
ENTRYPOINT /bin/goprobe
###########################################################################
FROM alpine:3.23 AS query
# Download system package dependencies
RUN apk add libcap zstd-libs lz4-libs
# Add user
RUN set -ex \
&& adduser -H -u 1000 -D goprobe
# Transfer binaries from build context
COPY --from=build /app/global-query /bin/global-query
# De-escalate privileges and define entrypoint
USER goprobe
ENTRYPOINT /bin/global-query server