first commit

This commit is contained in:
Chris Troutner
2025-11-09 16:16:37 -08:00
commit ba2afd47a4
61 changed files with 13847 additions and 0 deletions
+85
View File
@@ -0,0 +1,85 @@
# Create a Dockerized API server
#
#IMAGE BUILD COMMANDS
# ct-base-ubuntu = ubuntu 18.04 + nodejs v10 LTS
#FROM christroutner/ct-base-ubuntu
FROM ubuntu:22.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_20.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'"
# Update to the latest version of npm.
#RUN npm install -g npm@8.3.0
# npm mirror to prevent direct dependency on npm.
#RUN npm set registry http://94.130.170.209:4873/
# Switch to user account.
#USER safeuser
# Prep 'sudo' commands.
#RUN echo 'abcd8765' | sudo -S pwd
#RUN npm install -g node-gyp
# Clone the rest.bitcoin.com repository
WORKDIR /home/safeuser
RUN git clone https://github.com/christroutner/REST2NOSTR
# Switch to the desired branch. `master` is usually stable,
# and `stage` has the most up-to-date changes.
WORKDIR /home/safeuser/REST2NOSTR
# For development: switch to unstable branch
#RUN git checkout pin-ipfs
# Install dependencies
RUN npm install
# Generate the API docs
RUN npm run docs
#VOLUME /home/safeuser/keys
# Make leveldb folders
#RUN mkdir leveldb
#WORKDIR /home/safeuser/psf-slp-indexer/leveldb
#RUN mkdir current
#RUN mkdir zips
#RUN mkdir backup
#WORKDIR /home/safeuser/psf-slp-indexer/leveldb/zips
#COPY restore-auto.sh restore-auto.sh
#WORKDIR /home/safeuser/psf-slp-indexer
# Expose the port the API will be served on.
#EXPOSE 5011
# Start the application.
#COPY start-production.sh start-production.sh
VOLUME start-rest2nostr.sh
CMD ["./start-rest2nostr.sh"]
#CMD ["npm", "start"]
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash
# Remove all untagged docker images.
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
+19
View File
@@ -0,0 +1,19 @@
# Start the service with the command 'docker-compose up -d'
services:
rest2nostr:
build: .
container_name: rest2nostr
logging:
driver: 'json-file'
options:
max-size: '10m'
max-file: '10'
#mem_limit: 500mb
#links:
# - mongo-slp-indexer
ports:
- '5942:5942' # <host port>:<container port>
volumes:
- ./start-rest2nostr.sh:/home/safeuser/REST2NOSTR/start-rest2nostr.sh
restart: always
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
npm start