From f3b575ead4c931e36a64b643f00c104ce80c5150 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 28 Aug 2024 10:35:21 -0700 Subject: [PATCH] Minor dockerfile optimizations (#240) * Replace build-essential in Docker builder image build-essential is overkill, it pulls in all of the tools one needs to make to build debian packages, which we are not doing. Even though this is a builder image, it still takes time to download all the extra crud. Replace build-essential with make gcc and g++, which are all that are needed. * Replace dev packages in final Docker image The dev packages are only needed in the builder image. They add header files and docs and things that are not needed in the final image. Removing them and replacing them with just the runtime libraries reduces the final image size by about 25% (160M->124M) in a local build. Additionally, just for simplicity, zlib1g is already part of base ubuntu minimal, so we don't even have to list it. * Remove build-essential mention from the README Just like the in Dockerfile, people don't need all of those packages to build directly on their system. --- Dockerfile | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d512627f..ba2e8e30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:22.04 AS tippecanoe-builder RUN apt-get update \ - && apt-get -y install build-essential libsqlite3-dev zlib1g-dev + && apt-get -y install make gcc g++ libsqlite3-dev zlib1g-dev COPY . /tmp/tippecanoe-src WORKDIR /tmp/tippecanoe-src @@ -13,7 +13,7 @@ CMD make test # Using multistage build reduces the docker image size by alot by only copying the needed binaries FROM ubuntu:22.04 RUN apt-get update \ - && apt-get -y install libsqlite3-dev zlib1g-dev \ + && apt-get -y install libsqlite3-0 \ && rm -rf /var/lib/apt/lists/* COPY --from=tippecanoe-builder /tmp/tippecanoe-src/tippecanoe* /usr/local/bin/ COPY --from=tippecanoe-builder /tmp/tippecanoe-src/tile-join /usr/local/bin/ diff --git a/README.md b/README.md index 5f620fb7..b58978a9 100644 --- a/README.md +++ b/README.md @@ -707,7 +707,7 @@ uses md2man (`gem install md2man`). Linux: - sudo apt-get install build-essential libsqlite3-dev zlib1g-dev + sudo apt-get install gcc g++ make libsqlite3-dev zlib1g-dev Then build: