Updating Docker files for mono repo

This commit is contained in:
Chris Troutner
2026-08-26 12:05:01 -07:00
parent b58f360c89
commit 69c38d5a36
12 changed files with 114 additions and 79 deletions
+22
View File
@@ -0,0 +1,22 @@
# Keep Docker build contexts lean when building from the monorepo root.
.git
.gitsigners
.worktrees
swarmforge
docs
doc
test
tools
specs
**/node_modules
**/coverage
**/leveldb
**/logs
**/tmp
**/target
**/.env
!psf-memo-indexer/production/docker/**/.env
psf-memo-client/build
psf-memo-indexer/production/data
*.md
!README.md
+16
View File
@@ -40,6 +40,22 @@ npm start
See each component's `README.md` and `dev-docs/` for architecture details. See each component's `README.md` and `dev-docs/` for architecture details.
### Production (Docker)
Compose under [`psf-memo-indexer/production/docker`](psf-memo-indexer/production/docker/) builds all four services from this monorepo (no separate GitHub clones):
```bash
cd psf-memo-indexer/production/docker
cp memo-db/.env-example memo-db/.env
cp block-indexer/.env-example block-indexer/.env
cp tx-indexer/.env-example tx-indexer/.env
cp memo-client/.env-example memo-client/.env
docker compose build
docker compose up -d
```
Full ops notes: [`psf-memo-indexer/README.md`](psf-memo-indexer/README.md#production-docker).
## SwarmForge development ## SwarmForge development
This project is configured for SwarmForge with four pi-backed agents: This project is configured for SwarmForge with four pi-backed agents:
+1 -1
View File
@@ -61,7 +61,7 @@ npm test
## Production (Docker) ## Production (Docker)
The production Docker setup is in [psf-memo-indexer/production/docker](../psf-memo-indexer/production/docker/memo-db/) (compose builds `memo-db` from this repo). The production Docker setup is in [psf-memo-indexer/production/docker](../psf-memo-indexer/production/docker/). Compose builds `memo-db` by copying this package from the monorepo root.
## License ## License
+3 -3
View File
@@ -73,16 +73,16 @@ npm test
## Production (Docker) ## Production (Docker)
Docker Compose under [production/docker](./production/docker) runs the full stack. Images clone their source from GitHub at build time (same pattern as [psf-slp-indexer-g2](https://github.com/Permissionless-Software-Foundation/psf-slp-indexer-g2)). Docker Compose under [production/docker](./production/docker) runs the full stack. Build context is the [psf-memo](https://github.com/Permissionless-Software-Foundation/psf-memo) monorepo root; each image copies its package (`psf-memo-db`, `psf-memo-indexer`, or `psf-memo-client`) from the local checkout.
### Services ### Services
| Service | Container | Host port | Purpose | | Service | Container | Host port | Purpose |
|---------|-----------|-----------|---------| |---------|-----------|-----------|---------|
| `memo-db` | `memo-db` | `5021` | LevelDB REST API ([psf-memo-db](https://github.com/Permissionless-Software-Foundation/psf-memo-db)) | | `memo-db` | `memo-db` | `5021` | LevelDB REST API (`psf-memo-db/`) |
| `block-indexer` | `memo-block-indexer` | — | IBD + ZMQ block indexing | | `block-indexer` | `memo-block-indexer` | — | IBD + ZMQ block indexing |
| `tx-indexer` | `memo-tx-indexer` | `5455` | Mempool TX indexing (`/tx-start` control API) | | `tx-indexer` | `memo-tx-indexer` | `5455` | Mempool TX indexing (`/tx-start` control API) |
| `memo-client` | `memo-client` | `3000` | React SPA ([psf-memo-client](https://github.com/Permissionless-Software-Foundation/psf-memo-client)), nginx | | `memo-client` | `memo-client` | `3000` | React SPA (`psf-memo-client/`), nginx |
LevelDB data persists on the host at `production/data/leveldb`. LevelDB data persists on the host at `production/data/leveldb`.
+5 -4
View File
@@ -168,10 +168,11 @@ Each store is a separate LevelDB with JSON values. Keys are txids, addresses, or
```text ```text
production/docker/ production/docker/
├── docker-compose.yml ├── docker-compose.yml → build context: monorepo root (../../..)
├── memo-db/ → build context: ../../psf-memo-db ├── memo-db/ → COPY psf-memo-db/
├── block-indexer/ → build context: indexer repo root ├── block-indexer/ → COPY psf-memo-indexer/
── tx-indexer/ ── tx-indexer/ → COPY psf-memo-indexer/
└── memo-client/ → COPY psf-memo-client/
``` ```
Volumes mount `.env` and start scripts per service, matching the SLP production pattern. LevelDB data can persist under `production/data/leveldb`. Volumes mount `.env` and start scripts per service, matching the SLP production pattern. LevelDB data can persist under `production/data/leveldb`.
@@ -135,9 +135,9 @@ This document records **why** the Memo indexer stack looks the way it does, incl
## 13. Docker layout under `production/docker` ## 13. Docker layout under `production/docker`
**Decision:** Dockerfiles live in `psf-memo-indexer/production/docker/{memo-db,block-indexer,tx-indexer}/`, not repo roots—matching psf-slp-indexer-g2. **Decision:** Dockerfiles live in `psf-memo-indexer/production/docker/{memo-db,block-indexer,tx-indexer,memo-client}/`, not package roots—matching the psf-slp-indexer-g2 layout, adapted for the monorepo.
**Reason:** Single compose file orchestrates three services; build contexts point at `psf-memo-db` sibling repo and indexer root. **Reason:** Single compose file orchestrates all services; build context is the monorepo root so each Dockerfile can `COPY` its package (`psf-memo-db`, `psf-memo-indexer`, `psf-memo-client`) from the local checkout.
## 14. JavaScript vs extending the Go indexer ## 14. JavaScript vs extending the Go indexer
+1 -1
View File
@@ -215,4 +215,4 @@ Run: `npm test` in the `psf-memo-db` directory.
## Production ## Production
Docker build context is the `psf-memo-db` repo root; Dockerfile lives in [psf-memo-indexer/production/docker/memo-db/](../production/docker/memo-db/). See [architecture.md](./architecture.md#deployment-topology). Docker build context is the monorepo root; the Dockerfile copies `psf-memo-db/` and lives in [psf-memo-indexer/production/docker/memo-db/](../production/docker/memo-db/). See [architecture.md](./architecture.md#deployment-topology).
@@ -1,18 +1,20 @@
# Create a Dockerized block indexer # Create a Dockerized block indexer
# #
# Build context: psf-memo monorepo root
# docker compose build block-indexer
#IMAGE BUILD COMMANDS
FROM ubuntu:24.04 FROM ubuntu:24.04
MAINTAINER Chris Troutner <chris.troutner@gmail.com> MAINTAINER Chris Troutner <chris.troutner@gmail.com>
#Update the OS and install any OS packages needed. #Update the OS and install any OS packages needed.
RUN apt-get update RUN apt-get update && apt-get install -y sudo curl nano gnupg wget zip unzip python3 \
RUN apt-get install -y sudo git curl nano gnupg wget zip unzip python3 && rm -rf /var/lib/apt/lists/*
#Install Node and NPM #Install Node and NPM
RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh \
RUN bash nodesource_setup.sh && bash nodesource_setup.sh \
RUN apt-get install -y nodejs build-essential && apt-get update && apt-get install -y nodejs build-essential \
&& rm -rf /var/lib/apt/lists/*
#Create the user 'safeuser' and add them to the sudo group. #Create the user 'safeuser' and add them to the sudo group.
RUN useradd -ms /bin/bash safeuser RUN useradd -ms /bin/bash safeuser
@@ -30,17 +32,10 @@ RUN chown -R safeuser .npm-global
RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile
RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'" RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'"
# Clone the psf-memo-indexer repository # Copy psf-memo-indexer from the monorepo
WORKDIR /home/safeuser COPY psf-memo-indexer /home/safeuser/psf-memo-indexer
RUN git clone https://github.com/Permissionless-Software-Foundation/psf-memo-indexer
# Switch to the desired branch. `master` is usually stable,
# and `stage` has the most up-to-date changes.
WORKDIR /home/safeuser/psf-memo-indexer WORKDIR /home/safeuser/psf-memo-indexer
# For development: switch to unstable branch
#RUN git checkout <branch-name>
# Install dependencies # Install dependencies
RUN npm install RUN npm install
@@ -1,8 +1,16 @@
# Start the service with: docker-compose up -d # Build and start from this directory:
# docker compose build
# docker compose up -d
#
# Build context is the psf-memo monorepo root (../../../) so each
# image copies its package from the local checkout rather than cloning
# separate GitHub repositories.
services: services:
memo-db: memo-db:
build: ./memo-db build:
context: ../../..
dockerfile: psf-memo-indexer/production/docker/memo-db/Dockerfile
container_name: memo-db container_name: memo-db
logging: logging:
driver: json-file driver: json-file
@@ -18,7 +26,9 @@ services:
restart: always restart: always
tx-indexer: tx-indexer:
build: ./tx-indexer build:
context: ../../..
dockerfile: psf-memo-indexer/production/docker/tx-indexer/Dockerfile
image: memo-tx-indexer image: memo-tx-indexer
container_name: memo-tx-indexer container_name: memo-tx-indexer
logging: logging:
@@ -34,7 +44,9 @@ services:
restart: always restart: always
block-indexer: block-indexer:
build: ./block-indexer build:
context: ../../..
dockerfile: psf-memo-indexer/production/docker/block-indexer/Dockerfile
image: memo-block-indexer image: memo-block-indexer
container_name: memo-block-indexer container_name: memo-block-indexer
logging: logging:
@@ -48,7 +60,9 @@ services:
restart: always restart: always
memo-client: memo-client:
build: ./memo-client build:
context: ../../..
dockerfile: psf-memo-indexer/production/docker/memo-client/Dockerfile
image: memo-client image: memo-client
container_name: memo-client container_name: memo-client
logging: logging:
@@ -1,38 +1,35 @@
# Create a Dockerized front-end SPA served by nginx # Create a Dockerized front-end SPA served by nginx
# #
# Build context: psf-memo monorepo root
# docker compose build memo-client
#IMAGE BUILD COMMANDS #IMAGE BUILD COMMANDS
FROM ubuntu:24.04 as builder FROM ubuntu:24.04 as builder
MAINTAINER Chris Troutner <chris.troutner@gmail.com> MAINTAINER Chris Troutner <chris.troutner@gmail.com>
#Update the OS and install any OS packages needed. #Update the OS and install any OS packages needed.
RUN apt-get update RUN apt-get update && apt-get install -y sudo curl nano gnupg wget \
RUN apt-get install -y sudo git curl nano gnupg wget && rm -rf /var/lib/apt/lists/*
#Install Node and NPM #Install Node and NPM
RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh \
RUN bash nodesource_setup.sh && bash nodesource_setup.sh \
RUN apt-get install -y nodejs build-essential && apt-get update && apt-get install -y nodejs build-essential \
&& rm -rf /var/lib/apt/lists/*
#Set the working directory to be the home directory #Set the working directory to be the home directory
WORKDIR /home/safeuser WORKDIR /home/safeuser
# Clone the psf-memo-client repository # Copy psf-memo-client from the monorepo
RUN git clone https://github.com/Permissionless-Software-Foundation/psf-memo-client COPY psf-memo-client /home/safeuser/psf-memo-client
# Switch to the desired branch. `master` is usually stable,
# and `stage` / `unstable` have the most up-to-date changes.
WORKDIR /home/safeuser/psf-memo-client WORKDIR /home/safeuser/psf-memo-client
# For development: switch to unstable branch
#RUN git checkout unstable
# Install dependencies
RUN npm install
# Create React App reads REACT_APP_* from this .env at build time. # Create React App reads REACT_APP_* from this .env at build time.
# Edit production/docker/memo-client/.env before building. # Edit production/docker/memo-client/.env before building.
COPY .env .env COPY psf-memo-indexer/production/docker/memo-client/.env .env
# Install dependencies
RUN npm install
# Build the site # Build the site
RUN npm run build RUN npm run build
@@ -45,4 +42,4 @@ EXPOSE 80
COPY --from=builder /home/safeuser/psf-memo-client/build /usr/share/nginx/html COPY --from=builder /home/safeuser/psf-memo-client/build /usr/share/nginx/html
# Copy the NGINX configuration file. # Copy the NGINX configuration file.
COPY default.conf /etc/nginx/conf.d/default.conf COPY psf-memo-indexer/production/docker/memo-client/default.conf /etc/nginx/conf.d/default.conf
@@ -1,18 +1,20 @@
# Create a Dockerized API server # Create a Dockerized API server
# #
# Build context: psf-memo monorepo root
# docker compose build memo-db
#IMAGE BUILD COMMANDS
FROM ubuntu:24.04 FROM ubuntu:24.04
MAINTAINER Chris Troutner <chris.troutner@gmail.com> MAINTAINER Chris Troutner <chris.troutner@gmail.com>
#Update the OS and install any OS packages needed. #Update the OS and install any OS packages needed.
RUN apt-get update RUN apt-get update && apt-get install -y sudo curl nano gnupg wget zip unzip python3 \
RUN apt-get install -y sudo git curl nano gnupg wget zip unzip python3 && rm -rf /var/lib/apt/lists/*
#Install Node and NPM #Install Node and NPM
RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh \
RUN bash nodesource_setup.sh && bash nodesource_setup.sh \
RUN apt-get install -y nodejs build-essential && apt-get update && apt-get install -y nodejs build-essential \
&& rm -rf /var/lib/apt/lists/*
#Create the user 'safeuser' and add them to the sudo group. #Create the user 'safeuser' and add them to the sudo group.
RUN useradd -ms /bin/bash safeuser RUN useradd -ms /bin/bash safeuser
@@ -30,17 +32,10 @@ RUN chown -R safeuser .npm-global
RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile
RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'" RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'"
# Clone the psf-memo-db repository # Copy psf-memo-db from the monorepo
WORKDIR /home/safeuser COPY psf-memo-db /home/safeuser/psf-memo-db
RUN git clone https://github.com/Permissionless-Software-Foundation/psf-memo-db
# Switch to the desired branch. `master` is usually stable,
# and `stage` has the most up-to-date changes.
WORKDIR /home/safeuser/psf-memo-db WORKDIR /home/safeuser/psf-memo-db
# For development: switch to unstable branch
#RUN git checkout <branch-name>
# Install dependencies # Install dependencies
RUN npm install RUN npm install
@@ -1,18 +1,20 @@
# Create a Dockerized tx indexer # Create a Dockerized tx indexer
# #
# Build context: psf-memo monorepo root
# docker compose build tx-indexer
#IMAGE BUILD COMMANDS
FROM ubuntu:24.04 FROM ubuntu:24.04
MAINTAINER Chris Troutner <chris.troutner@gmail.com> MAINTAINER Chris Troutner <chris.troutner@gmail.com>
#Update the OS and install any OS packages needed. #Update the OS and install any OS packages needed.
RUN apt-get update RUN apt-get update && apt-get install -y sudo curl nano gnupg wget zip unzip python3 \
RUN apt-get install -y sudo git curl nano gnupg wget zip unzip python3 && rm -rf /var/lib/apt/lists/*
#Install Node and NPM #Install Node and NPM
RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh \
RUN bash nodesource_setup.sh && bash nodesource_setup.sh \
RUN apt-get install -y nodejs build-essential && apt-get update && apt-get install -y nodejs build-essential \
&& rm -rf /var/lib/apt/lists/*
#Create the user 'safeuser' and add them to the sudo group. #Create the user 'safeuser' and add them to the sudo group.
RUN useradd -ms /bin/bash safeuser RUN useradd -ms /bin/bash safeuser
@@ -30,17 +32,10 @@ RUN chown -R safeuser .npm-global
RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile
RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'" RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'"
# Clone the psf-memo-indexer repository # Copy psf-memo-indexer from the monorepo
WORKDIR /home/safeuser COPY psf-memo-indexer /home/safeuser/psf-memo-indexer
RUN git clone https://github.com/Permissionless-Software-Foundation/psf-memo-indexer
# Switch to the desired branch. `master` is usually stable,
# and `stage` has the most up-to-date changes.
WORKDIR /home/safeuser/psf-memo-indexer WORKDIR /home/safeuser/psf-memo-indexer
# For development: switch to unstable branch
#RUN git checkout <branch-name>
# Install dependencies # Install dependencies
RUN npm install RUN npm install