-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add explicit gcc
dependency in Dockerfile
#262
Conversation
In pelias/docker-baseimage#23 we're leaning out our Docker baseimage used by all other Pelias images, and hopefully can remove the compiler toolchain all together. The Polylines Docker images _do_ need `gcc` (but not quite a full compiler toolchain), but didn't follow the convention in our other Dockerfiles of having an `apt-get` step to install it. This adds such a step, and is a little clever in installing `gcc` only temporarily, and only for the `go get` step that requires it. The polylines Docker image is already quite large (950MB uncompressed) since it includes Node.js, Go, and package dependencies for both. Skipping the installation of `gcc` cuts out 120MB of that. Until pelias/docker-baseimage#23 this change won't really have any impact on the size or operation of this Docker image.
This should be fine, although I'm not convinced the cleanup is removing everything that was installed. I believe My preference for this sort of thing would be a multi-stage docker build where the binary is generated in an isolated stage and then just copied into the next stage. eg: https://github.com/missinglink/pbf/blob/master/Dockerfile#L14 |
We could also drop the Go dependency in the final docker image since the go runtime is compiled into the binary? |
Oh yeah, a multistage build would work really well here. I'll take a look at that :) |
I don't remember exactly what requires CGO in In that case you'll need to have the headers installed at compile time, so like They are dynamically linked by default so the runtime image will need a compatible version of the shared link library (.so on Linux, .dylib on Mac), these often have a similarly named |
If you have any issues with shared libs you can run |
Cool, I think shared libraries will be fine. I confirmed by looking at |
I think it'll be fine since the baseimage will have I'm actually not sure off the top of my head what would happen if that file didn't exist in the runtime docker image. I'd assume it wouldn't even start the binary rather than erroring only on SQLite related functionality. |
The polylines Docker image is a bit of a large one currently, as it includes not just Node.js and a `node_modules` directory, but a full compiler toolchain, an install of the Go language, the dependencies of the `pbf` repository from https://github.com/missinglink/pbf, and the final `pbf` executable that comes from it. All told, this brought the total image size to a whopping 950MB uncompressed. This PR makes use of multi stage builds to run the compiling of the `pbf` executable in a separate container. After this, all the toolchain and dependencies needed can be thrown away, and only the small executable copied to the final image. Using `container-diff` it looks like the image size, uncompressed, after pelias/docker-baseimage#23 as well, will be only 322MB. That's a nice 600MB savings! Before pelias/docker-baseimage#23 the image size still drops to 500MB, still a healthy reduction. Replaces #262
Yup, it all worked out fine: #263 |
The polylines Docker image is a bit of a large one currently, as it includes not just Node.js and a `node_modules` directory, but a full compiler toolchain, an install of the Go language, the dependencies of the `pbf` repository from https://github.com/missinglink/pbf, and the final `pbf` executable that comes from it. All told, this brought the total image size to a whopping 950MB uncompressed. This PR makes use of multi stage builds to run the compiling of the `pbf` executable in a separate container. After this, all the toolchain and dependencies needed can be thrown away, and only the small executable copied to the final image. Using `container-diff` it looks like the image size, uncompressed, after pelias/docker-baseimage#23 as well, will be only 322MB. That's a nice 600MB savings! Before pelias/docker-baseimage#23 the image size still drops to 500MB, still a healthy reduction. Replaces #262
The polylines Docker image is a bit of a large one currently, as it includes not just Node.js and a `node_modules` directory, but a full compiler toolchain, an install of the Go language, the dependencies of the `pbf` repository from https://github.com/missinglink/pbf, and the final `pbf` executable that comes from it. All told, this brought the total image size to a whopping 950MB uncompressed. This PR makes use of multi stage builds to run the compiling of the `pbf` executable in a separate container. After this, all the toolchain and dependencies needed can be thrown away, and only the small executable copied to the final image. Using `container-diff` it looks like the image size, uncompressed, after pelias/docker-baseimage#23 as well, will be only 322MB. That's a nice 600MB savings! Before pelias/docker-baseimage#23 the image size still drops to 500MB, still a healthy reduction. Replaces #262
In pelias/docker-baseimage#23 we're leaning out our Docker baseimage used by all other Pelias images, and hopefully can remove the compiler toolchain all together.
The Polylines Docker images do need
gcc
(but not quite a full compiler toolchain), but didn't follow the convention in our other Dockerfiles of having anapt-get
step to install it.This PR adds such a step, and is a little clever in installing
gcc
only temporarily, and only for thego get
step that requires it.The polylines Docker image is already quite large (950MB uncompressed) since it includes Node.js, Go, and package dependencies for both. Skipping the installation of
gcc
cuts out 120MB of that.Until pelias/docker-baseimage#23 this change won't really have any impact on the size or operation of this Docker image.