mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo-indexer.git
synced 2026-09-21 16:52:02 -07:00
fix(Docker): Adding front end client
This commit is contained in:
@@ -2,9 +2,7 @@
|
||||
|
||||
services:
|
||||
memo-db:
|
||||
build:
|
||||
context: ../../psf-memo-db
|
||||
dockerfile: ./memo-db/Dockerfile
|
||||
build: ./memo-db
|
||||
container_name: memo-db
|
||||
logging:
|
||||
driver: json-file
|
||||
@@ -50,3 +48,15 @@ services:
|
||||
- ./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
|
||||
|
||||
memo-client:
|
||||
build: ./memo-client
|
||||
container_name: memo-client
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 10m
|
||||
max-file: '10'
|
||||
ports:
|
||||
- '3000:80'
|
||||
restart: always
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# Create a Dockerized front-end SPA served by nginx
|
||||
#
|
||||
|
||||
#IMAGE BUILD COMMANDS
|
||||
FROM ubuntu:22.04 as builder
|
||||
MAINTAINER Chris Troutner <chris.troutner@gmail.com>
|
||||
|
||||
#Update the OS and install any OS packages needed.
|
||||
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 bash nodesource_setup.sh
|
||||
RUN apt-get install -y nodejs build-essential
|
||||
|
||||
#Set the working directory to be the home directory
|
||||
WORKDIR /home/safeuser
|
||||
|
||||
# Clone the psf-memo-client repository
|
||||
RUN git clone https://github.com/Permissionless-Software-Foundation/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
|
||||
|
||||
# For development: switch to unstable branch
|
||||
#RUN git checkout unstable
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Build the site
|
||||
RUN npm run build
|
||||
|
||||
# Load the NGINX image.
|
||||
FROM nginx
|
||||
EXPOSE 80
|
||||
|
||||
# Copy the files built in the first container to the new NGINX container.
|
||||
COPY --from=builder /home/safeuser/psf-memo-client/build /usr/share/nginx/html
|
||||
|
||||
# Copy the NGINX configuration file.
|
||||
COPY default.conf /etc/nginx/conf.d/default.conf
|
||||
@@ -0,0 +1,22 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
#error_page 404 /404.html;
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
#
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,56 @@
|
||||
FROM node:20-alpine
|
||||
# Create a Dockerized API server
|
||||
#
|
||||
|
||||
#IMAGE BUILD COMMANDS
|
||||
FROM ubuntu:24.04
|
||||
MAINTAINER Chris Troutner <chris.troutner@gmail.com>
|
||||
|
||||
#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-db repository
|
||||
WORKDIR /home/safeuser
|
||||
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
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
# For development: switch to unstable branch
|
||||
#RUN git checkout <branch-name>
|
||||
|
||||
COPY . .
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Generate the API docs
|
||||
RUN npm run docs
|
||||
|
||||
# Expose the port the API will be served on.
|
||||
EXPOSE 5021
|
||||
|
||||
# Start the application.
|
||||
# start-memo-db.sh is mounted at runtime via docker-compose.
|
||||
VOLUME start-memo-db.sh
|
||||
CMD ["./start-memo-db.sh"]
|
||||
|
||||
Reference in New Issue
Block a user