From b51888943715dcb38cfc7ac6a76b8a56fc4d689c Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Mon, 19 Feb 2024 20:13:20 +0100 Subject: [PATCH] docker: Fix missing /tmp directory This caused issues in various areas where Pat (and/or dependencies) relied on os.TempDir() store temporary files. E.g. when running `pat updateforms`. We can't do this inside the build container, as there is no way of specifying file permissions when doing COPY --from. The solution (inspired by the distroless images) is to ADD a pre-prepared tarball with the correct file permissions. `mkdir -m 01777 tmp && tar --owner=root --group=root -cf tmp.tar tmp` --- .docker/tmp.tar | Bin 0 -> 10240 bytes Dockerfile | 2 ++ 2 files changed, 2 insertions(+) create mode 100644 .docker/tmp.tar diff --git a/.docker/tmp.tar b/.docker/tmp.tar new file mode 100644 index 0000000000000000000000000000000000000000..0ad2c6c7c05fe126f90449bcf95aa1c0b59e501a GIT binary patch literal 10240 zcmeIuyA8rH5CBk*;te=UHa8CgprBy(C#0kZ4e8!BC*9B1oA<}1oE#C+GP7*?6W@8S zwLY$WWJcfSTJ-3pj+6hjpMO2)ZLPJe%QBDN`_(_%)gwTF009C72oNAZfB*pk1PBly eK!5-N0t5&UAV7cs0RjXF5FkK+009Dj7I*^?dl60m literal 0 HcmV?d00001 diff --git a/Dockerfile b/Dockerfile index 79a78ef1..54622fbe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,8 @@ FROM scratch LABEL org.opencontainers.image.source=https://github.com/la5nta/pat LABEL org.opencontainers.image.description="Pat - A portable Winlink client for amateur radio email" LABEL org.opencontainers.image.licenses=MIT +# Make sure we have a /tmp directory with the correct permissions (01777) +ADD .docker/tmp.tar / COPY --from=builder /etc/ssl/certs /etc/ssl/certs COPY --from=builder /src/pat /bin/pat USER 65534:65534