-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathDockerfile.fips
45 lines (30 loc) · 1.18 KB
/
Dockerfile.fips
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
ARG GO_VERSION
FROM mcr.microsoft.com/oss/go/microsoft/golang:${GO_VERSION}-1-fips-bookworm AS base
ENV FIPS=true
ENV CGO_ENABLED=1
RUN mkdir -p /.cache \
&& chmod 777 /.cache
WORKDIR /go/src/github.com/elastic/fleet-server
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
ENTRYPOINT [ "make" ]
CMD [ "release" ]
FROM base AS builder
COPY . .
ARG GCFLAGS=""
ARG LDFLAGS=""
ARG DEV=""
ARG TARGETPLATFORM
RUN FIPS=true CGO_ENABLED=1 GCFLAGS="${GCFLAGS}" LDFLAGS="${LDFLAGS}" DEV="${DEV}" make release-${TARGETPLATFORM}
FROM docker.elastic.co/wolfi/glibc-openssl-fips:latest
ARG VERSION
ARG TARGETOS
ARG TARGETARCH
RUN groupadd --gid 1000 fleet-server && \
useradd -M --uid 1000 --gid 1000 fleet-server
USER fleet-server
COPY --chown=fleet-server:fleet-server --chmod=644 fleet-server.yml /etc/fleet-server.yml
COPY --chown=fleet-server:fleet-server --chmod=755 --from=builder /usr/src/fleet-server/build/binaries/fleet-server-${VERSION}-${TARGETOS:-linux}-*/fleet-server /usr/bin/fleet-server
ENV GOFIPS=1
CMD /usr/bin/fleet-server -c /etc/fleet-server.yml