Open cyrus-mc opened 5 years ago
Thanks for the analysis. We found this issue in our environment recently as well, and fixed that in #239. We will create a new release soon.
I built master (v0.1.11-10-g1b1102a) and re-ran. Image size is better as the resulting size is only 1.06G now (vs 1.54G before). However docker build still results in a 811M file.
The image layers still show as indicated above. No difference.
Did you set commit=explicit? if you did, then it's expected you get less layers, see https://github.com/uber/makisu#explicit-commit-and-cache
About the size, I need a little time to debug.
Here is some more info
makisu image:
› docker history my_image
IMAGE CREATED CREATED BY SIZE COMMENT
174570a58198 2 minutes ago makisu: RUN rm -f /usr/local/bin/terraform &… 111MB
<missing> 2 minutes ago makisu: COPY bin /usr/local/bin/ (c0a9630e) 111MB
<missing> 2 minutes ago makisu: COPY config/aws /home/atlantis/.aws … 29B
<missing> 2 minutes ago makisu: RUN apk update && apk add python… 217MB
<missing> 3 minutes ago makisu: RUN curl -LOks https://github.com/gr… 9B
<missing> 3 minutes ago makisu: RUN curl -LOks https://github.com/gr… 294MB
docker image:
IMAGE CREATED CREATED BY SIZE COMMENT
13ecb764a55b 7 days ago /bin/sh -c rm -f /usr/local/bin/terraform &&… 31B
507e0de60879 7 days ago /bin/sh -c #(nop) COPY dir:f139a048ea560915c… 111MB
639ff8952e0a 7 days ago /bin/sh -c #(nop) COPY dir:71fc8ec224dc3156c… 29B
7e589924db1c 7 days ago /bin/sh -c apk update && apk add python … 217MB
d67b2cbeb26c 7 days ago /bin/sh -c #(nop) ENV AWS_CLI_VERSION=1.16.… 0B
13c98269605f 7 days ago /bin/sh -c curl -LOks https://github.com/gru… 28.2MB
216f6f7e82cf 7 days ago /bin/sh -c curl -LOks https://github.com/gru… 18.6MB
Interesting is the first layer listed there, in the Dockerfile that simply removes a file and sets a symlink. Docker reports that as a 31B layer whereas makisu matches the previous layer and makes a 111Mb layer.
In addition the curl commands that are used to install terragrunt seem off in the makisu version. First one is 294M. While the second layer is only 9B.
I think it's caused by changes we made to https://github.com/uber/makisu/blob/master/lib/tario/compare.go
I did more experiments, and found out this only happens for some special base images like runatlantis/atlantis
. Other base images like debian:9
doesn't have this issue.
The reason is - makisu includes all files that's considered different from previous layers into current layer.
In this particular case with runatlantis/atlantis
, most files are considered different because this condition is hit:
https://github.com/uber/makisu/blob/5a0da448b6315f098e0cb26823c6986c202b8ef7/lib/tario/compare.go#L25
Because these base image layer tars somehow has these files as of TypeRegA
, while after running build steps Makisu thinks they should be of type TypeReg
. Technically they should have been the same thing, and TypeRegA
is a deprecated type, so I am not sure how the base image was built to produce such a result - maybe it was built on a old version of docker or some special filesystem?
Regardless, this is still a minor bug we should fix.
I think there is also a size problem with hardlink.
New to makisu and built my first image. After successful build I find that the image is (as reported by docker images) 1.49G. That same image built with docker results in an image size of 811M.
Inspecting the resulting image and comparing that to the one that docker build produces shows different layers (both in hash and number).
Inspect of makisu image
Inspect of docker image
From the looks of it the the first 7 layers are common (and are actually from the base image runatlantis/atlantis:v0.8.2). In makisu it appears that all of the layers generated from my Dockerfile are squashed into one (which would make caching difficult no?) whereas in the docker build version they are not.