-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
34 lines (24 loc) · 921 Bytes
/
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
# syntax = docker/dockerfile:experimental
ARG GOLANG_VERSION=1.17
FROM golang:${GOLANG_VERSION}-alpine AS build
WORKDIR /go/src/kubegraph
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download
COPY . .
RUN go mod vendor
ENV CGO_ENABLED=0
RUN --mount=type=cache,target=/root/.cache/go-build go build \
-mod=vendor \
-o kubegraph cmd/kubegraph/main.go
FROM alpine:3 AS user
RUN echo "kubegraph:x:10001:kubegraph" >> /tmp/group
RUN echo "kubegraph:x:10001:10001::/:/dev/null" >> /tmp/passwd
FROM scratch
COPY --from=user /tmp/passwd /etc/passwd
COPY --from=user /tmp/group /etc/group
COPY --from=build --chown=kubegraph:kubegraph /go/src/kubegraph/kubegraph /
USER kubegraph:kubegraph
LABEL org.opencontainers.image.title=kubegraph
LABEL org.opencontainers.image.description="Kubernetes resource graph generator"
LABEL org.opencontainers.image.licenses=MIT
ENTRYPOINT [ "/kubegraph" ]