-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile
40 lines (35 loc) · 1.18 KB
/
Dockerfile
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
ARG base_image=registry.nordix.org/cloud-native/meridio/base:latest
ARG USER=meridio
ARG UID=10001
ARG HOME=/home/${USER}
FROM golang:1.24 as build
ENV GO111MODULE=on
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOBIN=/bin
ARG meridio_version=0.0.0-unknown
WORKDIR /app
COPY go.mod .
RUN go mod tidy
RUN go mod download
COPY . .
RUN go build -ldflags "-extldflags -static -X main.version=${meridio_version}" -o frontend ./cmd/frontend
FROM ${base_image}
ARG USER
ARG UID
ARG HOME
RUN apk add bird
RUN mkdir -p /run/bird && mkdir -p /etc/bird
RUN addgroup --gid $UID $USER \
&& adduser $USER --home $HOME --uid $UID -G $USER --disabled-password \
&& chown -R :root "${HOME}" && chmod -R g+s=u "${HOME}"
WORKDIR $HOME
COPY --from=build /app/frontend ./
# note: File permissions of unix spire-agent-socket grant "write" access for "others",
# thus cap_dac_override is not required by this hostPath.
# Permissions for logging to file (bird) and interaction between bird and frontend
# can be secured by writable volume mounts and by usage of "fsGroup".
RUN setcap 'cap_net_admin+ep' ./frontend \
&& setcap 'cap_net_admin,cap_net_bind_service,cap_net_raw+ep' /usr/sbin/bird
USER ${UID}:${UID}
CMD ["./frontend"]