From a9a155608f7b41a75edb2e074adbdffab67aacce Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Mon, 3 Apr 2023 11:25:24 -0400 Subject: [PATCH 1/2] Dockerize for LND --- .dockerignore | 4 ++++ Dockerfile | 18 ++++++++++++++++++ entrypoint.sh | 13 +++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1d4d1db --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules +npm-debug.log +*.md +LICENSE diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..93f4c29 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM node:16-alpine3.16 + +RUN apk add \ + bash \ + ca-certificates + +WORKDIR /usr/src/app + +COPY package*.json ./ +RUN npm ci --omit=dev +# install dependencies +RUN npm install knex pg + +COPY . . +RUN chmod +x ./entrypoint.sh +EXPOSE 3000 + +CMD ["./entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..b4340ae --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# add self-signed lnd cert to system +mkdir -p /usr/local/share/ca-certificates +cp $LND_CERT_PATH /usr/local/share/ca-certificates/lnd.crt +update-ca-certificates + +node cli.js server --host "$LNURL_HOST" \ + --port "$LNURL_PORT" \ + --lightning.backend "lnd" \ + --lightning.config "{\"hostname\": \"$LND_HOST:$LND_PORT\", \"macaroon\": \"$LND_MACAROON_PATH\", \"cert\": \"$LND_CERT_PATH\"}" \ + --store.backend "knex" \ + --store.config "{\"client\":\"postgres\",\"connection\":{\"host\":\"$POSTGRES_HOST\",\"user\":\"$POSTGRES_USER\",\"password\":\"$POSTGRES_PASSWORD\",\"database\":\"$POSTGRES_DB\"}}" \ No newline at end of file From 2b2033614e3751387104839641f4a58dfffbeefd Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Wed, 5 Apr 2023 14:09:03 -0400 Subject: [PATCH 2/2] rm custom user to fix adding self-signed cert to trusted certs --- Dockerfile | 16 ++++++++++++---- entrypoint.sh | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 93f4c29..5b1e1e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,15 @@ -FROM node:16-alpine3.16 +FROM --platform=linux/amd64 node:19-alpine3.16 RUN apk add \ bash \ ca-certificates - + +RUN mkdir -p /usr/local/share/ca-certificates \ + && chmod 333 /usr/local/share/ca-certificates + # && chmod 333 /etc/ssl/certs # this doesn't work + +# RUN addgroup -g 2001 -S lnurl && adduser -u 1001 -S lnurl -G lnurl + WORKDIR /usr/src/app COPY package*.json ./ @@ -12,7 +18,9 @@ RUN npm ci --omit=dev RUN npm install knex pg COPY . . -RUN chmod +x ./entrypoint.sh -EXPOSE 3000 +RUN chmod +x ./entrypoint.sh + # && chown lnurl:lnurl -R /usr/src/app +EXPOSE 3000 +# USER lnurl CMD ["./entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index b4340ae..544d387 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash # add self-signed lnd cert to system -mkdir -p /usr/local/share/ca-certificates + cp $LND_CERT_PATH /usr/local/share/ca-certificates/lnd.crt update-ca-certificates