From d53e4f45ab2e6d2902a1eaeee338795c6b85c492 Mon Sep 17 00:00:00 2001 From: lxsang Date: Sat, 27 Mar 2021 16:32:30 +0100 Subject: [PATCH] Reduce image size usinb busybox image --- Dockerfile | 31 ++++++++++++++++++++++++------- start.sh | 2 +- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index c0eb11a..8ec7321 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.9 AS build-env +FROM ubuntu:focal AS build-env -RUN apk add build-base make sqlite-dev zlib-dev readline-dev nodejs npm openssl-dev +RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get --yes --no-install-recommends install build-essential make libsqlite3-dev zlib1g-dev libreadline-dev nodejs npm libssl-dev COPY download /download RUN cd /download/antd-1.0.6b && ./configure --prefix=/usr/ && make && make install RUN cd /download/lua-0.5.2b && ./configure --prefix=/opt/www && make && make install @@ -13,15 +13,32 @@ RUN cd /download/antd-publishers-0.1.0a && ./configure --prefix=/opt/www && mak RUN mkdir -p /opt/www/htdocs RUN cd /download/antd-web-apps && BUILDDIR=/opt/www/htdocs PROJS=os make RUN rm /opt/www/htdocs/index.ls +RUN npm config set strict-ssl false RUN cd /download/antos && npm install terser uglifycss typescript -g && npm install @types/jquery && BUILDDIR=/opt/www/htdocs/os make release -FROM alpine:3.9 -RUN apk add --no-cache sqlite-dev zlib readline openssl curl +FROM ubuntu:focal AS deploy-env +RUN apt-get update && apt-get --yes --no-install-recommends install libsqlite3-0 zlib1g libreadline8 libssl1.1 +RUN apt clean && rm -rf /var/lib/apt/lists/* +RUN mkdir /ulib +RUN cp -rf /lib/*-linux-*/libsqlite3* /ulib +RUN cp -rf /lib/*-linux-*/libreadline* /ulib +RUN cp -rf /lib/*-linux-*/libncurse* /ulib +RUN cp -rf /lib/*-linux-*/libz* /ulib +RUN cp -rf /lib/*-linux-*/libcrypt* /ulib +RUN cp -rf /lib/*-linux-*/libdl* /ulib +RUN cp -rf /lib/*-linux-*/libm* /ulib +RUN cp -rf /lib/*-linux-*/libpthread* /ulib +RUN cp -rf /lib/*-linux-*/libssl* /ulib +RUN cp -rf /lib/*-linux-*/libc* /ulib +RUN cp -rf /lib/*-linux-*/libgcc* /ulib +RUN cp -rf /lib/*-linux-*/ld* /ulib -COPY start.sh /start.sh -RUN chmod 700 /start.sh +FROM busybox:stable-glibc +#copy all necessary libraries +COPY --from=deploy-env /ulib/* /lib/ COPY --from=build-env /usr/bin/antd /usr/bin/antd COPY --from=build-env /usr/lib/libantd* /usr/lib/ COPY --from=build-env /opt/www /opt/www +COPY start.sh /start.sh +RUN chmod 700 /start.sh ENTRYPOINT /start.sh -# ENTRYPOINT /bin/sh diff --git a/start.sh b/start.sh index 1f26d29..e74cdc2 100755 --- a/start.sh +++ b/start.sh @@ -8,7 +8,7 @@ mkdir -p /app/data/database mkdir -p /app/data/tmp [ ! -e "/home/$ANTOS_USER" ] && ln -sf /app/data/home "/home/$ANTOS_USER" adduser --home "/home/$ANTOS_USER" --disabled-password --gecos "" "$ANTOS_USER" -echo -e "$ANTOS_PASSWORD\n$ANTOS_PASSWORD" | passwd "$ANTOS_USER" +echo "$ANTOS_USER:$ANTOS_PASSWORD" | /bin/chpasswd # start antd-tunnel service /usr/bin/antd /app/antd-config.ini & sleep 1