-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
45 lines (36 loc) · 1.52 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
41
42
43
44
45
FROM mcr.microsoft.com/windows/nanoserver:1809-amd64 as runtime-Windows
COPY bin/cert-bootstrapper-Windows-x86_64.exe /
USER ContainerAdministrator
ENTRYPOINT "c:\cert-bootstrapper-Windows-x86_64.exe"
FROM --platform=${BUILDPLATFORM} golang:1.16 AS base
WORKDIR /project
ENV CGO_ENABLED=0
COPY go.* .
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
FROM base AS build
ARG TARGETOS
ARG TARGETARCH
RUN --mount=source=src,target=src,rw \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o src/bin/agent ./src/cmd/agent && \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /out/cert-bootstrapper ./src && \
cp src/bin/agent /out/
FROM golangci/golangci-lint:v1.31.0-alpine AS lint-base
FROM build AS lint
RUN --mount=source=src,target=src,rw \
--mount=from=build,src=/out,target=/out \
--mount=from=lint-base,src=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/.cache/golangci-lint \
cp /out/agent src/bin/ && \
golangci-lint run --timeout 10m0s ./src
FROM scratch AS bin-linux
COPY --from=build /out/cert-bootstrapper /cert-bootstrapper-Linux-x86_64
FROM scratch AS bin-windows
COPY --from=build /out/cert-bootstrapper /cert-bootstrapper-Windows-x86_64.exe
FROM bin-${TARGETOS} as bin
FROM bin-linux as runtime-linux
ENTRYPOINT [ "/cert-bootstrapper-Linux-x86_64" ]