[build] Optimize the Dockerfile

Optimize the Dockerfile according to the best practices described here:
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
pull/1179/head
Suresh Sundriyal 11 months ago
parent 8628bba7e5
commit ff0b112728

@ -8,6 +8,7 @@ LABEL com.github.actions.color="orange"
RUN apk update && apk add --no-cache \
build-base \
binutils \
curl \
m4 \
git \
make \
@ -36,19 +37,9 @@ RUN apk update && apk add --no-cache \
libunwind-static \
linux-headers
ADD https://www.libarchive.org/downloads/libarchive-3.6.2.tar.gz /
ADD https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz /
ADD https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.gz /
ADD https://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz /
ADD https://zlib.net/zlib-1.2.13.tar.gz /
ADD https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz /
ADD https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz /
ADD https://www.openssl.org/source/openssl-1.0.2n.tar.gz /
ADD https://www.libssh2.org/download/libssh2-1.11.0.tar.gz /
ADD https://curl.se/download/curl-8.1.2.tar.gz /
ADD https://tukaani.org/xz/xz-5.4.3.tar.gz /
RUN mkdir -p /fake.root /packages /extract
RUN mkdir -p /fake.root /extract
ENV SQLITE_CFLAGS="\
-DSQLITE_ENABLE_COLUMN_METADATA \
-DSQLITE_SOUNDEX \
@ -82,78 +73,107 @@ xterm,\
xterm-256color\
"
RUN cd /extract && for pkg in /*.tar.gz; do tar xvfz "$pkg"; done
RUN cd /extract/bzip2-1.0.8 && make install PREFIX=/fake.root && make clean
RUN cd /extract/zlib-* && ./configure --prefix=/fake.root && make -j2 && make install && make clean
RUN cd /extract/xz-* && \
./configure --prefix=/fake.root \
--disable-shared \
"LDFLAGS=-L/fake.root/lib" \
"CPPFLAGS=-I/fake.root/include" \
&& \
make -j2 && \
make install && make clean
RUN cd /extract/libarchive-* && \
./configure --prefix=/fake.root \
--disable-shared \
"LDFLAGS=-L/fake.root/lib" \
"CPPFLAGS=-I/fake.root/include" \
&& \
make -j2 && \
make install && make clean
RUN cd /extract/readline-* && ./configure --prefix=/fake.root && make -j2 && make install && make clean
RUN cd /extract/sqlite-* && \
./configure --disable-editline --prefix=/fake.root \
CFLAGS="${SQLITE_CFLAGS}" \
&& \
make -j2 && make install && make clean
RUN cd /extract/openssl-* && \
./config --prefix=/fake.root -fPIC && \
make -j2 && \
make install && make clean
RUN cd /extract/ncurses-* && \
./configure --prefix=/fake.root \
--enable-ext-mouse \
--enable-sigwinch \
--with-default-terminfo-dir=/usr/share/terminfo \
--enable-ext-colors \
--enable-widec \
--enable-termcap \
--with-fallbacks=$NCURSES_FALLBACKS \
&& \
make -j2 && make install && make clean
RUN cd /extract/pcre2-* && \
./configure --prefix=/fake.root \
--enable-jit \
RUN curl -sSL https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz | tar xvzC /extract/ && \
cd /extract/bzip* && \
make install PREFIX=/fake.root && \
cd /extract && rm -rf *
RUN curl -sSL https://zlib.net/zlib-1.2.13.tar.gz | tar xvzC /extract/ && \
cd /extract/zlib-* && ./configure --prefix=/fake.root && \
make -j2 && \
make install && \
cd /extract && rm -rf *
RUN curl -sSL https://tukaani.org/xz/xz-5.4.3.tar.gz | tar xvzC /extract/ && \
cd /extract/xz-* && \
./configure --prefix=/fake.root \
--disable-shared \
"LDFLAGS=-L/fake.root/lib" \
"CPPFLAGS=-I/fake.root/include" \
&& \
make -j2 && \
make install && \
cd /extract && rm -rf *
RUN curl -sSL https://www.libarchive.org/downloads/libarchive-3.6.2.tar.gz | tar xvzC /extract/ && \
cd /extract/libarchive-* && \
./configure --prefix=/fake.root \
--disable-shared \
"LDFLAGS=-L/fake.root/lib" \
"CPPFLAGS=-I/fake.root/include" \
&& \
make -j2 && \
make install && \
cd /extract && rm -rf *
RUN curl -sSL https://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz | tar xvzC /extract/ && \
cd /extract/readline-* && \
./configure --prefix=/fake.root && \
make -j2 && \
make install && \
cd /extract && rm -rf *
RUN curl -sSL https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz | tar xvzC /extract/ && \
cd /extract/sqlite-* && \
./configure --disable-editline --prefix=/fake.root \
CFLAGS="${SQLITE_CFLAGS}" \
&& \
make -j2 && \
make install && \
cd /extract && rm -rf *
RUN curl -sSL https://www.openssl.org/source/openssl-1.0.2n.tar.gz | tar xvzC /extract/ && \
cd /extract/openssl-* && \
./config --prefix=/fake.root -fPIC && \
make -j2 && \
make install && \
cd /extract && rm -rf *
RUN curl -sSL https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz | tar xvzC /extract/ && \
cd /extract/ncurses-* && \
./configure --prefix=/fake.root \
--enable-ext-mouse \
--enable-sigwinch \
--with-default-terminfo-dir=/usr/share/terminfo \
--enable-ext-colors \
--enable-widec \
--enable-termcap \
--with-fallbacks=$NCURSES_FALLBACKS \
&& \
make -j2 && \
make install && \
cd /extract && rm -rf *
RUN curl -sSL https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.gz | tar xvzC /extract/ && \
cd /extract/pcre2-* && \
./configure --prefix=/fake.root \
--enable-jit \
&& \
make -j2 && make install && make clean
RUN cd /extract/libssh2-* && \
./configure --prefix=/fake.root \
--with-libssl-prefix=/fake.root \
--with-libz-prefix=/fake.root \
"CPPFLAGS=-I/fake.root/include" \
"LDFLAGS=-ldl -L/fake.root/lib" && \
make -j2 && \
make install && make clean
RUN cd /extract/curl-* && \
./configure --prefix=/fake.root \
--with-libssh2=/fake.root \
--with-ssl=/fake.root \
--with-zlib=/fake.root \
"LDFLAGS=-ldl" && \
make -j2 && \
make install && make clean
make -j2 && \
make install && \
cd /extract && rm -rf *
RUN curl -sSL https://www.libssh2.org/download/libssh2-1.11.0.tar.gz | tar xvzC /extract/ && \
cd /extract/libssh2-* && \
./configure --prefix=/fake.root \
--with-libssl-prefix=/fake.root \
--with-libz-prefix=/fake.root \
"CPPFLAGS=-I/fake.root/include" \
"LDFLAGS=-ldl -L/fake.root/lib" && \
make -j2 && \
make install && \
cd /extract && rm -rf *
RUN curl -sSL https://curl.se/download/curl-8.1.2.tar.gz | tar xvzC /extract/ && \
cd /extract/curl-* && \
./configure --prefix=/fake.root \
--with-libssh2=/fake.root \
--with-ssl=/fake.root \
--with-zlib=/fake.root \
"LDFLAGS=-ldl" && \
make -j2 && \
make install && \
cd /extract && rm -rf *
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

Loading…
Cancel
Save