From bff09a3f55f84243c726c5ec4920313f2e9d3f5a Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Wed, 15 Jul 2026 09:58:51 -0700 Subject: [PATCH] fixing docker containers --- .gitignore | 1 + production/docker/block-indexer/Dockerfile | 47 +++++++++++++++++++-- production/docker/docker-compose.yml | 10 ++--- production/docker/memo-client/Dockerfile | 4 +- production/docker/tx-indexer/Dockerfile | 48 ++++++++++++++++++++-- 5 files changed, 94 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 6f3acac..23ca9cb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ .env coverage/ logs/ +production/data/ diff --git a/production/docker/block-indexer/Dockerfile b/production/docker/block-indexer/Dockerfile index a511581..ae9dd74 100644 --- a/production/docker/block-indexer/Dockerfile +++ b/production/docker/block-indexer/Dockerfile @@ -1,11 +1,50 @@ -FROM node:20-alpine +# Create a Dockerized block indexer +# +#IMAGE BUILD COMMANDS +FROM ubuntu:24.04 +MAINTAINER Chris Troutner + +#Update the OS and install any OS packages needed. +RUN apt-get update +RUN apt-get install -y sudo git curl nano gnupg wget zip unzip python3 + +#Install Node and NPM +RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh +RUN bash nodesource_setup.sh +RUN apt-get install -y nodejs build-essential + +#Create the user 'safeuser' and add them to the sudo group. +RUN useradd -ms /bin/bash safeuser +RUN adduser safeuser sudo + +#Set password to 'password' change value below if you want a different password +RUN echo safeuser:password | chpasswd + +#Set the working directory to be the home directory +WORKDIR /home/safeuser + +#Setup NPM for non-root global install +RUN mkdir /home/safeuser/.npm-global +RUN chown -R safeuser .npm-global +RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile +RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'" + +# Clone the psf-memo-indexer repository +WORKDIR /home/safeuser +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 -COPY package*.json ./ -RUN npm ci --omit=dev +# For development: switch to unstable branch +#RUN git checkout -COPY . . +# Install dependencies +RUN npm install +# Start the application. +# start-block-indexer.sh is mounted at runtime via docker-compose. VOLUME start-block-indexer.sh CMD ["./start-block-indexer.sh"] diff --git a/production/docker/docker-compose.yml b/production/docker/docker-compose.yml index f97ceaa..c695df9 100644 --- a/production/docker/docker-compose.yml +++ b/production/docker/docker-compose.yml @@ -18,9 +18,8 @@ services: restart: always tx-indexer: - build: - context: ../.. - dockerfile: production/docker/tx-indexer/Dockerfile + build: ./tx-indexer + image: memo-tx-indexer container_name: memo-tx-indexer logging: driver: json-file @@ -35,9 +34,8 @@ services: restart: always block-indexer: - build: - context: ../.. - dockerfile: production/docker/block-indexer/Dockerfile + build: ./block-indexer + image: memo-block-indexer container_name: memo-block-indexer logging: driver: json-file diff --git a/production/docker/memo-client/Dockerfile b/production/docker/memo-client/Dockerfile index df2745f..db201ea 100644 --- a/production/docker/memo-client/Dockerfile +++ b/production/docker/memo-client/Dockerfile @@ -2,7 +2,7 @@ # #IMAGE BUILD COMMANDS -FROM ubuntu:22.04 as builder +FROM ubuntu:24.04 as builder MAINTAINER Chris Troutner #Update the OS and install any OS packages needed. @@ -10,7 +10,7 @@ RUN apt-get update RUN apt-get install -y sudo git curl nano gnupg wget #Install Node and NPM -RUN curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh +RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh RUN bash nodesource_setup.sh RUN apt-get install -y nodejs build-essential diff --git a/production/docker/tx-indexer/Dockerfile b/production/docker/tx-indexer/Dockerfile index 1d304ff..0b883aa 100644 --- a/production/docker/tx-indexer/Dockerfile +++ b/production/docker/tx-indexer/Dockerfile @@ -1,13 +1,53 @@ -FROM node:20-alpine +# Create a Dockerized tx indexer +# +#IMAGE BUILD COMMANDS +FROM ubuntu:24.04 +MAINTAINER Chris Troutner + +#Update the OS and install any OS packages needed. +RUN apt-get update +RUN apt-get install -y sudo git curl nano gnupg wget zip unzip python3 + +#Install Node and NPM +RUN curl -sL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh +RUN bash nodesource_setup.sh +RUN apt-get install -y nodejs build-essential + +#Create the user 'safeuser' and add them to the sudo group. +RUN useradd -ms /bin/bash safeuser +RUN adduser safeuser sudo + +#Set password to 'password' change value below if you want a different password +RUN echo safeuser:password | chpasswd + +#Set the working directory to be the home directory +WORKDIR /home/safeuser + +#Setup NPM for non-root global install +RUN mkdir /home/safeuser/.npm-global +RUN chown -R safeuser .npm-global +RUN echo "export PATH=~/.npm-global/bin:$PATH" >> /home/safeuser/.profile +RUN runuser -l safeuser -c "npm config set prefix '~/.npm-global'" + +# Clone the psf-memo-indexer repository +WORKDIR /home/safeuser +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 -COPY package*.json ./ -RUN npm ci --omit=dev +# For development: switch to unstable branch +#RUN git checkout -COPY . . +# Install dependencies +RUN npm install +# Expose the port the API will be served on. EXPOSE 5455 +# Start the application. +# start-tx-indexer.sh is mounted at runtime via docker-compose. VOLUME start-tx-indexer.sh CMD ["./start-tx-indexer.sh"]