Skip to content

Commit

Permalink
Merge pull request #314 from theBeginner86/theBeginner86/update-build
Browse files Browse the repository at this point in the history
[chore] Update Adapter Build files
  • Loading branch information
leecalcote authored Sep 29, 2022
2 parents 062fe7c + 72c3173 commit 55299d7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ jobs:
context: "{{defaultContext}}"
push: true
build-args: |
GIT_STRIPPED_VERSION=${{env.GIT_STRIPPED_VERSION}}
GIT_VERSION=${{env.GIT_VERSION}}
RELEASE_CHANNEL=${{env.RELEASE_CHANNEL}}
VERSION=${{env.GIT_VERSION}}
GIT_COMMITSHA=${GITHUB_SHA::7}
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
-
Expand Down
42 changes: 25 additions & 17 deletions Dockerfile
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"]

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ docker:
docker-run:
(docker rm -f meshery-$(ADAPTER)) || true
docker run --name meshery-$(ADAPTER) -d \
-p 10000:10000 \
-p 10002:10002 \
-e DEBUG=true \
layer5/meshery-$(ADAPTER):$(RELEASE_CHANNEL)-latest

Expand Down

0 comments on commit 55299d7

Please sign in to comment.