Bumps the npm_and_yarn group with 2 updates in the / directory: [braces](https://github.com/micromatch/braces) and [nanoid](https://github.com/ai/nanoid). Updates `braces` from 3.0.2 to 3.0.3 <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/micromatch/braces/commit/74b2db2938fad48a2ea54a9c8bf27a37a62c350d"><code>74b2db2</code></a> 3.0.3</li> <li><a href="https://github.com/micromatch/braces/commit/88f1429a0f47e1dd3813de35211fc97ffda27f9e"><code>88f1429</code></a> update eslint. lint, fix unit tests.</li> <li><a href="https://github.com/micromatch/braces/commit/415d660c3002d1ab7e63dbf490c9851da80596ff"><code>415d660</code></a> Snyk js braces 6838727 (<a href="https://redirect.github.com/micromatch/braces/issues/40">#40</a>)</li> <li><a href="https://github.com/micromatch/braces/commit/190510f79db1adf21d92798b0bb6fccc1f72c9d6"><code>190510f</code></a> fix tests, skip 1 test in test/braces.expand</li> <li><a href="https://github.com/micromatch/braces/commit/716eb9f12d820b145a831ad678618731927e8856"><code>716eb9f</code></a> readme bump</li> <li><a href="https://github.com/micromatch/braces/commit/a5851e57f45c3431a94d83fc565754bc10f5bbc3"><code>a5851e5</code></a> Merge pull request <a href="https://redirect.github.com/micromatch/braces/issues/37">#37</a> from coderaiser/fix/vulnerability</li> <li><a href="https://github.com/micromatch/braces/commit/2092bd1fb108d2c59bd62e243b70ad98db961538"><code>2092bd1</code></a> feature: braces: add maxSymbols (<a href="https://github.com/micromatch/braces/issues/">https://github.com/micromatch/braces/issues/</a>...</li> <li><a href="https://github.com/micromatch/braces/commit/9f5b4cf47329351bcb64287223ffb6ecc9a5e6d3"><code>9f5b4cf</code></a> fix: vulnerability (<a href="https://security.snyk.io/vuln/SNYK-JS-BRACES-6838727">https://security.snyk.io/vuln/SNYK-JS-BRACES-6838727</a>)</li> <li><a href="https://github.com/micromatch/braces/commit/98414f9f1fabe021736e26836d8306d5de747e0d"><code>98414f9</code></a> remove funding file</li> <li><a href="https://github.com/micromatch/braces/commit/665ab5d561c017a38ba7aafd92cc6655b91d8c14"><code>665ab5d</code></a> update keepEscaping doc (<a href="https://redirect.github.com/micromatch/braces/issues/27">#27</a>)</li> <li>Additional commits viewable in <a href="https://github.com/micromatch/braces/compare/3.0.2...3.0.3">compare view</a></li> </ul> </details> <br /> Updates `nanoid` from 3.3.7 to 3.3.11 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/ai/nanoid/releases">nanoid's releases</a>.</em></p> <blockquote> <h2>3.3.11</h2> <ul> <li>Fixed React Native support.</li> </ul> <h2>3.3.10</h2> <ul> <li>Fixed React Native support (by <a href="https://github.com/steida"><code>@steida</code></a>).</li> </ul> <h2>3.3.9</h2> <ul> <li>Reduced npm package size.</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/ai/nanoid/blob/main/CHANGELOG.md">nanoid's changelog</a>.</em></p> <blockquote> <h2>3.3.11</h2> <ul> <li>Fixed React Native support.</li> </ul> <h2>3.3.10</h2> <ul> <li>Fixed React Native support (by <a href="https://github.com/steida"><code>@steida</code></a>).</li> </ul> <h2>3.3.9</h2> <ul> <li>Reduced npm package size.</li> </ul> <h2>3.3.8</h2> <ul> <li>Fixed a way to break Nano ID by passing non-integer size (by <a href="https://github.com/myndzi"><code>@myndzi</code></a>).</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/ai/nanoid/commit/37289ceee51a3194a1f121a1e5d2bbb864076b74"><code>37289ce</code></a> Release 3.3.11 version</li> <li><a href="https://github.com/ai/nanoid/commit/23690b77719ec8043c2509d28c1d74b0e2295b75"><code>23690b7</code></a> Fix CI</li> <li><a href="https://github.com/ai/nanoid/commit/c147962de7f5da3311a0e731030a28f49c5266a3"><code>c147962</code></a> Fix RN support</li> <li><a href="https://github.com/ai/nanoid/commit/a83734e28fa071f51fe3614a5fb891f08a4b91b2"><code>a83734e</code></a> Move to manually ESM/CJS dual package</li> <li><a href="https://github.com/ai/nanoid/commit/bb12e8a6f9c37ebe0b5ff2c697b8f9dcf34c8948"><code>bb12e8a</code></a> Release 3.3.10 version</li> <li><a href="https://github.com/ai/nanoid/commit/8f44264cd724080447f40620974163f1daca4612"><code>8f44264</code></a> Fix Expo support</li> <li><a href="https://github.com/ai/nanoid/commit/adf9b0c05eeeebbbf391c16bbd93da2fc275e235"><code>adf9b0c</code></a> Release 3.3.9 version</li> <li><a href="https://github.com/ai/nanoid/commit/1c6f08825b4f17c4462bd1c19dbc3f1c5626b76f"><code>1c6f088</code></a> Remove dev file from npm package</li> <li><a href="https://github.com/ai/nanoid/commit/3044cd5e73f4cf31795f61f6e6b961c8c0a5c744"><code>3044cd5</code></a> Release 3.3.8 version</li> <li><a href="https://github.com/ai/nanoid/commit/4fe34959c34e5b3573889ed4f24fe91d1d3e7231"><code>4fe3495</code></a> Update size limit</li> <li>Additional commits viewable in <a href="https://github.com/ai/nanoid/compare/3.3.7...3.3.11">compare view</a></li> </ul> </details> <br /> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/linux-odyssey/linux-odyssey/network/alerts). </details>
Linux Odyssey
Requirements
- NodeJS v20+
- Docker
- Yarn: v1.22
Known Issues
- MongoDB requires x86 architecture to run for v5+ versions. You can track this issue for updates.
Windows user please refer to docs/windows-setup.md for setup instructions.
Installation
git clone https://github.com/lancatlin/linux-odyssey.git
cd linux-odyssey
yarn install
Project Structures
- app: frontend
- server: backend
- quests: tutorials scripts for each quest
- packages: other packages
- analytics: admin dashboard to analyze collected data
- constants: some shared config values for app and server
- container: the script run in container to capture users' command
- file-graph: the algorithm to construct and modify file graph, used in both app and server
- models: definitions of MondoDB collections (data schema)
- utils: other utility code shared between packages
- game (in the future): core logic of game playing, will be extracted from server
Configuration
The configuration is stored in the .env file. You can copy from the sample file.
cp .env.sample .env
The backend will use a SSH key pair to login to the player's container. The private key is on the host, and the public key is copied to the player's container.
The key pair is stored in ./config/ssh_key and ./config/ssh_key.pub. If it doesn't exist, the backend will generate a new pair and store them.
Docker Setup
Docker compose files explaination
- docker-compose.yml: The one used for development. It sets up MongoDB and builds base quest image.
- docker-compose.prod.yml: The one used for production deployment. It has a Nginx service, a backend, a database, an analytics service, and creates isolated networks for player containers.
- docker-compose.testing.yml: Similar to production config, but sets up an one-time environment for end-to-end testing.
Common Development Setup
This sets up a development database, and running development server for frontend and backend.
Pull the latest images:
docker compose pull
Start the containers:
docker compose up -d
This will start the db. it will automatically restarts by Docker.
Building quest images:
docker compose build base
yarn build:quests
Build Quest Images in Details
In each quest folder, there is a game.yml file, which is the quest definition.
If you want to include additional files, put them in a home folder. The files in home will be copied to the user's home on container creation automatically.
quests/
├── Dockerfile # Base image
├── entrypoint.sh # Entrypoint for the container
├── discover
│ └── game.yml
├── helloworld
│ ├── Dockerfile # Overwrite the image
│ ├── game.yml
│ └── home # Include additional files
│ └── forgotten_scroll.txt
├── read
│ └── game.yml
└── spell
├── Dockerfile
├── game.yml
└── home
└── ancient_scroll.txt
An optional Dockerfile can overwrite the base image. You can use this to install additional dependencies or modify the environment.
Customized entrypoint.sh for each quest is not yet supported.
To build all quests:
yarn build:quests
The base image is built with docker-compose, so you can use docker compose build base to rebuild it. Once you rebuild the base image, you have to rebuild all quests.
Optional: Mounting Host Directory
To improve the development experience, we can mount the host directory to the container in the pattern:
/path/to/linux-odyssey/quests/${quest_id}/home:/home/commander
/path/to/linux-odyssey/packages/container:/usr/local/lib/container
You can edit the files on your host, and the changes will be reflected in the container. This is disabled by default. To enable it, you can set the following environment variables:
MOUNT_QUEST=true
Development
Copy .env.sample to .env and customize it for your needs.
Run dev server (frontend, backend):
yarn dev
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
Unit tests:
yarn test:unit
Run Cypress locally, using the current development containers:
docker compose up -d
yarn test:e2e
Run Cypress in container, create brand-new containers along with it:
./docker-scripts.sh test
# or with building
./docker-scripts.sh test --build
# tearing off the containers
./docker-scripts.sh down
Deployment
Create production env
cp .env.prod.sample .env.prod
Edit .env.prod
BASE_URL=https://yourdomain.com # IMPORTANT to make login work
SECRET_KEY=xxxx # Change it to something safe!
Start the service
# Build the images (only allowed for maintainers)
docker compose -f docker-compose.prod.yml build
docker compose -f docker-compose.prod.yml push
# Server side
docker compose -f docker-compose.prod.yml pull
yarn build:quests
docker compose -f docker-compose.prod.yml up -d
Necessary Configuration
To enable social login, you should have OAuth client token in a .env file:
You can copy from .env.sample
YOU MUST CHANGE THE SECRET_KEY in .env file.
SECRET_KEY=your-secret-key
You can generate a random key by running
yarn setup