From: Shuanglei Tao Date: Sun, 8 Dec 2019 10:32:33 +0000 (+0800) Subject: Dockerfile: use multi-stage build X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=1b2c45040a4e3fe0093497620437c386806ccfe1;p=ttyd.git Dockerfile: use multi-stage build --- 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"]