From 9ed605774a9eb2e09117df4907be646e96521b0d Mon Sep 17 00:00:00 2001 From: SuperMarioDaBom Date: Fri, 14 Jul 2023 01:28:46 -0700 Subject: [PATCH 1/5] Update Dockerfile to properly reflect needs, remove unneeded files --- Dockerfile | 11 +++-------- docker/entrypoint.sh | 28 ---------------------------- 2 files changed, 3 insertions(+), 36 deletions(-) delete mode 100644 docker/entrypoint.sh diff --git a/Dockerfile b/Dockerfile index a810a907..091b6082 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,11 @@ -FROM node:18-alpine +FROM node:20.4.0-alpine3.18 -RUN apk add --no-cache python3 make gcc g++ WORKDIR /app -COPY "docker/entrypoint.sh" ./ - COPY package*.json ./ -RUN npm install bcrypt && npm rebuild bcrypt --build-from-source RUN npm install COPY . ./ +RUN npm run build -VOLUME [ "/app/config.json", "/app/certs" ] - -CMD ["sh", "entrypoint.sh"] +CMD npm start \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh deleted file mode 100644 index 2c6aa028..00000000 --- a/docker/entrypoint.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -# this doesnt check game server specific certs, only static file paths -files='config.json' - -for file in $files; do - if [ ! -f $file ]; then - echo "$PWD/$file file does not exist. Please mount and try again." - exit 1 - fi -done - -# check for keys -keys='certs/nex/datastore/secret.key certs/service/account/secret.key certs/service/account/aes.key certs/service/account/private.pem certs/service/account/public.pem' -for file in $keys; do - if [ ! -f "$file" ]; then - if [ x"${GENERATE_NEW_KEYS}" = "x" ]; then - echo "$PWD/$file file does not exist. Please mount and try again." - exit 1 - else - echo "$PWD/$file file does not exist. Generating a temporary one" - node generate-keys.js nex datastore - node generate-keys.js account - fi - fi -done - -exec node src/server.js From 93c0f5e7a29a7be0ae89d5d5b01f9c119a0f9e55 Mon Sep 17 00:00:00 2001 From: SuperMarioDaBom Date: Mon, 17 Jul 2023 00:03:38 -0700 Subject: [PATCH 2/5] So I don't accidentally push data generated by the server in Docker --- .dockerignore | 2 ++ .gitignore | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 7a2fc0a1..92e4cf83 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,3 +4,5 @@ logs certs cdn node_modules +*.yaml +*.yml \ No newline at end of file diff --git a/.gitignore b/.gitignore index bd3afc3a..3d37cdbf 100644 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,8 @@ typings/ config.json certs cdn -dist \ No newline at end of file +dist +*.yaml +*.yml +data +datastore \ No newline at end of file From d11dc27f044bd6c0da0deefa3849966ed5026d26 Mon Sep 17 00:00:00 2001 From: SuperMarioDaBom Date: Mon, 17 Jul 2023 00:04:39 -0700 Subject: [PATCH 3/5] Begin notes on setting up using Docker --- DOCKER.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ SETUP.md | 3 +++ 2 files changed, 73 insertions(+) create mode 100644 DOCKER.md diff --git a/DOCKER.md b/DOCKER.md new file mode 100644 index 00000000..f7e55831 --- /dev/null +++ b/DOCKER.md @@ -0,0 +1,70 @@ +# Setup using Docker + +## Overview +To use this, you must have Docker installed on your system. Please follow a tutorial elsewhere. + +After performing installation, you will have the following running containers: +- mongodb (the database) +- account (the account server itself) + +## Building the image +Use the following command to build the image: +```bash +$ docker build -t account . +``` + +## Running Using `docker run` +Create a `.env` file with all of the environment variables set. The list of variables can be found in [SETUP.md](SETUP.md). + +Use a command similar to the following: +```bash +$ docker run --name mongodb -i -p 27017:27017 -t -e MONGODB_INITDB_ROOT_USERNAME=user -e MONGODB_INITDB_ROOT_PASSWORD=pass -v $(pwd)/data:/data/db mongo +$ docker run --name account -i -p 7070:7070 -p 7071:7071 -t -v $(pwd)/cdn:/app/cdn -v $(pwd)/datastore:/app/certs/nex/datastore --env-file .env account +``` + +## Running Using `docker compose` +This is an example `docker-compose.yaml` file that will set up the containers, configure them, and launch them: + +```yaml +services: + mongodb: + image: mongo + container_name: mongodb + ports: + - "27017:27017" + environment: + MONGODB_INITDB_ROOT_USERNAME: "user" + MONGODB_INITDB_ROOT_PASSWORD: "pass" + volumes: + - "${PWD}/data:/data/db" + networks: + - pretendo_web + account: + image: account + container_name: account + ports: + - "7070:7070" + - "7071:7071" + environment: + PN_ACT_PREFER_ENV_CONFIG: "true" + PN_ACT_CONFIG_HTTP_PORT: "7070" + PN_ACT_CONFIG_MONGO_CONNECTION_STRING: "mongodb://mongodb:27017/pretendo" + PN_ACT_CONFIG_CDN_BASE_URL: "http://pretendoacct.local" + PN_ACT_CONFIG_CDN_SUBDOMAIN: "cdn" + PN_ACT_CONFIG_CDN_DISK_PATH: "./cdn" + PN_ACT_CONFIG_WEBSITE_BASE: "https://example.com" + PN_ACT_CONFIG_AES_KEY: "abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789" + PN_ACT_CONFIG_GRPC_MASTER_API_KEY_ACCOUNT: "apikey" + PN_ACT_CONFIG_GRPC_MASTER_API_KEY_API: "apikey" + PN_ACT_CONFIG_GRPC_PORT: "7071" + volumes: + - "${PWD}/cdn:/app/cdn" + - "${PWD}/datastore:/app/certs/nex/datastore" + networks: + - pretendo_web + +networks: + pretendo_web: + driver: bridge + attachable: true +``` \ No newline at end of file diff --git a/SETUP.md b/SETUP.md index 1aeaba25..5f56b887 100644 --- a/SETUP.md +++ b/SETUP.md @@ -1,5 +1,6 @@ # Setup +- [Docker](#docker) - [Required software](#required-software) - [NodeJS](#nodejs) - [MongoDB](#mongodb) @@ -11,6 +12,8 @@ - [CDN](#cdn) - [Configuration](#configuration) +## Docker +If using Docker, please see [DOCKER.md](DOCKER.md) for setup instructions. ## Required software From 3a21f7c83d9260aa9b231db716cca702e2c4e9d0 Mon Sep 17 00:00:00 2001 From: SuperMarioDaBom Date: Mon, 17 Jul 2023 00:10:18 -0700 Subject: [PATCH 4/5] Update DOCKER.md Fix typo --- DOCKER.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DOCKER.md b/DOCKER.md index f7e55831..11962dfb 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -3,7 +3,7 @@ ## Overview To use this, you must have Docker installed on your system. Please follow a tutorial elsewhere. -After performing installation, you will have the following running containers: +After performing the following steps, you will have the following running containers: - mongodb (the database) - account (the account server itself) @@ -67,4 +67,4 @@ networks: pretendo_web: driver: bridge attachable: true -``` \ No newline at end of file +``` From ddc5182e714a50fdefa257bea8c0fa920948fbb9 Mon Sep 17 00:00:00 2001 From: SuperMarioDaBom Date: Sat, 14 Oct 2023 10:25:53 -0700 Subject: [PATCH 5/5] Remove Datastore token from Docker instructions --- DOCKER.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DOCKER.md b/DOCKER.md index 11962dfb..630ce72f 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -18,8 +18,8 @@ Create a `.env` file with all of the environment variables set. The list of vari Use a command similar to the following: ```bash -$ docker run --name mongodb -i -p 27017:27017 -t -e MONGODB_INITDB_ROOT_USERNAME=user -e MONGODB_INITDB_ROOT_PASSWORD=pass -v $(pwd)/data:/data/db mongo -$ docker run --name account -i -p 7070:7070 -p 7071:7071 -t -v $(pwd)/cdn:/app/cdn -v $(pwd)/datastore:/app/certs/nex/datastore --env-file .env account +$ docker run --name mongodb -d -p 27017:27017 -e MONGODB_INITDB_ROOT_USERNAME=user -e MONGODB_INITDB_ROOT_PASSWORD=pass -v $(pwd)/data:/data/db mongo +$ docker run --name account -d -p 7070:7070 -p 7071:7071 -v $(pwd)/cdn:/app/cdn --env-file .env account ``` ## Running Using `docker compose` @@ -59,7 +59,6 @@ services: PN_ACT_CONFIG_GRPC_PORT: "7071" volumes: - "${PWD}/cdn:/app/cdn" - - "${PWD}/datastore:/app/certs/nex/datastore" networks: - pretendo_web