diff --git a/.env b/.env index 34f3952..50a998b 100644 --- a/.env +++ b/.env @@ -15,4 +15,7 @@ TXOO_REPO=https://gitlab.com/lightning-signer/txoo.git TXOO_GIT_HASH=6f0718e3f2b9406df5e3cd73306f473199141da0 # vls version v0.11.0 (2024-06-06 15:09:25 +0000) VLS_REPO=https://gitlab.com/lightning-signer/validating-lightning-signer.git -VLS_GIT_HASH=f853773d0252430b8b24f181562a8afdd42293fa +VLS_GIT_HASH=d2590ba34a388a016bb91307864e993fb3cc3d84 +# lss version v0.1.0 +LSS_REPO=https://gitlab.com/lightning-signer/validating-lightning-signer.git +LSS_GIT_HASH=d2590ba34a388a016bb91307864e993fb3cc3d84 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ff38e1..80ed1f0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,6 +32,11 @@ build_txoo: stage: build script: - ./scripts/build_image_cache.sh txood +build_lss: + tags: [ saas-linux-large-amd64 ] + stage: build + script: + - ./scripts/build_image_cache.sh lss build_vls: tags: [ saas-linux-large-amd64 ] stage: build diff --git a/docker-compose.yml b/docker-compose.yml index 9204ce8..0c56009 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -78,6 +78,31 @@ services: - BITCOIN_NETWORK=testnet - BITCOIND_RPC_URL=http://rpcuser:VLSsigner1@bitcoind:18332 + lss: + build: + context: ./lss + args: + - LSS_REPO + - LSS_GIT_HASH + image: lss:${IMAGE_TAG:-latest} + container_name: lss-test + ports: + - 55551:55551 + expose: + - 55551 + profiles: + - lss + networks: + - lightning + volumes: + - lss_data:/home/lss/.lss + environment: + - LSS_DATABASE=${LSS_DATABASE:-sled} + - PG_HOST + - PG_USER + - PG_PASS + - PG_DB + vls: build: context: ./vlsd @@ -88,9 +113,10 @@ services: container_name: vlsd-test profiles: - vls - command: - - --log-level=info - - --connect=http://core-lightning:7701 + command: + --log-level=info + --connect=http://core-lightning:7701 + ${LSS_REMOTE_URL:+--lss=$LSS_REMOTE_URL} networks: - lightning volumes: @@ -100,6 +126,10 @@ services: - VLS_PERMISSIVE=1 - RUST_LOG=info - BITCOIND_RPC_URL=http://rpcuser:VLSsigner1@bitcoind:18332 + depends_on: + lss: + condition: service_started + required: false volumes: bitcoin_data: @@ -111,6 +141,9 @@ volumes: txoo_data: name: txoo_data external: true + lss_data: + name: lss_data + external: true vls_data: name: vls_data external: true diff --git a/lss/Dockerfile b/lss/Dockerfile new file mode 100644 index 0000000..fe3c409 --- /dev/null +++ b/lss/Dockerfile @@ -0,0 +1,62 @@ +# build lss +FROM --platform=${TARGETPLATFORM:-${BUILDPLATFORM:-linux/amd64}} alpine:3.18 as builder + +WORKDIR /build + +RUN apk update && \ + apk add \ + build-base \ + cargo \ + git \ + grpc \ + protobuf \ + protobuf-dev \ + rust + +ARG LSS_GIT_HASH \ + LSS_REPO +RUN echo "building lss from hash: $LSS_GIT_HASH" +RUN git clone $LSS_REPO lss + +RUN cd lss && \ + git checkout $LSS_GIT_HASH && \ + cargo install --locked --path ./lightning-storage-server --bin lssd --profile release --root /usr/local/ && \ + cargo clean + +# lss runner +FROM --platform=${TARGETPLATFORM:-${BUILDPLATFORM:-linux/amd64}} alpine:3.18 as runner + +ARG LSS_DATA=/root/.lssd + +RUN apk update && \ + apk add \ + build-base \ + curl-dev \ + protobuf \ + bind-tools \ + tini + +COPY --from=builder /usr/local/bin/lssd /usr/local/bin/lssd +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +VOLUME ["${LSS_DATA}"] + + + +# Environment variables with default fallbacks +ENV LSS_PORT=${LSS_PORT:-55551} +ENV LSS_INTERFACE=${LSS_INTERFACE:-0.0.0.0} +ENV LSS_CLEARDB=${LSS_CLEARDB:-false} +ENV LSS_DATADIR=${LSS_DATADIR:-datadir} +ENV LSS_DATABASE=${LSS_DATABASE:-sled} +ENV PG_HOST=${PG_HOST:-} +ENV PG_USER=${PG_USER:-dev} +ENV PG_PASSWORD=${PG_PASSWORD:-} +ENV PG_DB=${PG_DB:-dev} + +# Expose LSS port +EXPOSE ${LSS_PORT} + +# Run lssd with the build arguments passed at runtime +ENTRYPOINT ["/entrypoint.sh"] diff --git a/lss/README.md b/lss/README.md new file mode 100644 index 0000000..760d9f2 --- /dev/null +++ b/lss/README.md @@ -0,0 +1,24 @@ +# LSS Setup + +## Building the docker image + +### Ubuntu/Linux +```bash +sudo docker build \ + --build-arg LSS_REPO=https://gitlab.com/lightning-signer/validating-lightning-signer.git \ + --build-arg LSS_GIT_HASH=d2590ba34a388a016bb91307864e993fb3cc3d84 \ + -t lss . +``` + +### Windows +```bash +docker build --build-arg LSS_REPO=https://gitlab.com/lightning-signer/validating-lightning-signer.git --build-arg LSS_GIT_HASH=d2590ba34a388a016bb91307864e993fb3cc3d84 -t lss . +``` + +## Running the container +```bash +docker compose --profile lss -f docker-compose.yml up lss +``` + +## Postgres Setup +To use LSS with postgres, change the environment variable LSS_DATABASE to postgres, you also need to supply the arguments PG_HOST, PG_USER, PG_PASS, PG_DB to a real postgres database diff --git a/lss/docker-compose.yml b/lss/docker-compose.yml new file mode 100644 index 0000000..6ae69e3 --- /dev/null +++ b/lss/docker-compose.yml @@ -0,0 +1,58 @@ +version: "3.8" +services: + lss: + build: + context: . + dockerfile: Dockerfile + args: + - LSS_REPO + - LSS_GIT_HASH + image: lss:${IMAGE_TAG:-latest} + container_name: lss-test + ports: + - 55551:55551 + expose: + - 55551 + networks: + - lightning + volumes: + - lss_data:/home/lss/.lss + environment: + - LSS_DATABASE=${LSS_DATABASE:-sled} + - PG_HOST + - PG_USER + - PG_PASS + - PG_DB + vls: + build: + context: ../vlsd + dockerfile: Dockerfile + args: + - VLS_GIT_HASH + image: vlsd + container_name: vlsd-standalone + command: + --connect=http://core-lightning:7701 + --lss=http://lss:55551 + networks: + - lightning + volumes: + - vls_data:/home/vls/.lightning-signer + environment: + - BITCOIND_RPC_URL=$BITCOIND_RPC_URL + - VLS_NETWORK=testnet + depends_on: + lss: + condition: service_healthy + required: false + +networks: + lightning: + +volumes: + vls_data: + name: vls_data + external: true + lss_data: + name: lss_data + external: true diff --git a/lss/entrypoint.sh b/lss/entrypoint.sh new file mode 100644 index 0000000..887451d --- /dev/null +++ b/lss/entrypoint.sh @@ -0,0 +1,2 @@ +#!/bin/sh +/usr/local/bin/lssd --port "$LSS_PORT" --interface "$LSS_INTERFACE" --database "$LSS_DATABASE"