From 6e4dec556ea6856c542d87208d54ed9874141077 Mon Sep 17 00:00:00 2001 From: Aaron Dewes Date: Fri, 18 Dec 2020 15:25:13 +0100 Subject: [PATCH] Fix & Optimize Dockerfile --- Dockerfile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f895f7..2143ba8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,11 @@ +FROM alpine:latest AS perms + +# This is a bit weird, but required to make sure the LND data can be accessed. +RUN adduser --disabled-password \ + --home "/lndhub" \ + --gecos "" \ + "lndhub" + FROM node:buster-slim AS builder # These packages are required for building LNDHub @@ -13,7 +21,7 @@ RUN npm i FROM node:buster-slim # Create a specific user so LNDHub doesn't run as root -RUN adduser --disabled-password --uid 1000 --home /lndhub --gecos "" lndhub +COPY --from=perms /etc/group /etc/passwd /etc/shadow /etc/ # Copy LNDHub with installed modules from builder COPY --from=builder /lndhub /lndhub @@ -22,7 +30,7 @@ COPY --from=builder /lndhub /lndhub RUN rm -rf .git # Create logs folder and ensure permissions are set correctly -RUN mkdir /lndhub/logs && chown -R lndhun:lndhub /lndhub +RUN mkdir /lndhub/logs && chown -R lndhub:lndhub /lndhub USER lndhub