Merge pull request #386 from abutbul/master

fix docker implementation
This commit is contained in:
Bryan Ashby 2022-01-29 18:14:17 -07:00 committed by GitHub
commit 65efe7c1e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 21 deletions

View File

@ -1,32 +1,43 @@
FROM node:lts-buster-slim
FROM node:12-buster-slim
LABEL maintainer="dave@force9.org"
ENV NVM_DIR /root/.nvm
ENV DEBIAN_FRONTEND noninteractive
COPY . /enigma-bbs
# Do some installing!
RUN apt-get update && apt-get install -y \
# Do some installing! (and alot of cleaning up) keeping it in one step for less docker layers
# - if you need to debug i recommend to break the steps with individual RUNs)
RUN apt-get update \
&& apt-get install -y \
git \
curl \
build-essential \
python \
python3 \
libssl-dev \
lrzsz \
arj \
lhasa \
unrar-free \
p7zip-full \
&& npm install -g pm2 \
&& cd /enigma-bbs && npm install --only=production \
&& apt-get remove build-essential python libssl-dev git curl -y && apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& apt-get clean
&& npm install -g pm2 \
&& cd /enigma-bbs && npm install --only=production \
&& pm2 start main.js \
&& mkdir -p /enigma-bbs-pre/art \
&& mkdir /enigma-bbs-pre/mods \
&& mkdir /enigma-bbs-pre/config \
&& cp -rp art/* ../enigma-bbs-pre/art/ \
&& cp -rp mods/* ../enigma-bbs-pre/mods/ \
&& cp -rp config/* ../enigma-bbs-pre/config/ \
&& apt-get remove build-essential python python3 libssl-dev git curl -y \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& apt-get clean
# sexyz
COPY docker/bin/sexyz /usr/local/bin
RUN chmod +x /enigma-bbs/docker/bin/docker-entrypoint.sh
# enigma storage mounts
VOLUME /enigma-bbs/art
@ -42,4 +53,4 @@ EXPOSE 8888
WORKDIR /enigma-bbs
CMD ["pm2-runtime", "main.js"]
ENTRYPOINT ["/enigma-bbs/docker/bin/docker-entrypoint.sh"]

View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e
# Set some vars
PRE_POPULATED_VOLUMES=("config" "mods" "art") # These are folders which contain runtime needed files, and need to be represented in the host
BBS_ROOT_DIR=/enigma-bbs # Install location
BBS_STAGING_PATH=/enigma-bbs-pre # Staging location for pre populated volumes (PRE_POPULATED_VOLUMES)
CONFIG_NAME=config.hjson # This is the default name, this script is intended for easy get-go - make changes as needed
# Setup happens when there is no existing config file
if [[ ! -f $BBS_ROOT_DIR/config/$CONFIG_NAME ]]; then
for VOLUME in "${PRE_POPULATED_VOLUMES[@]}"
do
if [ -n "$(find "$BBS_ROOT_DIR/$VOLUME" -maxdepth 0 -type d -empty 2>/dev/null)" ]; then
cp -rp $BBS_STAGING_PATH/$VOLUME/* $BBS_ROOT_DIR/$VOLUME/
else
printf "WARN: skipped $BBS_ROOT_DIR/$VOLUME: Volume not empty or not a new setup; Files required to run ENiGMA 1/2 may be missing.\n Possible bad state\n"
printf "INFO: You have mounted folders with existing data - but no existing config json.\n\nPossible solutions:\n1. Make sure all volumes are set correctly specifically config volume... \n2. Check your configuration name if non-default\n\n\n"
fi
done
./oputil.js config new
fi
if [[ ! -f $BBS_ROOT_DIR/config/$CONFIG_NAME ]]; then # Make sure once more, otherwise pm2-runtime will loop if missing the config
printf "ERROR: Missing configuration - ENiGMA 1/2 will not work. please run config\n"
exit 1
else
exec pm2-runtime main.js
fi

View File

@ -6,20 +6,43 @@ title: Docker
for every operating system on the [Docker website](https://docs.docker.com/engine/install/).**
## Quick Start
prepare a folder where you are going to save your bbs files.
- Generate some config for your BBS: \
you can perform this step from anywhere - but make sure to consistently run it from the same place to retain your config inside the docker guest
```
docker run -it -p 8888:8888 \
--name " ENiGMABBS" \
-v "$(pwd)/config:/enigma-bbs/config" \
-v "$(pwd)/db:/enigma-bbs/db" \
-v "$(pwd)/logs:/enigma-bbs/logs" \
-v "$(pwd)/filebase:/enigma-bbs/filebase" \
-v "$(pwd)/art:/enigma-bbs/art" \
-v "$(pwd)/mods:/enigma-bbs/mods" \
-v "$(pwd)/mail:/mail" \
enigmabbs/enigmabbs:latest
```
- Run it: \
you can use the same command as above, just daemonize and drop interactiveness (we needed it for config but most of the time docker will run in the background)
````
docker run -d -p 8888:8888 \
--name "ENiGMABBS" \
-v "$(pwd)/config:/enigma-bbs/config" \
-v "$(pwd)/db:/enigma-bbs/db" \
-v "$(pwd)/logs:/enigma-bbs/logs" \
-v "$(pwd)/filebase:/enigma-bbs/filebase" \
-v "$(pwd)/art:/enigma-bbs/art" \
-v "$(pwd)/mods:/enigma-bbs/mods" \
-v "$(pwd)/mail:/mail" \
enigmabbs/enigmabbs:latest
````
- Restarting and Making changes\
if you make any changes to your host config folder they will persist, and you can just restart ENiGMABBS container to load any changes you've made.
- Generate some config for your BBS:
```
docker run -it -v "${HOME}/enigma-bbs/config:/enigma-bbs/config" enigmabbs/enigma-bbs:latest oputil.js config new
```
```docker restart ENiGMABBS```
- Run it:
```
docker run -p 8888:8888 -v "${HOME}/enigma-bbs/config:/enigma-bbs/config" enigmabbs/enigma-bbs:latest
```
:bulb: Configuration will be stored in `$(pwd)/enigma-bbs/config`.
:bulb: Configuration will be stored in `${HOME}/enigma-bbs/config`.
:bulb: Windows users - you'll need to switch out `${HOME}/enigma-bbs/config` for a Windows-style path.
:bulb: Windows users - you'll need to switch out `$(pwd)/enigma-bbs/config` for a Windows-style path.
## Volumes