From fdb6b6be3f96314b22347087f383c0c79109aa02 Mon Sep 17 00:00:00 2001 From: Sah Date: Tue, 27 Mar 2018 13:44:01 +0200 Subject: [PATCH 1/2] Docker: optimize image size --- .dockerignore | 2 ++ docker/alpine/Dockerfile | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.dockerignore b/.dockerignore index 678587f8..83f2dee6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,7 @@ # General .dockerignore +.git +.gitmodules .gitignore .github AUTHORS diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index d032f257..b10b3557 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -13,22 +13,21 @@ ENV DNS_ADDR 8.8.8.8 ENV DNS_ADDR_2 8.8.4.4 ENV ARGS= -COPY . /tmp +COPY . /tmp/repo RUN set -ex && \ apk add --no-cache --virtual .build-deps \ - git \ autoconf \ automake \ - libtool \ build-base \ + c-ares-dev \ libev-dev \ - linux-headers \ + libtool \ libsodium-dev \ + linux-headers \ mbedtls-dev \ - pcre-dev \ - c-ares-dev && \ - cd /tmp && \ + pcre-dev && \ + cd /tmp/repo && \ ./autogen.sh && \ ./configure --prefix=/usr --disable-documentation && \ make install && \ @@ -43,7 +42,7 @@ RUN set -ex && \ rng-tools \ $runDeps && \ apk del .build-deps && \ - rm -rf /tmp/* + rm -rf /tmp/repo USER nobody From d70bba28f88cace894556351ee24886f43250a45 Mon Sep 17 00:00:00 2001 From: Sah Date: Tue, 27 Mar 2018 14:58:46 +0200 Subject: [PATCH 2/2] Docker: Dockerfile improvements - Format adjustments - Fix error: missing runtime dependencies --- docker/alpine/Dockerfile | 76 +++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index b10b3557..0de4a0b1 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -14,47 +14,45 @@ ENV DNS_ADDR_2 8.8.4.4 ENV ARGS= COPY . /tmp/repo - -RUN set -ex && \ - apk add --no-cache --virtual .build-deps \ - autoconf \ - automake \ - build-base \ - c-ares-dev \ - libev-dev \ - libtool \ - libsodium-dev \ - linux-headers \ - mbedtls-dev \ - pcre-dev && \ - cd /tmp/repo && \ - ./autogen.sh && \ - ./configure --prefix=/usr --disable-documentation && \ - make install && \ - - runDeps="$( \ - scanelf --needed --nobanner /usr/bin/ss-* \ - | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ - | xargs -r apk info --installed \ - | sort -u \ - )" && \ - apk add --no-cache --virtual .run-deps \ - rng-tools \ - $runDeps && \ - apk del .build-deps && \ - rm -rf /tmp/repo +RUN set -ex \ + # Build environment setup + && apk add --no-cache --virtual .build-deps \ + autoconf \ + automake \ + build-base \ + c-ares-dev \ + libev-dev \ + libtool \ + libsodium-dev \ + linux-headers \ + mbedtls-dev \ + pcre-dev \ + # Build & install + && cd /tmp/repo \ + && ./autogen.sh \ + && ./configure --prefix=/usr --disable-documentation \ + && make install \ + && apk del .build-deps \ + # Runtime dependencies setup + && apk add --no-cache \ + rng-tools \ + $(scanelf --needed --nobanner /usr/bin/ss-* \ + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ + | sort -u) \ + && rm -rf /tmp/repo USER nobody EXPOSE 8388/tcp 8388/udp -CMD ss-server -s $SERVER_ADDR \ - -p 8388 \ - -k ${PASSWORD:-$(hostname)} \ - -m $METHOD \ - -t $TIMEOUT \ - --fast-open \ - -d $DNS_ADDR \ - -d $DNS_ADDR_2 \ - -u \ - $ARGS +CMD exec ss-server \ + -s $SERVER_ADDR \ + -p 8388 \ + -k ${PASSWORD:-$(hostname)} \ + -m $METHOD \ + -t $TIMEOUT \ + --fast-open \ + -d $DNS_ADDR \ + -d $DNS_ADDR_2 \ + -u \ + $ARGS