forked from yugabyte/pgloader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Dockerfiles/docker image size (dimitri#821)
* Add dockerfiles to .dockerignore Otherwise changes in the dockerfiles would invalidate the cache * Rewrite Dockerfile - Fix deprecated MAINTAINER instruction - Move maintainer label to the bottom (improving cache) - Tidy up apt-get - Use COPY instead of ADD see https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy - Remove WORKDIR instruction (we don't really need this) - Combine remaining RUN layers to reduce layer count - Move final binary instead of copying (reduce image size) * Use -slim image an multistage build Reduce size by using multistage builds and the -slim image. Use debian:stable instead of an specific code name (future proof). * [cosmetic] indent Dockerfile instructions Make it easier to see where a new build stage begins * Rewrite Dockerfile.ccl Apply the same changes to Dockerfile.ccl as we did for Dockerfile
- Loading branch information
1 parent
5ca3ee8
commit 34cc253
Showing
3 changed files
with
92 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.git | ||
.vagrant | ||
build | ||
Dockerfile | ||
Dockerfile.ccl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,45 @@ | ||
FROM debian:stretch | ||
MAINTAINER Dimitri Fontaine <dim@tapoueh.org> | ||
FROM debian:stable-slim as builder | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
wget curl make git bzip2 time \ | ||
ca-certificates \ | ||
libzip-dev libssl1.1 openssl \ | ||
patch unzip libsqlite3-dev gawk \ | ||
freetds-dev sbcl && \ | ||
rm -rf /var/lib/apt/lists/* | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
bzip2 \ | ||
ca-certificates \ | ||
curl \ | ||
freetds-dev \ | ||
gawk \ | ||
git \ | ||
libsqlite3-dev \ | ||
libssl1.1 \ | ||
libzip-dev \ | ||
make \ | ||
openssl \ | ||
patch \ | ||
sbcl \ | ||
time \ | ||
unzip \ | ||
wget \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ADD ./ /opt/src/pgloader | ||
WORKDIR /opt/src/pgloader | ||
COPY ./ /opt/src/pgloader | ||
|
||
# build/ is in the .dockerignore file, but we actually need it now | ||
RUN mkdir -p build/bin | ||
RUN make | ||
RUN mkdir -p /opt/src/pgloader/build/bin \ | ||
&& cd /opt/src/pgloader \ | ||
&& make | ||
|
||
RUN cp /opt/src/pgloader/build/bin/pgloader /usr/local/bin | ||
FROM debian:stable-slim | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
curl \ | ||
freetds-dev \ | ||
gawk \ | ||
libsqlite3-dev \ | ||
libzip-dev \ | ||
make \ | ||
sbcl \ | ||
unzip \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=builder /opt/src/pgloader/build/bin/pgloader /usr/local/bin | ||
|
||
LABEL maintainer="Dimitri Fontaine <dim@tapoueh.org>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,49 @@ | ||
FROM debian:stretch | ||
MAINTAINER Dimitri Fontaine <dim@tapoueh.org> | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
wget curl make git bzip2 time \ | ||
ca-certificates \ | ||
libzip-dev libssl1.1 openssl \ | ||
patch unzip libsqlite3-dev gawk \ | ||
freetds-dev sbcl && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /usr/local/src | ||
RUN curl --location -O https://github.com/Clozure/ccl/releases/download/v1.11.5/ccl-1.11.5-linuxx86.tar.gz | ||
RUN tar xf ccl-1.11.5-linuxx86.tar.gz | ||
RUN cp /usr/local/src/ccl/scripts/ccl64 /usr/local/bin/ccl | ||
|
||
ADD ./ /opt/src/pgloader | ||
WORKDIR /opt/src/pgloader | ||
|
||
# build/ is in the .dockerignore file, but we actually need it now | ||
RUN mkdir -p build/bin | ||
RUN make CL=ccl DYNSIZE=256 | ||
|
||
RUN cp /opt/src/pgloader/build/bin/pgloader /usr/local/bin | ||
FROM debian:stable-slim as builder | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
bzip2 \ | ||
ca-certificates \ | ||
curl \ | ||
freetds-dev \ | ||
gawk \ | ||
git \ | ||
libsqlite3-dev \ | ||
libssl1.1 \ | ||
libzip-dev \ | ||
make \ | ||
openssl \ | ||
patch \ | ||
sbcl \ | ||
time \ | ||
unzip \ | ||
wget \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl -SL https://github.com/Clozure/ccl/releases/download/v1.11.5/ccl-1.11.5-linuxx86.tar.gz \ | ||
| tar xz -C /usr/local/src/ \ | ||
&& mv /usr/local/src/ccl/scripts/ccl64 /usr/local/bin/ccl | ||
|
||
COPY ./ /opt/src/pgloader | ||
|
||
RUN mkdir -p /opt/src/pgloader/build/bin \ | ||
&& cd /opt/src/pgloader \ | ||
&& make CL=ccl DYNSIZE=256 | ||
|
||
FROM debian:stable-slim | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
curl \ | ||
freetds-dev \ | ||
gawk \ | ||
libsqlite3-dev \ | ||
libzip-dev \ | ||
make \ | ||
sbcl \ | ||
unzip \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=builder /opt/src/pgloader/build/bin/pgloader /usr/local/bin | ||
|
||
LABEL maintainer="Dimitri Fontaine <dim@tapoueh.org>" |