Skip to content

Commit 5ee6e8c

Browse files
committed
chore: 🤖 run as non-root
1 parent 5d38810 commit 5ee6e8c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

‎Dockerfile

+14-7
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,35 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
2828

2929
FROM ubuntu:latest
3030
ARG LIGHTNING_PORTS="4200-4299 4300-4399"
31-
WORKDIR /root
31+
ARG USERNAME="lgtn"
32+
WORKDIR /home/$USERNAME
3233
SHELL ["/bin/bash", "-c"]
3334

3435
RUN apt-get update && \
3536
apt-get install -y \
3637
libssl-dev \
37-
ca-certificates
38+
ca-certificates \
39+
curl
3840

3941
COPY --from=build /build/lightning-node /usr/local/bin/lgtn
4042

41-
COPY <<EOF /root/init
43+
RUN useradd -Um $USERNAME
44+
45+
COPY <<EOF /home/$USERNAME/init
4246
#!/usr/bin/bash
4347

44-
if [[ ! -d /root/.lightning/keystore ]]; then
48+
if [[ ! -d /home/$USERNAME/.lightning/keystore ]]; then
4549
lgtn keys generate
4650
fi
4751

48-
lgtn -vv run
52+
lgtn -c /home/$USERNAME/.lightning/config.toml -vv run
4953
EOF
5054

51-
RUN chmod +x /root/init
55+
RUN chown $USERNAME:$USERNAME /home/$USERNAME/init
56+
RUN chmod +x /home/$USERNAME/init
5257

5358
EXPOSE $LIGHTNING_PORTS
5459

55-
ENTRYPOINT ["/root/init"]
60+
USER $USERNAME
61+
62+
ENTRYPOINT ["/home/lgtn/init"]

0 commit comments

Comments
 (0)