From d1f1772d7491f36cfeb272e64435ac3e122dfee8 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 13 May 2024 03:48:29 +0200 Subject: [PATCH] build: Optimize Dockerfile (#729) --- Dockerfile | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 83f88e0..99b59f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,12 +10,14 @@ FROM qemux/qemu-host:2.04 as builder FROM debian:trixie-slim ARG TARGETPLATFORM -ARG DEBCONF_NOWARNINGS "yes" -ARG DEBIAN_FRONTEND "noninteractive" -ARG DEBCONF_NONINTERACTIVE_SEEN "true" +ARG VERSION_ARG="0.0" +ARG DEBCONF_NOWARNINGS="yes" +ARG DEBIAN_FRONTEND="noninteractive" +ARG DEBCONF_NONINTERACTIVE_SEEN="true" -RUN if [ "$TARGETPLATFORM" != "linux/amd64" ]; then extra="qemu-user"; fi && \ +RUN set -eu && \ apt-get update && \ + if [ "$TARGETPLATFORM" != "linux/amd64" ]; then extra="qemu-user"; fi && \ apt-get --no-install-recommends -y install \ jq \ tini \ @@ -41,14 +43,13 @@ RUN if [ "$TARGETPLATFORM" != "linux/amd64" ]; then extra="qemu-user"; fi && \ apt-get clean && \ unlink /etc/nginx/sites-enabled/default && \ sed -i 's/^worker_processes.*/worker_processes 1;/' /etc/nginx/nginx.conf && \ + echo "$VERSION_ARG" > /run/version && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -COPY ./src /run/ -COPY ./web /var/www/ -COPY --from=builder /qemu-host.bin /run/host.bin - -RUN chmod +x /run/*.sh && chmod +x /run/*.bin -RUN mv /var/www/nginx.conf /etc/nginx/sites-enabled/web.conf +COPY --chmod=755 ./src /run/ +COPY --chmod=755 ./web /var/www/ +COPY --chmod=755 --from=builder /qemu-host.bin /run/host.bin +COPY --chmod=744 ./web/nginx.conf /etc/nginx/sites-enabled/web.conf VOLUME /storage EXPOSE 22 139 445 5000 @@ -57,9 +58,6 @@ ENV RAM_SIZE "1G" ENV DISK_SIZE "16G" ENV CPU_CORES "1" -ARG VERSION_ARG "0.0" -RUN echo "$VERSION_ARG" > /run/version - HEALTHCHECK --interval=60s --start-period=45s --retries=2 CMD /run/check.sh ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entry.sh"]