diff --git a/Dockerfile.block-indexer b/Dockerfile.block-indexer deleted file mode 100644 index 5ab8121..0000000 --- a/Dockerfile.block-indexer +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:20-alpine - -WORKDIR /app - -COPY package*.json ./ -RUN npm ci --omit=dev - -COPY . . - -CMD ["node", "--max-old-space-size=8192", "psf-memo-block-indexer.js"] diff --git a/Dockerfile.tx-indexer b/Dockerfile.tx-indexer deleted file mode 100644 index fea71be..0000000 --- a/Dockerfile.tx-indexer +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:20-alpine - -WORKDIR /app - -COPY package*.json ./ -RUN npm ci --omit=dev - -COPY . . - -CMD ["node", "--max-old-space-size=4096", "psf-memo-tx-indexer.js"] diff --git a/README.md b/README.md index 26cfe2b..bb6e488 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,21 @@ See `.env-example`. Key variables: npm test ``` +## Production (Docker) + +Docker files live under [production/docker](./production/docker), matching [psf-slp-indexer-g2](https://github.com/Permissionless-Software-Foundation/psf-slp-indexer-g2): + +```bash +cd production/docker +cp block-indexer/.env-example block-indexer/.env +cp tx-indexer/.env-example tx-indexer/.env +cp memo-db/.env-example memo-db/.env +docker-compose build +docker-compose up -d +``` + +Services: `memo-db` (port 5021), `block-indexer`, `tx-indexer` (port 5455). + ## License GPL v3 diff --git a/production/docker/block-indexer/.env-example b/production/docker/block-indexer/.env-example new file mode 100644 index 0000000..95d1515 --- /dev/null +++ b/production/docker/block-indexer/.env-example @@ -0,0 +1,16 @@ +# Environment variables for psf-memo-block-indexer +# Copy this file to .env and modify as needed + +PSF_MEMO_DB_URL=http://172.17.0.1:5021 + +RPC_IP=172.17.0.1 +RPC_PORT=8332 +ZMQ_PORT=28332 +RPC_USER=bitcoin +RPC_PASS=password + +TX_REST_API_PORT=5455 +TX_REST_API_IP=172.17.0.1 + +START_BLOCK_HEIGHT=525000 +EXIT_ON_MISSING_BACKUP=false diff --git a/production/docker/block-indexer/Dockerfile b/production/docker/block-indexer/Dockerfile new file mode 100644 index 0000000..a511581 --- /dev/null +++ b/production/docker/block-indexer/Dockerfile @@ -0,0 +1,11 @@ +FROM node:20-alpine + +WORKDIR /home/safeuser/psf-memo-indexer + +COPY package*.json ./ +RUN npm ci --omit=dev + +COPY . . + +VOLUME start-block-indexer.sh +CMD ["./start-block-indexer.sh"] diff --git a/production/docker/block-indexer/start-block-indexer.sh b/production/docker/block-indexer/start-block-indexer.sh new file mode 100755 index 0000000..71e019f --- /dev/null +++ b/production/docker/block-indexer/start-block-indexer.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +node --max-old-space-size=8192 psf-memo-block-indexer.js diff --git a/production/docker/docker-compose.yml b/production/docker/docker-compose.yml new file mode 100644 index 0000000..a2413bd --- /dev/null +++ b/production/docker/docker-compose.yml @@ -0,0 +1,52 @@ +# Start the service with: docker-compose up -d + +services: + memo-db: + build: + context: ../../psf-memo-db + dockerfile: ./memo-db/Dockerfile + container_name: memo-db + logging: + driver: json-file + options: + max-size: 10m + max-file: '10' + ports: + - '5021:5021' + volumes: + - ../data/leveldb:/home/safeuser/psf-memo-db/leveldb + - ./memo-db/start-memo-db.sh:/home/safeuser/psf-memo-db/start-memo-db.sh + - ./memo-db/.env:/home/safeuser/psf-memo-db/.env + restart: always + + tx-indexer: + build: + context: ../.. + dockerfile: production/docker/tx-indexer/Dockerfile + container_name: memo-tx-indexer + logging: + driver: json-file + options: + max-size: 10m + max-file: '10' + ports: + - '5455:5455' + volumes: + - ./tx-indexer/start-tx-indexer.sh:/home/safeuser/psf-memo-indexer/start-tx-indexer.sh + - ./tx-indexer/.env:/home/safeuser/psf-memo-indexer/.env + restart: always + + block-indexer: + build: + context: ../.. + dockerfile: production/docker/block-indexer/Dockerfile + container_name: memo-block-indexer + logging: + driver: json-file + options: + max-size: 10m + max-file: '10' + volumes: + - ./block-indexer/start-block-indexer.sh:/home/safeuser/psf-memo-indexer/start-block-indexer.sh + - ./block-indexer/.env:/home/safeuser/psf-memo-indexer/.env + restart: always diff --git a/production/docker/memo-db/.env-example b/production/docker/memo-db/.env-example new file mode 100644 index 0000000..5f9a9cb --- /dev/null +++ b/production/docker/memo-db/.env-example @@ -0,0 +1,4 @@ +PORT=5021 +SVC_ENV=prod +BACKUP_QTY=3 +EXIT_ON_MISSING_BACKUP=false diff --git a/production/docker/memo-db/Dockerfile b/production/docker/memo-db/Dockerfile new file mode 100644 index 0000000..cab09c4 --- /dev/null +++ b/production/docker/memo-db/Dockerfile @@ -0,0 +1,13 @@ +FROM node:20-alpine + +WORKDIR /home/safeuser/psf-memo-db + +COPY package*.json ./ +RUN npm ci --omit=dev + +COPY . . + +EXPOSE 5021 + +VOLUME start-memo-db.sh +CMD ["./start-memo-db.sh"] diff --git a/production/docker/memo-db/start-memo-db.sh b/production/docker/memo-db/start-memo-db.sh new file mode 100755 index 0000000..c499cf0 --- /dev/null +++ b/production/docker/memo-db/start-memo-db.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +node index.js diff --git a/production/docker/tx-indexer/.env-example b/production/docker/tx-indexer/.env-example new file mode 100644 index 0000000..527ddb2 --- /dev/null +++ b/production/docker/tx-indexer/.env-example @@ -0,0 +1,15 @@ +# Environment variables for psf-memo-tx-indexer +# Copy this file to .env and modify as needed + +PSF_MEMO_DB_URL=http://172.17.0.1:5021 + +RPC_IP=172.17.0.1 +RPC_PORT=8332 +ZMQ_PORT=28332 +RPC_USER=bitcoin +RPC_PASS=password + +TX_REST_API_PORT=5455 +TX_REST_API_IP=172.17.0.1 + +SEEN_TX_MAX=100000 diff --git a/production/docker/tx-indexer/Dockerfile b/production/docker/tx-indexer/Dockerfile new file mode 100644 index 0000000..1d304ff --- /dev/null +++ b/production/docker/tx-indexer/Dockerfile @@ -0,0 +1,13 @@ +FROM node:20-alpine + +WORKDIR /home/safeuser/psf-memo-indexer + +COPY package*.json ./ +RUN npm ci --omit=dev + +COPY . . + +EXPOSE 5455 + +VOLUME start-tx-indexer.sh +CMD ["./start-tx-indexer.sh"] diff --git a/production/docker/tx-indexer/start-tx-indexer.sh b/production/docker/tx-indexer/start-tx-indexer.sh new file mode 100755 index 0000000..2446215 --- /dev/null +++ b/production/docker/tx-indexer/start-tx-indexer.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +node --max-old-space-size=4096 psf-memo-tx-indexer.js