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: Speed up docker build in some setups #1948

Closed
wants to merge 1 commit into from

Conversation

abador
Copy link
Contributor

@abador abador commented Nov 11, 2021

This change adds builder cache in dockerfile. This speeds up the build in some cases.

Related issue(s)

Checklist

  • [x ] I have read the contributing guidelines.
  • [x ] I have referenced an issue containing the design document if my change
    introduces a new feature.
  • [x ] I am following the
    contributing code guidelines.
  • [x ] I have read the security policy.
  • [ x] I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security. vulnerability, I
    confirm that I got green light (please contact
    [email protected]) from the maintainers to push
    the changes.
  • [x ] I have added tests that prove my fix is effective or that my feature
    works.
  • [x ] I have added or changed the documentation.

Further Comments

@abador abador changed the title Speed up docker build in some setups perf: Speed up docker build in some setups Nov 11, 2021
@abador abador changed the title perf: Speed up docker build in some setups build: Speed up docker build in some setups Nov 11, 2021
@aeneasr
Copy link
Member

aeneasr commented Nov 13, 2021

Could you please link some docs explaining how this works? Thank you :)

@abador
Copy link
Contributor Author

abador commented Nov 16, 2021

This change is basically a way to add caching to our docker builds on a local machine that runs that build. If you run it on a different machine there is no difference. I also split this into a multi-stage build (this also might speed some things up). Some example doc about this: https://www.docker.com/blog/containerize-your-go-developer-environment-part-2/

@@ -1,4 +1,5 @@
FROM golang:1.16-alpine AS builder
# syntax = docker/dockerfile:1-experimental
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I know this changes the way dockerfiles are parsed and it's still needed in the current version

@@ -13,13 +14,15 @@ ENV CGO_ENABLED 1

RUN go mod download

FROM base as builder
Copy link
Member

Choose a reason for hiding this comment

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

We are using the same image as in the previous step, do we need to or can we leave this out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will still work porperly without this

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.

2 participants