2017-05-11 21:15:10 +00:00
|
|
|
FROM debian:jessie-slim as builder
|
2017-05-10 20:55:40 +00:00
|
|
|
|
2017-05-11 21:15:10 +00:00
|
|
|
ARG ARCH=x86_64
|
|
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
2017-05-10 20:55:40 +00:00
|
|
|
|
2017-05-12 10:50:24 +00:00
|
|
|
ARG GLIBC_VER=2.25
|
2017-05-12 00:30:49 +00:00
|
|
|
ARG BUSYB_VER=1.26.2
|
|
|
|
ARG SU_EXEC_VER=v0.2
|
|
|
|
ARG TINI_VER=v0.14.0
|
|
|
|
|
2017-05-11 21:15:10 +00:00
|
|
|
WORKDIR /output
|
2017-05-11 09:36:22 +00:00
|
|
|
|
2017-05-11 22:37:11 +00:00
|
|
|
#Set up our dependencies, configure the output filesystem a bit
|
2017-05-11 21:15:10 +00:00
|
|
|
RUN apt-get update -qy && \
|
2017-05-12 10:50:24 +00:00
|
|
|
apt-get install -qy curl build-essential gawk linux-libc-dev && \
|
2017-05-12 13:07:18 +00:00
|
|
|
mkdir -p usr/bin usr/sbin usr/lib dev proc root etc && \
|
2017-05-11 21:15:10 +00:00
|
|
|
ln -sv usr/bin bin && \
|
2017-05-12 13:07:18 +00:00
|
|
|
ln -sv usr/sbin sbin && \
|
2017-05-11 21:15:10 +00:00
|
|
|
ln -sv usr/lib lib && \
|
2017-05-12 10:49:40 +00:00
|
|
|
ln -sv usr/lib lib64
|
2017-05-11 22:37:11 +00:00
|
|
|
|
2017-05-12 00:30:49 +00:00
|
|
|
# Pull busybox and some other utilities
|
2017-05-12 13:07:18 +00:00
|
|
|
RUN curl -L https://busybox.net/downloads/binaries/$BUSYB_VER-defconfig-multiarch/busybox-$ARCH > bin/busybox && \
|
2017-05-12 12:43:42 +00:00
|
|
|
curl -L https://github.com/javabean/su-exec/releases/download/${SU_EXEC_VER}/su-exec.amd64 > sbin/su-exec && \
|
2017-05-12 13:07:18 +00:00
|
|
|
curl -L https://github.com/krallin/tini/releases/download/${TINI_VER}/tini-amd64 > sbin/tini && \
|
|
|
|
chmod +x bin/busybox sbin/su-exec sbin/tini
|
2017-05-11 23:34:57 +00:00
|
|
|
|
2017-05-10 20:55:40 +00:00
|
|
|
WORKDIR /tmp
|
|
|
|
|
2017-05-12 10:50:24 +00:00
|
|
|
ARG CFLAGS="-Os -pipe -fstack-protector-strong"
|
|
|
|
ARG LDFLAGS="-Wl,-O1,--sort-common -Wl,-s"
|
|
|
|
|
|
|
|
# Download and build glibc from source
|
|
|
|
RUN curl -L https://ftp.gnu.org/gnu/glibc/glibc-$GLIBC_VER.tar.xz | tar xJ && \
|
|
|
|
mkdir -p glibc-build && cd glibc-build && \
|
|
|
|
\
|
|
|
|
echo "slibdir=/lib" >> configparms && \
|
|
|
|
echo "rtlddir=/lib" >> configparms && \
|
|
|
|
echo "sbindir=/bin" >> configparms && \
|
|
|
|
echo "rootsbindir=/bin" >> configparms && \
|
|
|
|
\
|
|
|
|
rm -rf /usr/include/x86_64-linux-gnu/c++ && \
|
|
|
|
ln -sfv /usr/include/x86_64-linux-gnu/* /usr/include && \
|
|
|
|
../glibc-$GLIBC_VER/configure \
|
|
|
|
--prefix="$(pwd)/root" \
|
|
|
|
--libdir="$(pwd)/root/lib" \
|
|
|
|
--libexecdir=/lib \
|
|
|
|
--with-headers=/usr/include \
|
|
|
|
--enable-add-ons \
|
|
|
|
--enable-obsolete-rpc \
|
|
|
|
--enable-kernel=3.10.0 \
|
|
|
|
--enable-bind-now \
|
|
|
|
--disable-profile \
|
|
|
|
--enable-stackguard-randomization \
|
|
|
|
--enable-stack-protector=strong \
|
|
|
|
--enable-lock-elision \
|
|
|
|
--enable-multi-arch \
|
|
|
|
--disable-werror && \
|
|
|
|
make && make install_root=$(pwd)/out install
|
|
|
|
|
|
|
|
# Copy glibc libs & generate ld cache
|
|
|
|
RUN cp -r glibc-build/out/lib/*.so /output/lib && \
|
|
|
|
echo '/usr/lib' > /output/etc/ld.so.conf && \
|
|
|
|
ldconfig -r /output
|
|
|
|
|
2017-05-11 21:15:10 +00:00
|
|
|
# Build and install openssl
|
2017-05-11 22:37:11 +00:00
|
|
|
ARG DESTDIR=/output/libressl
|
2017-05-11 21:15:10 +00:00
|
|
|
RUN curl -L https://www.openssl.org/source/openssl-1.1.0e.tar.gz | \
|
|
|
|
tar xz -C /tmp --strip-components=1 && \
|
|
|
|
./config --prefix=/output && \
|
|
|
|
make install_sw && \
|
|
|
|
rm /output/lib/*.a && \
|
|
|
|
rm -r /output/include
|
|
|
|
|
|
|
|
# =============
|
|
|
|
|
|
|
|
FROM scratch
|
2017-05-10 20:55:40 +00:00
|
|
|
WORKDIR /
|
2017-05-11 23:34:57 +00:00
|
|
|
COPY --from=builder /output/ /
|
|
|
|
# Needed cos we dont have /bin/sh yet
|
|
|
|
RUN ["/bin/busybox", "--install", "-s", "/bin"]
|
2017-05-11 21:15:10 +00:00
|
|
|
CMD ["sh"]
|