Skip to content

Commit 05d4f4a

Browse files
authored
Merge pull request #68 from utkarsh-pro/utkarsh-pro/fix/docker-image
Move to distroless image
2 parents e953c16 + c24984c commit 05d4f4a

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

Dockerfile

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
FROM golang:1.15 as bd
2-
WORKDIR /github.com/layer5io/meshery-traefik-mesh
3-
ADD . .
4-
RUN GOPROXY=https://proxy.golang.org GOSUMDB=off go build -ldflags="-w -s" -a -o /meshery-traefik-mesh .
5-
RUN find . -name "*.go" -type f -delete
1+
FROM golang:1.15 as builder
62

7-
FROM alpine
8-
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
9-
RUN apk --update add ca-certificates
10-
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
3+
ARG CONFIG_PROVIDER="viper"
4+
WORKDIR /build
5+
# Copy the Go Modules manifests
6+
COPY go.mod go.mod
7+
COPY go.sum go.sum
8+
# cache deps before building and copying source so that we don't need to re-download as much
9+
# and so that source changes don't invalidate our downloaded layer
10+
RUN go mod download
11+
# Copy the go source
12+
COPY main.go main.go
13+
COPY internal/ internal/
14+
COPY traefik/ traefik/
15+
# Build
16+
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags="-w -s -X main.provider=$CONFIG_PROVIDER" -a -o meshery-traefik-mesh main.go
1117

12-
USER appuser
13-
RUN mkdir -p /home/appuser/.kube
14-
RUN mkdir -p /home/appuser/.meshery
15-
WORKDIR /home/appuser
16-
COPY --from=bd /meshery-traefik-mesh /home/appuser
17-
# COPY --from=bd /etc/passwd /etc/passwd
18-
CMD ./meshery-traefik-mesh
18+
# Use distroless as minimal base image to package the manager binary
19+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
20+
FROM gcr.io/distroless/base:nonroot-amd64
21+
ENV DISTRO="debian"
22+
ENV GOARCH="amd64"
23+
WORKDIR $HOME/.meshery
24+
COPY --from=builder /build/meshery-traefik-mesh .
25+
ENTRYPOINT ["./meshery-traefik-mesh"]

0 commit comments

Comments
 (0)