diff --git a/docker/Dockerfile b/docker/Dockerfile index 8448ef17..1784e250 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,20 +4,12 @@ LABEL maintainer="dave@force9.org" ENV NVM_DIR /root/.nvm ENV DEBIAN_FRONTEND noninteractive - -# enigma storage mounts -VOLUME /enigma-bbs/art -VOLUME /enigma-bbs/config -VOLUME /enigma-bbs/db -VOLUME /enigma-bbs/filebase -VOLUME /enigma-bbs/logs -VOLUME /enigma-bbs/mods -VOLUME /mail - 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 \ @@ -29,18 +21,35 @@ RUN apt-get update && apt-get install -y \ 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 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 +# enigma storage mounts +VOLUME /enigma-bbs/art +VOLUME /enigma-bbs/config +VOLUME /enigma-bbs/db +VOLUME /enigma-bbs/filebase +VOLUME /enigma-bbs/logs +VOLUME /enigma-bbs/mods +VOLUME /mail + # Enigma default port EXPOSE 8888 WORKDIR /enigma-bbs -CMD ["pm2-runtime", "main.js"] +ENTRYPOINT ["/enigma-bbs/docker/bin/docker-entrypoint.sh"] \ No newline at end of file diff --git a/docker/bin/docker-entrypoint.sh b/docker/bin/docker-entrypoint.sh new file mode 100644 index 00000000..1e0927d2 --- /dev/null +++ b/docker/bin/docker-entrypoint.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +prepopvols=("config" "mods" "art") +bbspath=/enigma-bbs +bbsstgp=/enigma-bbs-pre +if [[ ! -f $bbspath/config/config.hjson ]]; then + for dir in "${prepopvols[@]}" + do + if [ -n "$(find "$bbspath/$dir" -maxdepth 0 -type d -empty 2>/dev/null)" ]; then + cp -rp $bbsstgp/$dir/* $bbspath/$dir/ + else + echo "WARN skipped $bbspath/$dir - vol Not empty/not a new setup - possible bad state" + fi + done + ./oputil.js config new +fi +pm2-runtime main.js \ No newline at end of file diff --git a/docs/installation/docker.md b/docs/installation/docker.md index 5510bc6c..39ce70df 100644 --- a/docs/installation/docker.md +++ b/docs/installation/docker.md @@ -6,20 +6,39 @@ 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 --rm -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: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 --rm -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:latest +``` -- 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 - ``` +:bulb: Configuration will be stored in `$(pwd)/enigma-bbs/config`. -- 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 `${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