-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker Push Github Action #83
Changes from 5 commits
4017d17
2b29eeb
5e01f28
2900646
79ba1df
b00a7d9
25373a9
403e70c
29d2850
4c35ea4
2fa3a1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM golang:1.18.2 as builder | ||
|
||
WORKDIR /workspace | ||
# 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 go mod download | ||
|
||
# Copy the go source | ||
COPY . /workspace | ||
|
||
# Build | ||
RUN make build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why build here again but not use artifact from build and test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keeping the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel this is a bad practice: we are releasing a build which is not tested in the same environment. buildx doesn't need volume mounts anyway, it is just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree here, the workflow for pushing docker images would also run some form of e2e (which doesn't exist today) using the same image before pushing the image There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other disadvantage of this is we are going to use QEMU for future arm64 (and other) build which is way slower and hard to workaround. It is better to split the build and docker packaging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer if we first tried the simpler way of building There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have moved over the job as a step into the main workflow, we could further optimize this logic by retagging instead of relying on the build cache layers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need even a self hosted ARM runner, Go cross compile works great without hassle, just need to copy the binary from local machine (or downloaded artifacts), instead of force docker build run Go build. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cool, lets consider adding that as a follow up PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. raised #93 so this conversation can continue there and can unblock this PR |
||
|
||
# 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 | ||
WORKDIR / | ||
COPY --from=builder /workspace/bin/envoy-gateway . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/envoy-gateway"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
# REGISTRY is the image registry to use for build and push image targets. | ||
REGISTRY ?= docker.io/envoyproxy | ||
# IMAGE is the image URL for build and push image targets. | ||
IMAGE ?= ${REGISTRY}/gateway-dev | ||
# REV is the short git sha of latest commit. | ||
REV=$(shell git rev-parse --short HEAD) | ||
# Tag is the tag to use for build and push image targets. | ||
TAG ?= $(REV) | ||
|
||
.PHONY: build | ||
build: | ||
@go build -o ./bin/ github.com/envoyproxy/gateway/cmd/envoy-gateway | ||
@CGO_ENABLED=0 go build -a -o ./bin/ github.com/envoyproxy/gateway/cmd/envoy-gateway | ||
|
||
.PHONY: test | ||
test: | ||
@go test ./... | ||
|
||
.PHONY: docker-build | ||
docker-build: test ## Build the envoy-gateway docker image. | ||
docker build -t $(IMAGE):$(TAG) -f Dockerfile . | ||
|
||
.PHONY: docker-push | ||
docker-push: ## Push the docker image for envoy-gateway. | ||
docker push $(IMAGE):$(TAG) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can drop this since we're only building a single arch now and when we add support for multi-arch images we can use Go's native cross-compilation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on the comments, added
linux/arm64
to enableenvoy-gateway
images to run onarm64
as well (e.g. M1 Macbooks)