Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Reduce size of go image #21

Closed
akosyakov opened this issue Jan 5, 2018 · 7 comments
Closed

Reduce size of go image #21

akosyakov opened this issue Jan 5, 2018 · 7 comments
Assignees

Comments

@akosyakov
Copy link
Member

See for the guidance: #14 (comment)

@JanKoehnlein JanKoehnlein self-assigned this Jan 5, 2018
@JanKoehnlein
Copy link
Member

I cannot get the latest go running on alpine. Tried for a few hours, postponing now.

  • latest apk for alpine is 1.8.4, which is seriously behind the current 1.9.2.
  • The binary blob is not executable on alpine. It's not a chmod issue, rather some missing runtime or wrong architecture.
  • Building go from sources with the 1.8.4 yields a segmentation fault while running the tests

@Zate
Copy link

Zate commented Feb 25, 2018

Still tinkering with this but I was able to get it from ~1.4GB down to 745mb.

Going to dig deeper, but as you can see below, the theia app is ~173mb, Go is 264mb and the installed go deps are ~ 240mb.

I'm going to explore perhaps statically compiling all the go deps (but i dont think this will work), and see what I can slim out of the go install itself but am not hopeful as golang:1.9-alpine is 269mb on it's own.

Not sure I can get it much smaller. I'll stick the Dockerfile etc up once I am done tinkering.

> $ docker history a0945ede9efa
> IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
> a0945ede9efa        6 minutes ago       /bin/sh -c #(nop)  ENTRYPOINT ["/bin/sh" "-c…   0B
> ea10e8342c44        6 minutes ago       /bin/sh -c #(nop)  ENV USE_LOCAL_GIT=true       0B
> 5d989e8ac219        6 minutes ago       /bin/sh -c #(nop)  ENV SHELL=/bin/bash          0B
> e1d7521aa8d3        6 minutes ago       /bin/sh -c #(nop)  EXPOSE 3000                  0B
> 90ab98b35ed5        6 minutes ago       /bin/sh -c apk add --no-cache git openssh-cl…   240MB
> 313d9b9788c6        13 minutes ago      /bin/sh -c #(nop) COPY dir:2eaf1b244da5df459…   264MB
> a394158fd65c        13 minutes ago      /bin/sh -c #(nop) COPY dir:ed68ba95ee37b16d2…   173MB
> b6a793052b33        13 minutes ago      /bin/sh -c #(nop) WORKDIR /home/theia           0B
> 406f227b21f5        3 days ago          /bin/sh -c #(nop)  CMD ["node"]                 0B
> <missing>           3 days ago          /bin/sh -c apk add --no-cache --virtual .bui…   4.19MB
> <missing>           3 days ago          /bin/sh -c #(nop)  ENV YARN_VERSION=1.3.2       0B
> <missing>           3 days ago          /bin/sh -c addgroup -g 1000 node     && addu…   59.9MB
> <missing>           6 weeks ago         /bin/sh -c #(nop)  ENV NODE_VERSION=8.9.4       0B
> <missing>           6 weeks ago         /bin/sh -c #(nop)  CMD ["/bin/sh"]              0B
> <missing>           6 weeks ago         /bin/sh -c #(nop) ADD file:6edc55fb54ec9fc36…   3.97MB

@Zate
Copy link

Zate commented Feb 26, 2018

Ok this is pretty untested though it worked on my local, I'm going to build it and stick it up on my server for more testing.

https://github.com/Zate/theia/tree/master/theia-go-docker

@marcdumais-work
Copy link
Member

@Zate
Copy link

Zate commented Mar 31, 2018

Yes sorry moved that into a docker branch on my fork so that automated builds I was working on for the master branch wouldn't break and so i could always rebase to upstream master.

Fair warning, the items in the docker branch as in a state of semi broken flux. feel free to look around but no guarantees on anything building. my Work is heaving right now (writing reviews for a team of 20) and I should be able to look at docker again in a week or so.

https://github.com/zate/theia/tree/docker is the branch. Anything outside of theia-go-docker is likely to be broken. Current dockerfile in that folder is me trying to automate a multistage build from a bare alpine for everything, not just go. The last go specific build I did is I think this one https://github.com/Zate/theia/blob/docker/theia-go-docker/Dockerfiles.experiments/Dockerfile.next

Mostly i just squashed as man RUN elements into a single layer as I could.

@sr229
Copy link
Contributor

sr229 commented Jul 12, 2018

@akosyakov I think there's a way to compress it - using the current image. By putting some stuff on a single layer. I'll do a PR about it.

@stale
Copy link

stale bot commented Jul 16, 2019

This contribution has been automatically marked as stale due to inactivity, and it will be closed if no further activity occurs. Thank you for contributing to Theia!

@stale stale bot added the stale label Jul 16, 2019
@stale stale bot closed this as completed Aug 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants