From 1c2bcb5837026cc2f179c5d9c9ec289d6989679b Mon Sep 17 00:00:00 2001 From: Lualt Date: Thu, 18 Jul 2024 04:23:05 +0200 Subject: [PATCH] added dockerfile and instructions --- .dockerignore | 30 ++++++++++++++++++++++++++++++ Dockerfile | 15 +++++++++++++++ README.md | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 README.md diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8806bd5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitattributes +**/.gitignore +**/.github +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/.next +**/.cache +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/charts +**/docker-compose* +**/compose.y*ml +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +**/build +**/dist +LICENSE +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d6e6aea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +ARG NODE_VERSION=18.0.0 + +FROM node:${NODE_VERSION} + +WORKDIR /usr/src/app + +RUN --mount=type=bind,source=package.json,target=package.json \ + --mount=type=bind,source=package-lock.json,target=package-lock.json \ + --mount=type=cache,target=/root/.npm \ + npm ci + +COPY . . + +EXPOSE 8000 +CMD npm run start diff --git a/README.md b/README.md new file mode 100644 index 0000000..c284314 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# Pipe-Bomb-Server +### Docker instructions +Before we run the server you will have to build the pipe bomb docker image by doing; +``` +$ docker build -t "pipe-bomb-server" . +``` +After the image is built you want to find a place to put the container in, personally I will do it in `~/docker/pipe-bomb-server`. In the directory of your choosing make a `compose.yml` file which should look something like this. +```yaml +services: + pipe-bomb-server: + image: pipe-bomb-server + container_name: pipe-bomb-server + ports: + - "8000:8000" + # volumes: + # - ./Config.json:/usr/src/app/Config.json + # # the database has a volume incase you want to move/backup or do anything else with the files + # - ./database/music.db:/usr/src/app/music.db + # - ./database/music.db-smh:/usr/src/app/music.db-shm + # - ./database/music.db-wal:/usr/src/app/music.db-wal + restart: unless-stopped +``` +Keep the volumes commented out at first so we can let pipe bomb generate the files needed for the volumes, to let pipe bomb generate them run the following command. +``` +$ docker compose up +``` +When you see something like the line `API is listening on ___` it's done staring up and generating the files, you can now safely do `CTRL-c` to stop the server. Now we can uncomment the volumes but before we can run it again we must copy the generated files over. +``` +$ docker cp pipe-bomb-server:/usr/src/app/Config.json . +$ mkdir database +$ docker cp pipe-bomb-server:/usr/src/app/music.db ./database/music.db +$ docker cp pipe-bomb-server:/usr/src/app/music.db-shm ./database/music.db-shm +$ docker cp pipe-bomb-server:/usr/src/app/music.db-wal ./database/music.db-wal +``` +Feel free to edit the config as you like and once you are done with that you can run the server by doing this command (-d will run it in the background) +``` +$ docker compose up +```