From ff0b1127287d86d795c5e9530a4557c6685b0cda Mon Sep 17 00:00:00 2001 From: Suresh Sundriyal <247110+sureshsundriyal@users.noreply.github.com> Date: Sun, 9 Jul 2023 09:11:00 -0700 Subject: [PATCH] [build] Optimize the Dockerfile Optimize the Dockerfile according to the best practices described here: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ --- .github/actions/muslbuilder/Dockerfile | 188 ++++++++++++++----------- 1 file changed, 104 insertions(+), 84 deletions(-) diff --git a/.github/actions/muslbuilder/Dockerfile b/.github/actions/muslbuilder/Dockerfile index 78ca2be7..5caa24c9 100644 --- a/.github/actions/muslbuilder/Dockerfile +++ b/.github/actions/muslbuilder/Dockerfile @@ -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"]