Skip to content
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

build: Simpler Docker build #5057

Merged
merged 22 commits into from
Feb 10, 2021
Merged

build: Simpler Docker build #5057

merged 22 commits into from
Feb 10, 2021

Conversation

alexec
Copy link
Contributor

@alexec alexec commented Feb 9, 2021

Build Before After
Docker Build 1h 45m
CI 13m 17m

Signed-off-by: Alex Collins <alex_collins@intuit.com>
@@ -1,10 +1,21 @@
# Prevent vendor directory from being copied to ensure we are not not pulling unexpected cruft from
# a user's workspace, and are only building off of what is locked by dep.
*.iml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while these files are small, they can result in invalidating the Docker caches, forcing build steps to be re-run


ARG IMAGE_OS=linux
ARG DOCKER_CHANNEL=stable
Copy link
Contributor Author

@alexec alexec Feb 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ARGs can and should go before the first FROM

Dockerfile Outdated
tar --extract --file docker.tgz --strip-components 1 --directory /usr/local/bin/ && \
rm docker.tgz
# https://blog.container-solutions.com/faster-builds-in-docker-with-go-1-11
WORKDIR /go/src/github.com/argoproj/argo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classic cache speed up technique

FROM debian:10.7-slim as argoexec-base

ARG IMAGE_OS=linux
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need this because we use `docker buildx --platform linux/amd64'


####################################################################################################

FROM node:14.0.0 as argo-ui

ADD ["ui", "ui"]
ADD ["api", "api"]
COPY ui/package.json ui/yarn.lock ui/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another classic speed up technique

COPY . .
# check we can use Git
RUN git rev-parse HEAD
RUN --mount=type=cache,target=/root/.cache/go-build make dist/workflow-controller
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a buildx way to do build caching, I'm not 100% sure it works, so we may want to remove later on

COPY --from=argo-build --chown=8737 /go/src/github.com/argoproj/argo/argo-server.key argo-server.key
COPY --from=argo-build /go/src/github.com/argoproj/argo/dist/argo-${IMAGE_OS}-* /bin/argo

COPY hack/ssh_known_hosts /etc/ssh/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer depend on argoexec

DOCKER_PUSH := false

# VERSION is the version to be used for files in manifests and should always be latest uunlesswe are releasing
# we assume HEAD means you are on a tag
ifeq ($(findstring release,$(GIT_BRANCH)),release)
VERSION := $(GIT_TAG)
DEV_IMAGE := false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer need dev images, standard build is fast enough

Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
@alexec alexec changed the title build: Faster, simpler, build build: Simpler Docker build Feb 9, 2021
alexec and others added 4 commits February 9, 2021 12:12
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Dockerfile Outdated Show resolved Hide resolved
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
@alexec
Copy link
Contributor Author

alexec commented Feb 10, 2021

This is actually a 3m slower to run tests CI, but is faster to start-up locally.

@alexec alexec marked this pull request as ready for review February 10, 2021 00:10
@alexec alexec merged commit b18b992 into master Feb 10, 2021
@alexec alexec deleted the buildx branch February 10, 2021 20:23
@simster7 simster7 mentioned this pull request Feb 16, 2021
33 tasks
@bryanisgreat bryanisgreat mentioned this pull request Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants