-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from theBeginner86/theBeginner86/update-build
[chore] Update Adapter Build files
- Loading branch information
Showing
3 changed files
with
28 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
FROM golang:1.19 as bd | ||
FROM golang:1.19 as builder | ||
|
||
ARG VERSION | ||
ARG GIT_COMMITSHA | ||
WORKDIR /github.com/layer5io/meshery-consul | ||
ADD . . | ||
RUN GOPROXY=direct GOSUMDB=off go build -ldflags="-w -s -X main.version=$VERSION -X main.gitsha=$GIT_COMMITSHA" -a -o /meshery-consul . | ||
RUN find . -name "*.go" -type f -delete; mv consul / | ||
WORKDIR /build | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN GOPROXY=https://proxy.golang.org,direct go mod download | ||
# Copy the go source | ||
COPY main.go main.go | ||
COPY internal/ internal/ | ||
COPY consul/ consul/ | ||
COPY build/ build/ | ||
|
||
FROM alpine:3.15 | ||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup | ||
RUN apk --update add ca-certificates && \ | ||
mkdir /lib64 && \ | ||
ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 | ||
RUN GOPROXY=https://proxy.golang.org,direct CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -ldflags="-w -s -X main.version=$VERSION -X main.gitsha=$GIT_COMMITSHA" -a -o meshery-consul main.go | ||
|
||
USER appuser | ||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
ENV DISTRO="debian" | ||
ENV SERVICE_ADDR="meshery-consul" | ||
ENV MESHERY_SERVER="http://meshery:9081" | ||
RUN mkdir -p /home/appuser/.kube | ||
RUN mkdir -p /home/appuser/.meshery | ||
WORKDIR /home/appuser | ||
WORKDIR $HOME/.meshery | ||
COPY templates/ ./templates | ||
COPY --from=bd /meshery-consul /home/appuser | ||
COPY --from=bd /consul /home/appuser/consul | ||
CMD ./meshery-consul | ||
COPY --from=builder /build/meshery-consul . | ||
USER nonroot:nonroot | ||
|
||
CMD ["./meshery-consul"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters