Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Add no-cache build flag #1470

Merged
merged 2 commits into from
Mar 30, 2021
Merged

Add no-cache build flag #1470

merged 2 commits into from
Mar 30, 2021

Conversation

aiordache
Copy link
Contributor

@aiordache aiordache commented Mar 26, 2021

Added remaining build flags. Only one applied is the no-cache one.

$ docker compose build                                                                                                                             
[+] Building 0.3s (18/18) FINISHED                                                                                                                       
 => [nginx-golang-postgres_backend internal] load build definition from Dockerfile                                                                  0.0s
 => => transferring dockerfile: 32B                                                                                                                 0.0s
 => [nginx-golang-postgres_proxy internal] load build definition from Dockerfile                                                                    0.0s
 => => transferring dockerfile: 31B                                                                                                                 0.0s
 => [nginx-golang-postgres_backend internal] load .dockerignore                                                                                     0.0s
 => => transferring context: 2B                                                                                                                     0.0s
 => [nginx-golang-postgres_proxy internal] load .dockerignore                                                                                       0.0s
 => => transferring context: 2B                                                                                                                     0.0s
 => [nginx-golang-postgres_backend internal] load metadata for docker.io/library/alpine:3.12                                                        0.2s
 => [nginx-golang-postgres_backend internal] load metadata for docker.io/library/golang:1.13-alpine                                                 0.2s
 => [nginx-golang-postgres_proxy internal] load metadata for docker.io/library/nginx:1.13-alpine                                                    0.1s
 => [nginx-golang-postgres_proxy internal] load build context                                                                                       0.0s
 => => transferring context: 157B                                                                                                                   0.0s
 => [nginx-golang-postgres_proxy 1/2] FROM docker.io/library/nginx:1.13-alpine@sha256:9d46fd628d54ebe1633ee3cf0fe2acfcc419cfae541c63056530e39cd562  0.0s
 => CACHED [nginx-golang-postgres_proxy 2/2] COPY conf /etc/nginx/conf.d/default.conf                                                               0.0s
 => [nginx-golang-postgres_backend] exporting to image                                                                                              0.0s
 => => exporting layers                                                                                                                             0.0s
 => => writing image sha256:fa6741fd561e047833a7c244a2c989a94e5404c839017d3f5efdf64cd4fe0388                                                        0.0s
 => => naming to docker.io/library/nginx-golang-postgres_proxy                                                                                      0.0s
 => => writing image sha256:7809a9a2a8ef872738fbe5e78fe1554cd339f633b69a160256d8f947415b30c4                                                        0.0s
 => => naming to docker.io/library/nginx-golang-postgres_backend                                                                                    0.0s
 => [nginx-golang-postgres_backend stage-1 1/2] FROM docker.io/library/alpine:3.12@sha256:d1eaae2a6814b4b10a722fa75e8a6b53db42d1bf531395a107fea045  0.0s
 => [nginx-golang-postgres_backend build 1/4] FROM docker.io/library/golang:1.13-alpine@sha256:e74b83b94d499cb34c7edf55fbdff9d3cfabd238a35f9cb1b59  0.0s
 => [nginx-golang-postgres_backend internal] load build context                                                                                     0.0s
 => => transferring context: 2.21kB                                                                                                                 0.0s
 => CACHED [nginx-golang-postgres_backend build 2/4] WORKDIR /go/src/github.com/org/repo                                                            0.0s
 => CACHED [nginx-golang-postgres_backend build 3/4] COPY . .                                                                                       0.0s
 => CACHED [nginx-golang-postgres_backend build 4/4] RUN go build -o server .                                                                       0.0s
 => CACHED [nginx-golang-postgres_backend stage-1 2/2] COPY --from=build /go/src/github.com/org/repo/server /server                                 0.0s

With --no-cache

18:18 $ docker compose build --no-cache                                                                                                                  
[+] Building 2.7s (18/18) FINISHED                                                                                                                       
 => [nginx-golang-postgres_backend internal] load build definition from Dockerfile                                                                  0.0s
 => => transferring dockerfile: 32B                                                                                                                 0.0s
 => [nginx-golang-postgres_proxy internal] load build definition from Dockerfile                                                                    0.0s
 => => transferring dockerfile: 31B                                                                                                                 0.0s
 => [nginx-golang-postgres_backend internal] load .dockerignore                                                                                     0.0s
 => => transferring context: 2B                                                                                                                     0.0s
 => [nginx-golang-postgres_proxy internal] load .dockerignore                                                                                       0.0s
 => => transferring context: 2B                                                                                                                     0.0s
 => [nginx-golang-postgres_backend internal] load metadata for docker.io/library/golang:1.13-alpine                                                 0.4s
 => [nginx-golang-postgres_backend internal] load metadata for docker.io/library/alpine:3.12                                                        0.4s
 => [nginx-golang-postgres_proxy internal] load metadata for docker.io/library/nginx:1.13-alpine                                                    0.4s
 => [nginx-golang-postgres_proxy internal] load build context                                                                                       0.0s
 => => transferring context: 157B                                                                                                                   0.0s
 => CACHED [nginx-golang-postgres_proxy 1/2] FROM docker.io/library/nginx:1.13-alpine@sha256:9d46fd628d54ebe1633ee3cf0fe2acfcc419cfae541c63056530e  0.0s
 => [nginx-golang-postgres_backend build 1/4] FROM docker.io/library/golang:1.13-alpine@sha256:e74b83b94d499cb34c7edf55fbdff9d3cfabd238a35f9cb1b59  0.0s
 => CACHED [nginx-golang-postgres_backend stage-1 1/2] FROM docker.io/library/alpine:3.12@sha256:d1eaae2a6814b4b10a722fa75e8a6b53db42d1bf531395a10  0.0s
 => [nginx-golang-postgres_backend internal] load build context                                                                                     0.0s
 => => transferring context: 85B                                                                                                                    0.0s
 => CACHED [nginx-golang-postgres_backend build 2/4] WORKDIR /go/src/github.com/org/repo                                                            0.0s
 => [nginx-golang-postgres_proxy 2/2] COPY conf /etc/nginx/conf.d/default.conf                                                                      0.0s
 => [nginx-golang-postgres_backend build 3/4] COPY . .                                                                                              0.0s
 => [nginx-golang-postgres_backend] exporting to image                                                                                              0.9s
 => => exporting layers                                                                                                                             0.9s
 => => writing image sha256:fa6741fd561e047833a7c244a2c989a94e5404c839017d3f5efdf64cd4fe0388                                                        0.0s
 => => naming to docker.io/library/nginx-golang-postgres_proxy                                                                                      0.0s
 => => writing image sha256:6e9485cc210170ed8e4d91b59f0dd286c07dd5b1bc6ad158e061d7ef02d46aa4                                                        0.0s
 => => naming to docker.io/library/nginx-golang-postgres_backend                                                                                    0.0s
 => [nginx-golang-postgres_backend build 4/4] RUN go build -o server .                                                                              1.2s 
 => [nginx-golang-postgres_backend stage-1 2/2] COPY --from=build /go/src/github.com/org/repo/server /server     

Closes #1468

Signed-off-by: aiordache <[email protected]>
@aiordache aiordache requested review from gtardif and ndeloof March 26, 2021 17:23
@github-actions github-actions bot added api api cli cli local Local context (moby) labels Mar 26, 2021
cmd.Flags().BoolVar(&opts.noCache, "no-cache", false, "Do not use cache when building the image")
cmd.Flags().Bool("no-rm", false, "Do not remove intermediate containers after a successful build. DEPRECATED")
cmd.Flags().MarkHidden("no-rm") //nolint:errcheck
cmd.Flags().StringVarP(&opts.memory, "memory", "m", "", "Set memory limit for the build container. DEPRECATED")
Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAIK this hasn't been deprecated (why would it?)
docker-compose 1.28.5 says -m, --memory MEM Set memory limit for the build container. - no deprecation notice here

Copy link
Member

Choose a reason for hiding this comment

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

I don't think they're deprecated, but some of these are not (yet) supported on BuildKit; there's a list of options that are not available when using buildkit here; moby/moby#40379

Copy link
Collaborator

Choose a reason for hiding this comment

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

right, so we should better show a warning explaining this option is not (yet) implemented and will be ignored.

Copy link
Member

Choose a reason for hiding this comment

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

On the docker cli, we conditionally hide some of these if buildkit is used as builder (look for the no-buildkit annotation for these flags; https://github.com/docker/cli/blob/e3d93058fdbb7ecd24aa68ca710908e075a0f2ed/cli/command/image/build.go#L123-L124

Copy link
Member

Choose a reason for hiding this comment

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

right, so we should better show a warning explaining this option is not (yet) implemented and will be ignored.

Yes, I had a PR in the cli, that would produce an error, but possibly a "warning" would be better; I was waiting for @tonistiigi to answer he agreed on that (instead of error); docker/cli#2736

Copy link
Contributor

Choose a reason for hiding this comment

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

while @aiordache is on PTO, I added a warning if the --memory flag is set, and it's just ignored. Removed DEPRECATED from the description (but it's hidden anyway)

Copy link
Collaborator

@ndeloof ndeloof left a comment

Choose a reason for hiding this comment

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

LGTM but need clarification on deprecating --memory (which seems to me a usefull one)

…rning and ignore flag

Signed-off-by: Guillaume Tardif <[email protected]>
@ndeloof ndeloof merged commit 9df272a into docker-archive:main Mar 30, 2021
@aiordache aiordache deleted the build_args branch June 25, 2021 10:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api api cli cli local Local context (moby)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement missing build flags to better align with docker-compose
4 participants