From 6bc37900d826005a6c2b40950d4726cf32fa8ac4 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 10 Oct 2024 17:41:47 +0800 Subject: [PATCH] doc: update README --- .env.sample | 38 ++++++++++++++++++ README.md | 94 +++++++++++--------------------------------- server/src/config.ts | 2 +- 3 files changed, 62 insertions(+), 72 deletions(-) create mode 100644 .env.sample diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..a389a42 --- /dev/null +++ b/.env.sample @@ -0,0 +1,38 @@ +HOST=localhost +PORT=3000 +BASE_URL=http://localhost:5173 +BACKEND_URL=http://localhost:3000 +MONGO_URL=mongodb://localhost:27017/odyssey-test +SECRET_KEY=sample-secret + +# Optional +# CONTAINER_EXPIRY=60 # 60 minutes +# SESSION_MAX_AGE=168 # 7 days +# TRUSTED_PROXIES=1.2.3.4 +# valid configurations see isIP & isIPRange in https://github.com/validatorjs/validator.js?tab=readme-ov-file#validators + +# GOOGLE_CLIENT_ID= +# GOOGLE_CLIENT_SECRET= +# GITHUB_CLIENT_ID= +# GITHUB_CLIENT_SECRET= +# SURVEY_URL= +# BUG_REPORT_URL= +# DOCKER_NETWORK= + +# SURVEY_URL= +# BUG_REPORT_URL= + +# Docker related config +# DOCKER_NETWORK=host +# QUEST_IMAGE=linuxodyssey/quest-base +# DOCKER_PREFIX=linuxodyssey/quest- + +# To mount quest folder from host into container, for development purpose +# MOUNT_QUEST=true + +# LOG_PATH= + +# Testing, create a user with the following credentials, disable rate limiting +# TESTING=true +# TESTING_USERNAME=alex +# TESTING_PASSWORD=Alex1234 \ No newline at end of file diff --git a/README.md b/README.md index 0e68ddc..2873065 100644 --- a/README.md +++ b/README.md @@ -9,15 +9,18 @@ - Docker - Yarn: v1.22 +## Known Issues + +- The player's terminal doesn't work correctly on Mac OS and Windows for now. Please use Linux or Virtual Machines. You can track [this issue](https://github.com/linux-odyssey/linux-odyssey/issues/165) for updates. +- MongoDB requires x86 architecture to run for v5+ versions. You can track [this issue](https://github.com/linux-odyssey/linux-odyssey/issues/166) for updates. + ## Installation git clone https://github.com/lancatlin/linux-odyssey.git cd linux-odyssey yarn install -## Development - -### Project Structures +## Project Structures 1. **app**: frontend 2. **server**: backend @@ -94,17 +97,27 @@ You can edit the files on your host, and the changes will be reflected in the co MOUNT_QUEST=true -### Development +## Development -Build up dependencies: +Copy `.env.sample` to `.env` and customize it for your needs. - yarn build:deps +Build the whole project for the first time: + + yarn build + +This will build the typescript for each package and the server. Run dev server (frontend, backend): yarn dev -If you want to enable social login, you should have OAuth client token in a `.env` file: +**IMPORTANT NOTE**: only the app and server have hot-reloading, other packages require manually running `yarn dev` in each package. + +To develop analytics dashboard: + + yarn analytics + +The default username and password is `alex` and `Alex1234`. ## Testing @@ -124,8 +137,9 @@ Run Cypress in container, create brand-new containers along with it: # tearing off the containers ./docker-scripts.sh down -### Deployment +## Deployment + # Build the images (only allowed for maintainers) docker compose -f docker-compose.prod.yml build docker compose -f docker-compose.prod.yml push @@ -134,66 +148,4 @@ Run Cypress in container, create brand-new containers along with it: docker compose -f docker-compose.prod.yml up -d To enable social login, you should have OAuth client token in a `.env` file: -You can copy from `example.env` - - # .env - BASE_URL=https://example.com - GOOGLE_CLIENT_ID=... - GOOGLE_CLIENT_SECRET=... - -To enable it: - - docker compose --env-file .env -f docker-compose.prod.yml up -d - -## Standalone App (without Docker) - -Source: `app/` - - # Connect to dev server (https://odyssey.wancat.cc) - yarn app - - # Connect to localhost (http://localhost:3000) - yarn app:local - - # Connect to anyhost - API_ENDPOINT=http://example.com yarn app:local - -## Swagger - - docker compose up -d swagger - -Open http://localhost:8080 to open Swagger - -## CLI terminal client (Docker not required) - - yarn cli - Usage: client [options] [command] - - Options: - -s, --session Session ID - -c, --create Create a new session - -h, --host Server host (default: "http://localhost:3000") - --help display help for command - - Commands: - list List all sessions - -connet to recent session: - - yarn cli - -connect to new session: - - yarn cli -c - -connect to specific session: - - yarn cli -s 64d0de0367459c13004bc83f - -connect to other host: - - yarn cli -h https://example.com - -list sessions: - - yarn cli list +You can copy from `.env.sample` diff --git a/server/src/config.ts b/server/src/config.ts index 76274bc..63af4dd 100644 --- a/server/src/config.ts +++ b/server/src/config.ts @@ -70,7 +70,7 @@ function createConfig() { projectRoot: getProjectRoot(), log: { - path: get('LOG_PATH', '../logs'), + path: get('LOG_PATH', path.join(getProjectRoot(), 'logs')), }, testing: { enabled: !isProduction && process.env.TESTING === 'true',