Dockerfile: use multi-stage build

This commit is contained in:
Shuanglei Tao
2019-12-08 18:32:33 +08:00
parent c6248d1e6a
commit 1b2c45040a
2 changed files with 13 additions and 42 deletions

View File

@@ -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"]

View File

@@ -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"]