From a0725fea0b9005b8f018ce026fc504eacf8acfd5 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Tue, 31 Jan 2023 16:49:18 +1300 Subject: [PATCH 01/23] Add in the dockerfile and the docker compose files --- Dockerfile | 16 +++++++++++++ docker-compose.yml | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6f08e14 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.19.0-bullseye + +WORKDIR /App +ADD . /App +RUN go build + +WORKDIR /App/createboltcard +RUN go get github.com/skip2/go-qrcode +RUN go build + +WORKDIR /App/wipeboltcard +RUN go build + +WORKDIR /App + +ENTRYPOINT ["/App/boltcard"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..eb424b1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,60 @@ +version: '3' +services: + boltcard: + build: + context: ./ + dockerfile: Dockerfile + container_name: boltcard_main + depends_on: + - db + restart: unless-stopped + environment: + - LOG_LEVEL=DEBUG + - DB_HOST=db + - DB_USER=${DB_USER} + - DB_PASSWORD=${DB_PASSWORD} + - DB_PORT=5432 + - DB_NAME=${DB_NAME} + ports: + - 9000:9000 + volumes: + - ${PWD}/tls.cert:/boltcard/tls.cert + - ${PWD}/SendPaymentV2.macaroon:/boltcard/SendPaymentV2.macaroon + networks: + - boltnet + db: + image: postgres + container_name: boltcard_db + restart: unless-stopped + environment: + - POSTGRES_USER=${DB_USER} + - POSTGRES_PASSWORD=${DB_PASSWORD} + - POSTGRES_DB=${DB_NAME} + - PGDATA=/var/lib/postgresql/data/pgdata + volumes: + - db-data:/var/lib/postgresql/data + - ./select_db.sql:/docker-entrypoint-initdb.d/select_db.sql + - ./create_db.sql:/docker-entrypoint-initdb.d/create_db.sql + - ./settings.sql:/docker-entrypoint-initdb.d/settings.sql + ports: + - 5432:5432 + networks: + - boltnet + webserver: + image: caddy + restart: unless-stopped + ports: + - "8080:80" + - "443:443" + - "443:443/udp" + volumes: + - ${PWD}/Caddyfile:/etc/caddy/Caddyfile + - caddy_data:/data + - caddy_config:/config +networks: + boltnet: +volumes: + db-data: + caddy_data: + external: true + caddy_config: \ No newline at end of file From 2ea481e2817c7d617e37571e2a6c0f11b231155e Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Tue, 31 Jan 2023 16:50:55 +1300 Subject: [PATCH 02/23] Separate out the "DROP" sql code. In docker, it results an error "cannot drop the currently open database". --- create_db.sql | 6 ------ create_db_init.sql | 2 ++ create_db_user.sql | 2 ++ s_create_db | 2 ++ select_db.sql | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 create_db_init.sql create mode 100644 create_db_user.sql create mode 100644 select_db.sql diff --git a/create_db.sql b/create_db.sql index 7bc9842..f50285b 100644 --- a/create_db.sql +++ b/create_db.sql @@ -1,9 +1,3 @@ -DROP DATABASE IF EXISTS card_db; -CREATE DATABASE card_db; - -DROP USER IF EXISTS cardapp; -CREATE USER cardapp WITH PASSWORD 'database_password'; - \c card_db; CREATE TABLE settings ( diff --git a/create_db_init.sql b/create_db_init.sql new file mode 100644 index 0000000..2a65afb --- /dev/null +++ b/create_db_init.sql @@ -0,0 +1,2 @@ +DROP DATABASE IF EXISTS card_db; +CREATE DATABASE card_db; diff --git a/create_db_user.sql b/create_db_user.sql new file mode 100644 index 0000000..678c8b1 --- /dev/null +++ b/create_db_user.sql @@ -0,0 +1,2 @@ +DROP USER cardapp; +CREATE USER cardapp WITH PASSWORD 'database_password'; \ No newline at end of file diff --git a/s_create_db b/s_create_db index bf7f18c..f5d85f6 100755 --- a/s_create_db +++ b/s_create_db @@ -12,7 +12,9 @@ echo Continue? "(y or n)" read x if [ "$x" = "y" ]; then + psql postgres -f create_db_init.sql psql postgres -f create_db.sql + psql postgres -f create_db_user.sql psql postgres -f settings.sql echo Database created else diff --git a/select_db.sql b/select_db.sql new file mode 100644 index 0000000..340c842 --- /dev/null +++ b/select_db.sql @@ -0,0 +1 @@ +SELECT 'CREATE DATABASE card_db' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'card_db'); \ No newline at end of file From 20c793661544d4c816787668558024cfccfb0252 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Tue, 31 Jan 2023 16:51:03 +1300 Subject: [PATCH 03/23] Add the .env.example file --- .env.example | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5d282c1 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +DB_PORT=5432 +DB_USER=cardapp +DB_PASSWORD=password +DB_NAME=card_db \ No newline at end of file From 64754608794ca5fabc08cb631d1620e15a907562 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 1 Feb 2023 09:45:01 +1300 Subject: [PATCH 04/23] Change the port to 80 from 8080 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index eb424b1..03cbd30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: image: caddy restart: unless-stopped ports: - - "8080:80" + - "80:80" - "443:443" - "443:443/udp" volumes: From fb9c74cbdbe401032ee190931202374fdf37342f Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 1 Feb 2023 11:10:35 +1300 Subject: [PATCH 05/23] Add a "Caddyfile_docker" file. Update docker-compose.yml file --- .env.example | 5 +---- Caddyfile_docker | 2 ++ docker-compose.yml | 10 +++++----- 3 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 Caddyfile_docker diff --git a/.env.example b/.env.example index 5d282c1..775f70b 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1 @@ -DB_PORT=5432 -DB_USER=cardapp -DB_PASSWORD=password -DB_NAME=card_db \ No newline at end of file +DB_PASSWORD=password \ No newline at end of file diff --git a/Caddyfile_docker b/Caddyfile_docker new file mode 100644 index 0000000..e32ab53 --- /dev/null +++ b/Caddyfile_docker @@ -0,0 +1,2 @@ +https://card.yourdomain.com +reverse_proxy boltcard_main:9000 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 03cbd30..4c4e39a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,10 +11,10 @@ services: environment: - LOG_LEVEL=DEBUG - DB_HOST=db - - DB_USER=${DB_USER} + - DB_USER=cardapp - DB_PASSWORD=${DB_PASSWORD} - DB_PORT=5432 - - DB_NAME=${DB_NAME} + - DB_NAME=card_db ports: - 9000:9000 volumes: @@ -27,9 +27,9 @@ services: container_name: boltcard_db restart: unless-stopped environment: - - POSTGRES_USER=${DB_USER} + - POSTGRES_USER=cardapp - POSTGRES_PASSWORD=${DB_PASSWORD} - - POSTGRES_DB=${DB_NAME} + - POSTGRES_DB=card_db - PGDATA=/var/lib/postgresql/data/pgdata volumes: - db-data:/var/lib/postgresql/data @@ -48,7 +48,7 @@ services: - "443:443" - "443:443/udp" volumes: - - ${PWD}/Caddyfile:/etc/caddy/Caddyfile + - ${PWD}/Caddyfile_docker:/etc/caddy/Caddyfile - caddy_data:/data - caddy_config:/config networks: From becc52d72b29c220767dd2ed1097078770a96c61 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 1 Feb 2023 11:45:18 +1300 Subject: [PATCH 06/23] Add docker install readme --- README.md | 1 + docs/DOCKER_INSTALL.md | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 docs/DOCKER_INSTALL.md diff --git a/README.md b/README.md index 8d5c7fb..aa8f9eb 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ The 'bolt card creation' instructions describe how to set up bolt cards for use | [Specification](docs/SPEC.md) | Bolt card specifications | | [System](docs/SYSTEM.md) | Bolt card system overview | | [Service Install](docs/INSTALL.md) | Bolt card service installation | +| [Docker Service Install](docs/DOCKER_INSTALL.md) | Bolt card service docker installation | | [Automatic Card Creation](docs/CARD_ANDROID.md) | Bolt card creation using the Bolt Card app| | [Manual Card Creation](docs/CARD_MANUAL.md) | Bolt card creation using NXP TagXplorer software| | [FAQ](docs/FAQ.md) | Frequently asked questions | diff --git a/docs/DOCKER_INSTALL.md b/docs/DOCKER_INSTALL.md new file mode 100644 index 0000000..08e1096 --- /dev/null +++ b/docs/DOCKER_INSTALL.md @@ -0,0 +1,38 @@ +# Bolt card service installation using Docker + +### install Docker engine and Docker compose + +[Docker engine download & install](https://docs.docker.com/engine/install/) +[Docker compose download & install](https://docs.docker.com/compose/install/) + +### Set up the boltcard server +edit `.env` to set up the database connection +edit `settings.sql` to set up [bolt card system settings](SETTINGS.md) +edit `Caddyfile` to set the boltcard domain name + +### https setup + +set up the domain A record to point to the server + +set up the server hosting firewall to allow open access to https (port 443) only + + +### service bring-up and running +``` +$ docker volumes create caddy_data +// add -d for detached mode +$ docker-compose up -d +``` + +### stop docker +``` +$ docker-compose down +``` +To delete the database and reset the docker volume, run `docker-compose down --volumes` +*NOTE: caddy_data volume won't be removed even if you run `docker-compose down --volumes` because it's an external volume.* + + +#### running create bolt card command +- `docker exec boltcard_main createboltcard/createboltcard` to see options +- `docker exec boltcard_main createboltcard/createboltcard -enable -allow_neg_bal -tx_max=1000 -day_max=10000 -name=card_1` for example +- this will give you a one-time link in text and QR code form \ No newline at end of file From fd7d4e5134b41eeda73c69363210093362aaf831 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 1 Feb 2023 11:55:11 +1300 Subject: [PATCH 07/23] Update the readme --- docs/DOCKER_INSTALL.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/DOCKER_INSTALL.md b/docs/DOCKER_INSTALL.md index 08e1096..ac70546 100644 --- a/docs/DOCKER_INSTALL.md +++ b/docs/DOCKER_INSTALL.md @@ -2,8 +2,10 @@ ### install Docker engine and Docker compose -[Docker engine download & install](https://docs.docker.com/engine/install/) -[Docker compose download & install](https://docs.docker.com/compose/install/) +- [Docker engine download & + install](https://docs.docker.com/engine/install/) +- [Docker compose download & + install](https://docs.docker.com/compose/install/) ### Set up the boltcard server edit `.env` to set up the database connection From 9269b25fa55ebbe507dbb765edc5ba61b90f453a Mon Sep 17 00:00:00 2001 From: Rob Clarkson Date: Wed, 1 Feb 2023 13:10:20 +1300 Subject: [PATCH 08/23] Update DOCKER_INSTALL.md --- docs/DOCKER_INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/DOCKER_INSTALL.md b/docs/DOCKER_INSTALL.md index ac70546..357ee1c 100644 --- a/docs/DOCKER_INSTALL.md +++ b/docs/DOCKER_INSTALL.md @@ -21,7 +21,7 @@ set up the server hosting firewall to allow open access to https (port 443) only ### service bring-up and running ``` -$ docker volumes create caddy_data +$ docker volume create caddy_data // add -d for detached mode $ docker-compose up -d ``` @@ -37,4 +37,4 @@ To delete the database and reset the docker volume, run `docker-compose down --v #### running create bolt card command - `docker exec boltcard_main createboltcard/createboltcard` to see options - `docker exec boltcard_main createboltcard/createboltcard -enable -allow_neg_bal -tx_max=1000 -day_max=10000 -name=card_1` for example -- this will give you a one-time link in text and QR code form \ No newline at end of file +- this will give you a one-time link in text and QR code form From 4af6cc74542306afb751479fe53a672f4c364d58 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 1 Feb 2023 13:24:10 +1300 Subject: [PATCH 09/23] Put the caddy container on the same network --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 4c4e39a..6ddf739 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -51,6 +51,8 @@ services: - ${PWD}/Caddyfile_docker:/etc/caddy/Caddyfile - caddy_data:/data - caddy_config:/config + networks: + - boltnet networks: boltnet: volumes: From bdb0b5d74d5e83af65ccb39768a5b3b51982e32d Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 1 Feb 2023 14:23:25 +1300 Subject: [PATCH 10/23] Update docker-compose --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6ddf739..ce40c8b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: - 9000:9000 volumes: - ${PWD}/tls.cert:/boltcard/tls.cert - - ${PWD}/SendPaymentV2.macaroon:/boltcard/SendPaymentV2.macaroon + - ${PWD}/boltcard.macaroon:/boltcard/boltcard.macaroon networks: - boltnet db: From 59d1953db9f3ed1b7170430290789bb1e4807e78 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 1 Feb 2023 14:37:56 +1300 Subject: [PATCH 11/23] Change boltcard.macaroon to admin.macaroon --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ce40c8b..adc6869 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,8 +18,8 @@ services: ports: - 9000:9000 volumes: - - ${PWD}/tls.cert:/boltcard/tls.cert - - ${PWD}/boltcard.macaroon:/boltcard/boltcard.macaroon + - ${PWD}/tls.cert:/boltcard + - ${PWD}/admin.macaroon:/boltcard networks: - boltnet db: From 61500781e98b37b1da9728375489253760e5b6ef Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 1 Feb 2023 15:11:59 +1300 Subject: [PATCH 12/23] Update the docker-compose. Remove the volumes for key files --- docker-compose.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index adc6869..3fc66dc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,9 +17,6 @@ services: - DB_NAME=card_db ports: - 9000:9000 - volumes: - - ${PWD}/tls.cert:/boltcard - - ${PWD}/admin.macaroon:/boltcard networks: - boltnet db: From 9ebc75671cdad27e35deb54438051c4015681302 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 1 Feb 2023 15:45:09 +1300 Subject: [PATCH 13/23] Update the volumes for go container --- docker-compose.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 3fc66dc..41ae147 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,9 @@ services: - DB_NAME=card_db ports: - 9000:9000 + volumes: + - ${PWD}/tls.cert:/boltcard/tls.cert + - ${PWD}/admin.macaroon:/boltcard/admin.macaroon networks: - boltnet db: From 4cb0351f14fb6cc3267f2c525af3789d28a9ea4b Mon Sep 17 00:00:00 2001 From: chloehjung15 <73510449+chloehjung15@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:47:42 +1300 Subject: [PATCH 14/23] Update DOCKER_INSTALL.md --- docs/DOCKER_INSTALL.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/DOCKER_INSTALL.md b/docs/DOCKER_INSTALL.md index 357ee1c..6730517 100644 --- a/docs/DOCKER_INSTALL.md +++ b/docs/DOCKER_INSTALL.md @@ -10,6 +10,7 @@ ### Set up the boltcard server edit `.env` to set up the database connection edit `settings.sql` to set up [bolt card system settings](SETTINGS.md) +- Put the `tls.cert` file and `admin.macaroon` files in the project root directory and in the settings.sql, set the paths to the files to `/boltcard/tls.cert` and `/boltcard/admin.macaroon` edit `Caddyfile` to set the boltcard domain name ### https setup @@ -36,5 +37,5 @@ To delete the database and reset the docker volume, run `docker-compose down --v #### running create bolt card command - `docker exec boltcard_main createboltcard/createboltcard` to see options -- `docker exec boltcard_main createboltcard/createboltcard -enable -allow_neg_bal -tx_max=1000 -day_max=10000 -name=card_1` for example +- `docker exec boltcard_main createboltcard/createboltcard -enable -tx_max=1000 -day_max=10000 -name=card_1` for example - this will give you a one-time link in text and QR code form From 8c47ef140b7405d8205140849b6dcabd2c5143ef Mon Sep 17 00:00:00 2001 From: chloehjung15 <73510449+chloehjung15@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:48:54 +1300 Subject: [PATCH 15/23] Update DOCKER_INSTALL.md --- docs/DOCKER_INSTALL.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/DOCKER_INSTALL.md b/docs/DOCKER_INSTALL.md index 6730517..0063834 100644 --- a/docs/DOCKER_INSTALL.md +++ b/docs/DOCKER_INSTALL.md @@ -8,10 +8,10 @@ install](https://docs.docker.com/compose/install/) ### Set up the boltcard server -edit `.env` to set up the database connection -edit `settings.sql` to set up [bolt card system settings](SETTINGS.md) -- Put the `tls.cert` file and `admin.macaroon` files in the project root directory and in the settings.sql, set the paths to the files to `/boltcard/tls.cert` and `/boltcard/admin.macaroon` -edit `Caddyfile` to set the boltcard domain name +- edit `.env` to set up the database connection +- edit `settings.sql` to set up [bolt card system settings](SETTINGS.md) + - Put the `tls.cert` file and `admin.macaroon` files in the project root directory and in the settings.sql, set the paths to the files to `/boltcard/tls.cert` and `/boltcard/admin.macaroon` +- edit `Caddyfile` to set the boltcard domain name ### https setup From 76eabf453fc5ec54c51b194a02a3928249895219 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Wed, 1 Feb 2023 17:27:03 +1300 Subject: [PATCH 16/23] Push 'docker_init.sh' --- docker_init.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 docker_init.sh diff --git a/docker_init.sh b/docker_init.sh new file mode 100755 index 0000000..a319103 --- /dev/null +++ b/docker_init.sh @@ -0,0 +1,34 @@ +#!/bin/bash +echo Enter the domain name excluding the protocol +read domainname + +echo Enter your LND node gRPC domain +read lnd_host + +echo LND node gRPC port +read lnd_port +sed -i "1s/.*/https:\/\/$domainname/" Caddyfile_docker +sed -i "s/[(]'HOST_DOMAIN'[^)]*[)]/(\'HOST_DOMAIN\', \'$domainname\')/" settings.sql +echo writing the domain name to $domainname ... + +PASSWORD=$(date +%s|sha256sum|base64|head -c 32) +if [[ ! -e .env ]]; then + cp .env.example .env +fi +sed -i "s/^DB_PASSWORD=/DB_PASSWORD=$PASSWORD/g" .env +decrypt_key=$(hexdump -vn16 -e'4/4 "%08x" 1 "\n"' /dev/random) +echo $decrypt_key + +sed -i "s/[(]'LOG_LEVEL'[^)]*[)]/(\'LOG_LEVEL\', \'DEBUG\')/" settings.sql +sed -i "s/[(]'AES_DECRYPT_KEY'[^)]*[)]/(\'AES_DECRYPT_KEY\', \'$decrypt_key\')/" settings.sql +sed -i "s/[(]'MIN_WITHDRAW_SATS'[^)]*[)]/(\'MIN_WITHDRAW_SATS\', \'1\')/" settings.sql +sed -i "s/[(]'MAX_WITHDRAW_SATS'[^)]*[)]/(\'MAX_WITHDRAW_SATS\', \'1000000\')/" settings.sql +sed -i "s/[(]'LN_HOST'[^)]*[)]/(\'LN_HOST\', \'$lnd_host\')/" settings.sql +sed -i "s/[(]'LN_PORT'[^)]*[)]/(\'LN_PORT\', \'$lnd_port\')/" settings.sql +sed -i "s/[(]'LN_TLS_FILE'[^)]*[)]/(\'LN_TLS_FILE\', \'\/boltcard\/cert.tls\')/" settings.sql +sed -i "s/[(]'LN_MACAROON_FILE'[^)]*[)]/(\'LN_MACAROON_FILE\', \'\/boltcard\/admin.macaroon\')/" settings.sql +sed -i "s/[(]'FEE_LIMIT_SAT'[^)]*[)]/(\'FEE_LIMIT_SAT\', \'10\')/" settings.sql +sed -i "s/[(]'FEE_LIMIT_PERCENT'[^)]*[)]/(\'FEE_LIMIT_PERCENT\', \'0.5\')/" settings.sql +sed -i "s/[(]'FUNCTION_LNURLW'[^)]*[)]/(\'FUNCTION_LNURLW\', \'ENABLE\')/" settings.sql +sed -i "s/[(]'FUNCTION_LNURLP'[^)]*[)]/(\'FUNCTION_LNURLP\', \'DISABLE\')/" settings.sql +sed -i "s/[(]'FUNCTION_EMAIL'[^)]*[)]/(\'FUNCTION_EMAIL\', \'DISABLE\')/" settings.sql From 7d76797154ca67d4c6a350295ab68771ca581c4a Mon Sep 17 00:00:00 2001 From: chloehjung15 <73510449+chloehjung15@users.noreply.github.com> Date: Wed, 1 Feb 2023 17:33:11 +1300 Subject: [PATCH 17/23] Update DOCKER_INSTALL.md --- docs/DOCKER_INSTALL.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/DOCKER_INSTALL.md b/docs/DOCKER_INSTALL.md index 0063834..028dca8 100644 --- a/docs/DOCKER_INSTALL.md +++ b/docs/DOCKER_INSTALL.md @@ -8,10 +8,9 @@ install](https://docs.docker.com/compose/install/) ### Set up the boltcard server -- edit `.env` to set up the database connection -- edit `settings.sql` to set up [bolt card system settings](SETTINGS.md) - - Put the `tls.cert` file and `admin.macaroon` files in the project root directory and in the settings.sql, set the paths to the files to `/boltcard/tls.cert` and `/boltcard/admin.macaroon` -- edit `Caddyfile` to set the boltcard domain name +- Run `chmod +x docker_init.sh` +- Run `./docker_init.sh` to set up the initial data +- Put the `tls.cert` file and `admin.macaroon` files in the project root directory ### https setup From 004fc003d9337c24c11048b21e91e93749e649a6 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Thu, 2 Feb 2023 15:08:54 +1300 Subject: [PATCH 18/23] Do not expose db and boltcard service containers ports --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 41ae147..31ef452 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,8 +15,8 @@ services: - DB_PASSWORD=${DB_PASSWORD} - DB_PORT=5432 - DB_NAME=card_db - ports: - - 9000:9000 + expose: + - "9000" volumes: - ${PWD}/tls.cert:/boltcard/tls.cert - ${PWD}/admin.macaroon:/boltcard/admin.macaroon @@ -36,8 +36,8 @@ services: - ./select_db.sql:/docker-entrypoint-initdb.d/select_db.sql - ./create_db.sql:/docker-entrypoint-initdb.d/create_db.sql - ./settings.sql:/docker-entrypoint-initdb.d/settings.sql - ports: - - 5432:5432 + expose: + - "5432" networks: - boltnet webserver: From 9f601f59db2307379092a7ca35db05b5a64e21a8 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Fri, 3 Feb 2023 15:17:37 +1300 Subject: [PATCH 19/23] Update docker install readme --- docs/DOCKER_INSTALL.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/DOCKER_INSTALL.md b/docs/DOCKER_INSTALL.md index 028dca8..1d717fa 100644 --- a/docs/DOCKER_INSTALL.md +++ b/docs/DOCKER_INSTALL.md @@ -4,11 +4,8 @@ - [Docker engine download & install](https://docs.docker.com/engine/install/) -- [Docker compose download & - install](https://docs.docker.com/compose/install/) ### Set up the boltcard server -- Run `chmod +x docker_init.sh` - Run `./docker_init.sh` to set up the initial data - Put the `tls.cert` file and `admin.macaroon` files in the project root directory @@ -21,20 +18,32 @@ set up the server hosting firewall to allow open access to https (port 443) only ### service bring-up and running ``` +$ sudo groupadd docker +$ sudo usermod -aG docker ${USER} +(log out & in again) $ docker volume create caddy_data -// add -d for detached mode -$ docker-compose up -d +// add -d option for detached mode +$ docker compose up ``` ### stop docker ``` -$ docker-compose down +$ docker compose down ``` To delete the database and reset the docker volume, run `docker-compose down --volumes` *NOTE: caddy_data volume won't be removed even if you run `docker-compose down --volumes` because it's an external volume.* +### check container logs + +- [Docker Logs](https://docs.docker.com/engine/reference/commandline/logs/) + +``` +$ docker logs [OPTIONS] CONTAINER +``` + +Run `$ docker ps` to list containers and get container names/ids #### running create bolt card command - `docker exec boltcard_main createboltcard/createboltcard` to see options -- `docker exec boltcard_main createboltcard/createboltcard -enable -tx_max=1000 -day_max=10000 -name=card_1` for example +- `docker exec boltcard_main createboltcard/createboltcard -enable -allow_neg_bal -tx_max=1000 -day_max=10000 -name=card_1` for example - this will give you a one-time link in text and QR code form From 4a66bbf3f172262244570ba49352b48a1d141bd0 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Fri, 3 Feb 2023 15:20:37 +1300 Subject: [PATCH 20/23] Update the setting the db password in env script --- docker_init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_init.sh b/docker_init.sh index a319103..c428b2e 100755 --- a/docker_init.sh +++ b/docker_init.sh @@ -15,7 +15,7 @@ PASSWORD=$(date +%s|sha256sum|base64|head -c 32) if [[ ! -e .env ]]; then cp .env.example .env fi -sed -i "s/^DB_PASSWORD=/DB_PASSWORD=$PASSWORD/g" .env +sed -i "s/^DB_PASSWORD=.*$/DB_PASSWORD=$PASSWORD/g" .env decrypt_key=$(hexdump -vn16 -e'4/4 "%08x" 1 "\n"' /dev/random) echo $decrypt_key From 3e3412233d7541421dd2afa22d42ce29ecd45e4b Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Tue, 7 Feb 2023 09:14:15 +1300 Subject: [PATCH 21/23] Change cert.tls to tls.cert --- docker_init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_init.sh b/docker_init.sh index c428b2e..511b9bc 100755 --- a/docker_init.sh +++ b/docker_init.sh @@ -25,7 +25,7 @@ sed -i "s/[(]'MIN_WITHDRAW_SATS'[^)]*[)]/(\'MIN_WITHDRAW_SATS\', \'1\')/" settin sed -i "s/[(]'MAX_WITHDRAW_SATS'[^)]*[)]/(\'MAX_WITHDRAW_SATS\', \'1000000\')/" settings.sql sed -i "s/[(]'LN_HOST'[^)]*[)]/(\'LN_HOST\', \'$lnd_host\')/" settings.sql sed -i "s/[(]'LN_PORT'[^)]*[)]/(\'LN_PORT\', \'$lnd_port\')/" settings.sql -sed -i "s/[(]'LN_TLS_FILE'[^)]*[)]/(\'LN_TLS_FILE\', \'\/boltcard\/cert.tls\')/" settings.sql +sed -i "s/[(]'LN_TLS_FILE'[^)]*[)]/(\'LN_TLS_FILE\', \'\/boltcard\/tls.cert\')/" settings.sql sed -i "s/[(]'LN_MACAROON_FILE'[^)]*[)]/(\'LN_MACAROON_FILE\', \'\/boltcard\/admin.macaroon\')/" settings.sql sed -i "s/[(]'FEE_LIMIT_SAT'[^)]*[)]/(\'FEE_LIMIT_SAT\', \'10\')/" settings.sql sed -i "s/[(]'FEE_LIMIT_PERCENT'[^)]*[)]/(\'FEE_LIMIT_PERCENT\', \'0.5\')/" settings.sql From c423f967111900e5c6f28f6bf0526ba727822b68 Mon Sep 17 00:00:00 2001 From: Chloe Jung Date: Tue, 7 Feb 2023 09:18:29 +1300 Subject: [PATCH 22/23] Update read me --- docs/DOCKER_INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/DOCKER_INSTALL.md b/docs/DOCKER_INSTALL.md index 1d717fa..cd897af 100644 --- a/docs/DOCKER_INSTALL.md +++ b/docs/DOCKER_INSTALL.md @@ -30,8 +30,8 @@ $ docker compose up ``` $ docker compose down ``` -To delete the database and reset the docker volume, run `docker-compose down --volumes` -*NOTE: caddy_data volume won't be removed even if you run `docker-compose down --volumes` because it's an external volume.* +To delete the database and reset the docker volume, run `docker compose down --volumes` +*NOTE: caddy_data volume won't be removed even if you run `docker compose down --volumes` because it's an external volume. **Make sure to wipe your programmed cards before wiping the database*** ### check container logs From e3d006ffe09159bee5b285519db35b610101b2fd Mon Sep 17 00:00:00 2001 From: chloehjung15 <73510449+chloehjung15@users.noreply.github.com> Date: Thu, 9 Feb 2023 15:58:59 +1300 Subject: [PATCH 23/23] Update DOCKER_INSTALL.md --- docs/DOCKER_INSTALL.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/DOCKER_INSTALL.md b/docs/DOCKER_INSTALL.md index cd897af..576705a 100644 --- a/docs/DOCKER_INSTALL.md +++ b/docs/DOCKER_INSTALL.md @@ -15,6 +15,10 @@ set up the domain A record to point to the server set up the server hosting firewall to allow open access to https (port 443) only +### database setup + +copy the `.env.example` file to `.env` and change the database password + ### service bring-up and running ```