From 1b2c45040a4e3fe0093497620437c386806ccfe1 Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Sun, 8 Dec 2019 18:32:33 +0800 Subject: [PATCH] Dockerfile: use multi-stage build --- Dockerfile | 40 ++++++---------------------------------- Dockerfile-alpine | 15 +++++++-------- 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8da1698..493cfaf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,9 @@ -FROM ubuntu:16.04 -LABEL maintainer "Shuanglei Tao - tsl0922@gmail.com" +FROM tsl0922/musl-cross +RUN git clone --depth=1 https://github.com/tsl0922/ttyd.git /tmp/ttyd \ + && cd /tmp/ttyd && ./scripts/cross-build.sh x86_64 -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - g++ \ - git \ - libjson-c2 \ - libjson-c-dev \ - libssl1.0.0 \ - libssl-dev \ - libwebsockets7 \ - libwebsockets-dev \ - pkg-config \ - vim-common \ - && git clone --depth=1 https://github.com/tsl0922/ttyd.git /tmp/ttyd \ - && cd /tmp/ttyd && mkdir build && cd build \ - && cmake -DCMAKE_BUILD_TYPE=RELEASE .. \ - && make \ - && make install \ - && apt-get remove -y --purge \ - cmake \ - g++ \ - libwebsockets-dev \ - libjson-c-dev \ - libssl-dev \ - pkg-config \ - && apt-get purge -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ - && rm -rf /tmp/ttyd +FROM ubuntu:18.04 +COPY --from=0 /tmp/ttyd/build/ttyd /usr/local/bin/ttyd ENV TINI_VERSION v0.18.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini @@ -40,4 +12,4 @@ RUN chmod +x /tini EXPOSE 7681 ENTRYPOINT ["/tini", "--"] -CMD ["ttyd", "bash"] +CMD ["ttyd", "sh"] diff --git a/Dockerfile-alpine b/Dockerfile-alpine index f5964d8..168b0cd 100644 --- a/Dockerfile-alpine +++ b/Dockerfile-alpine @@ -1,13 +1,12 @@ -FROM alpine:3.9 -LABEL maintainer "Shuanglei Tao - tsl0922@gmail.com" \ - maintainer "Damien Duportal - damien.duportal@gmail.com" +FROM tsl0922/musl-cross +RUN git clone --depth=1 https://github.com/tsl0922/ttyd.git /tmp/ttyd \ + && cd /tmp/ttyd && ./scripts/cross-build.sh x86_64 -RUN apk add --no-cache \ - bash \ - tini \ - ttyd +FROM alpine:3.9 +COPY --from=0 /tmp/ttyd/build/ttyd /usr/local/bin/ttyd +RUN apk add --no-cache tini EXPOSE 7681 ENTRYPOINT ["/sbin/tini", "--"] -CMD ["ttyd", "bash"] +CMD ["ttyd", "sh"] -- 2.43.4