mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-07 14:56:59 +02:00
Improved Dockerfiles/docker image size (#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
This commit is contained in:
parent
5ca3ee8aad
commit
34cc25383a
@ -1,3 +1,5 @@
|
|||||||
.git
|
.git
|
||||||
.vagrant
|
.vagrant
|
||||||
build
|
build
|
||||||
|
Dockerfile
|
||||||
|
Dockerfile.ccl
|
57
Dockerfile
57
Dockerfile
@ -1,20 +1,45 @@
|
|||||||
FROM debian:stretch
|
FROM debian:stable-slim as builder
|
||||||
MAINTAINER Dimitri Fontaine <dim@tapoueh.org>
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update \
|
||||||
apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
wget curl make git bzip2 time \
|
bzip2 \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
libzip-dev libssl1.1 openssl \
|
curl \
|
||||||
patch unzip libsqlite3-dev gawk \
|
freetds-dev \
|
||||||
freetds-dev sbcl && \
|
gawk \
|
||||||
rm -rf /var/lib/apt/lists/*
|
git \
|
||||||
|
libsqlite3-dev \
|
||||||
|
libssl1.1 \
|
||||||
|
libzip-dev \
|
||||||
|
make \
|
||||||
|
openssl \
|
||||||
|
patch \
|
||||||
|
sbcl \
|
||||||
|
time \
|
||||||
|
unzip \
|
||||||
|
wget \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
ADD ./ /opt/src/pgloader
|
COPY ./ /opt/src/pgloader
|
||||||
WORKDIR /opt/src/pgloader
|
|
||||||
|
|
||||||
# build/ is in the .dockerignore file, but we actually need it now
|
RUN mkdir -p /opt/src/pgloader/build/bin \
|
||||||
RUN mkdir -p build/bin
|
&& cd /opt/src/pgloader \
|
||||||
RUN make
|
&& 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>"
|
@ -1,25 +1,49 @@
|
|||||||
FROM debian:stretch
|
FROM debian:stable-slim as builder
|
||||||
MAINTAINER Dimitri Fontaine <dim@tapoueh.org>
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update \
|
||||||
apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
wget curl make git bzip2 time \
|
bzip2 \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
libzip-dev libssl1.1 openssl \
|
curl \
|
||||||
patch unzip libsqlite3-dev gawk \
|
freetds-dev \
|
||||||
freetds-dev sbcl && \
|
gawk \
|
||||||
rm -rf /var/lib/apt/lists/*
|
git \
|
||||||
|
libsqlite3-dev \
|
||||||
|
libssl1.1 \
|
||||||
|
libzip-dev \
|
||||||
|
make \
|
||||||
|
openssl \
|
||||||
|
patch \
|
||||||
|
sbcl \
|
||||||
|
time \
|
||||||
|
unzip \
|
||||||
|
wget \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /usr/local/src
|
RUN curl -SL https://github.com/Clozure/ccl/releases/download/v1.11.5/ccl-1.11.5-linuxx86.tar.gz \
|
||||||
RUN curl --location -O https://github.com/Clozure/ccl/releases/download/v1.11.5/ccl-1.11.5-linuxx86.tar.gz
|
| tar xz -C /usr/local/src/ \
|
||||||
RUN tar xf ccl-1.11.5-linuxx86.tar.gz
|
&& mv /usr/local/src/ccl/scripts/ccl64 /usr/local/bin/ccl
|
||||||
RUN cp /usr/local/src/ccl/scripts/ccl64 /usr/local/bin/ccl
|
|
||||||
|
|
||||||
ADD ./ /opt/src/pgloader
|
COPY ./ /opt/src/pgloader
|
||||||
WORKDIR /opt/src/pgloader
|
|
||||||
|
|
||||||
# build/ is in the .dockerignore file, but we actually need it now
|
RUN mkdir -p /opt/src/pgloader/build/bin \
|
||||||
RUN mkdir -p build/bin
|
&& cd /opt/src/pgloader \
|
||||||
RUN make CL=ccl DYNSIZE=256
|
&& make CL=ccl DYNSIZE=256
|
||||||
|
|
||||||
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>"
|
Loading…
Reference in New Issue
Block a user