From cbedc9d3c9cf25808b77c7b147fa89300769305d Mon Sep 17 00:00:00 2001 From: Elegant Date: Tue, 27 Aug 2024 13:43:37 +0900 Subject: [PATCH] build(docker): reduce dependencies --- Dockerfile | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9fe3896c..c3832ac8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,26 +41,11 @@ FROM alpine:3.20 AS build-sysroot WORKDIR /root # Fetch runtime dependencies -RUN apk --no-cache add \ - binutils \ +RUN mkdir -p /sysroot/etc/apk && cp -r /etc/apk/* /sysroot/etc/apk/ +RUN apk add --no-cache --initdb -p /sysroot \ + alpine-baselayout \ + busybox \ ca-certificates \ - curl \ - ncurses-terminfo-base - -# Install rTorrent and dependencies to new system root -RUN mkdir -p /root/sysroot/etc/ssl/certs -COPY --from=build /root/rtorrent/dist/rtorrent-deb.deb . -RUN ar -xv rtorrent-deb.deb -RUN tar xvf data.tar.* -C /root/sysroot/ - -RUN mkdir -p /root/sysroot/download /root/sysroot/session /root/sysroot/watch - -FROM alpine:3.20 AS rtorrent - -RUN apk --no-cache add \ - binutils \ - ca-certificates \ - jq \ mktorrent \ ncurses-terminfo-base \ tini \ @@ -69,8 +54,16 @@ RUN apk --no-cache add \ && apk --no-cache upgrade \ -X https://dl-cdn.alpinelinux.org/alpine/v3.14/main \ unrar +RUN rm -rf /sysroot/etc/apk /sysroot/lib/apk /sysroot/var/cache + +# Install rTorrent to new system root +RUN mkdir -p /sysroot/etc/rtorrent /sysroot/download /sysroot/session /sysroot/watch +COPY --from=build /root/rtorrent/dist/rtorrent /sysroot/usr/local/bin +COPY doc/rtorrent.rc /sysroot/etc/rtorrent + +FROM scratch AS rtorrent -COPY --from=build-sysroot /root/sysroot / +COPY --from=build-sysroot /sysroot / EXPOSE 5000