diff --git a/Dockerfile.docs b/Dockerfile.docs index e1db055f1..f6b806fb1 100644 --- a/Dockerfile.docs +++ b/Dockerfile.docs @@ -4,4 +4,4 @@ RUN pip install mkdocs-material==9.5.17 COPY docs ./ -CMD ["mkdocs", "serve"] +CMD ["mkdocs", "serve", "-a", "0.0.0.0:8000"] diff --git a/README.md b/README.md index 14277760e..9a3a3f0a2 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,19 @@ There are way more features that Tachi has, and you can read about all of them [ ## Setup +Tachi maintains a setup guide that is easy to follow even if you've never programmed before. + Check the [Documentation](https://docs.tachi.ac/contributing/setup) for how to set Tachi up. -You can then check the component-specific guides to see how to run those components and contribute back. +You can then check the component-specific guides to see how to run those components and contribute back! + +## Quick Setup For Nerds + +Already know what you're doing? + +Install docker + docker-compose and use `./run.sh start` or `./run.bat start` to start Tachi. + +Other commands you might want to execute are included inside the `run` file. ## Repository Info diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index fe34014a6..25f42be9a 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -3,18 +3,18 @@ services: mongo: container_name: mongo image: mongo:5 - restart: always + restart: unless-stopped ports: - - '27017:27017' + - "27017:27017" volumes: - tachi-volume:/data/db redis: container_name: redis command: redis-server --save 60 1 --loglevel warning image: redis:6 - restart: always + restart: unless-stopped ports: - - '6379:6379' + - "6379:6379" volumes: - tachi-redis:/data tachi-server: @@ -35,7 +35,7 @@ services: volumes: - ./:/app ports: - - '8080:8080' + - "8080:8080" environment: REDIS_URL: redis MONGO_URL: mongo @@ -53,7 +53,7 @@ services: volumes: - ./:/app ports: - - '3000:3000' + - "3000:3000" tachi-seeds: container_name: tachi-seeds build: @@ -74,7 +74,15 @@ services: MONGO_URL: mongo PORT: 8080 NODE_ENV: "dev" + tachi-docs: + container_name: tachi-docs + build: + dockerfile: Dockerfile.docs + ports: + - "3001:8000" + volumes: + - ./:/app volumes: tachi-volume: tachi-redis: - tachi-logs: \ No newline at end of file + tachi-logs: diff --git a/docs/docs/contributing/setup.md b/docs/docs/contributing/setup.md index 4e0f042d7..f17520dd6 100644 --- a/docs/docs/contributing/setup.md +++ b/docs/docs/contributing/setup.md @@ -34,16 +34,7 @@ However, for Windows users we recommend installing the [Windows Terminal](https: With a terminal open you can proceed to the next steps! -## 1. Getting Node and Docker. - -You'll need `node` and `npm` in order to run Tachi. Install this from [the official NodeJS website](https://nodejs.org). - -!!! info - If you are on linux, NodeJS will be provided by your package manager instead. - - You may wish to use that instead. It honestly doesn't matter all too much. - -Check that the install has worked by running `npm -v`. If you get an error message saying that `npm` was not found, try restarting the terminal. +## 1. Getting Docker. To set everything else up for local development, we'll use [Docker](https://docker.com). @@ -118,7 +109,17 @@ You should now be properly authenticated! ## 4. Start Tachi! -With a terminal open inside the `Tachi` folder you just cloned, run `npm start`. +With a terminal open inside the `Tachi` folder you just cloned, run this command: + +=== "Windows" + ```bat + run start + ``` + +=== "Linux, MacOS" + ```sh + ./run.sh start + ``` The frontend will be running on `http://127.0.0.1:3000`. The backend will be running on `https://127.0.0.1:8080`. @@ -131,6 +132,9 @@ The backend will be running on `https://127.0.0.1:8080`. the browser that you trust these certificates. Otherwise, all client requests to the server will silently be chomped by the browser. +!!! tip + Open the `run.bat` or `run.sh` files in vscode to see what other commands are available. + ## 5. Editor Plugins If you're using VSCode as your editor (I *really* recommend it!) You'll want a couple @@ -144,7 +148,7 @@ Namely, Install the ESLint plugin, and enable "Format On Save" in your settings. It's ridiculously convenient, and there's a bunch of other stuff that VSCode helps with. -## 8. OK, Now what. +## 6. OK, Now what. Now that you've got a working version of Tachi running on your local PC, you should go check out the [component-specific contribution guides](./components.md)! diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 399e337de..a2f811055 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -3,6 +3,10 @@ site_description: Documentation for Kamaitachi, Bokutachi and related things. site_author: zkldi site_url: https://docs.tachi.ac +watch: + - "docs/" + - "mkdocs.yml" + theme: name: material features: @@ -35,43 +39,43 @@ nav: - "contributing/components/seeds.md" - Cookbook: - - "contributing/cookbook/iidx-mdb.md" - - "contributing/cookbook/sdvx-mdb.md" - - "contributing/cookbook/bms-tables.md" + - "contributing/cookbook/iidx-mdb.md" + - "contributing/cookbook/sdvx-mdb.md" + - "contributing/cookbook/bms-tables.md" - Supporting New Games: - "game-support/index.md" - Common Config: - - "game-support/common-config/index.md" - - "game-support/common-config/metrics.md" - - "game-support/common-config/metric-groups.md" - - "game-support/common-config/match-types.md" - - "game-support/common-config/versions.md" + - "game-support/common-config/index.md" + - "game-support/common-config/metrics.md" + - "game-support/common-config/metric-groups.md" + - "game-support/common-config/match-types.md" + - "game-support/common-config/versions.md" - "game-support/server-impl.md" - "game-support/client-impl.md" - Game Information: - - "game-support/games/iidx-SP.md" - - "game-support/games/iidx-DP.md" - - "game-support/games/museca-Single.md" - - "game-support/games/chunithm-Single.md" - - "game-support/games/bms-7K.md" - - "game-support/games/bms-14K.md" - - "game-support/games/gitadora-Gita.md" - - "game-support/games/gitadora-Dora.md" - - "game-support/games/jubeat-Single.md" - - "game-support/games/maimaidx-Single.md" - - "game-support/games/popn-9B.md" - - "game-support/games/sdvx-Single.md" - - "game-support/games/usc-Controller.md" - - "game-support/games/usc-Keyboard.md" - - "game-support/games/wacca-Single.md" - - "game-support/games/pms-Controller.md" - - "game-support/games/pms-Keyboard.md" - - "game-support/games/itg-Stamina.md" - - "game-support/games/ongeki-Single.md" + - "game-support/games/iidx-SP.md" + - "game-support/games/iidx-DP.md" + - "game-support/games/museca-Single.md" + - "game-support/games/chunithm-Single.md" + - "game-support/games/bms-7K.md" + - "game-support/games/bms-14K.md" + - "game-support/games/gitadora-Gita.md" + - "game-support/games/gitadora-Dora.md" + - "game-support/games/jubeat-Single.md" + - "game-support/games/maimaidx-Single.md" + - "game-support/games/popn-9B.md" + - "game-support/games/sdvx-Single.md" + - "game-support/games/usc-Controller.md" + - "game-support/games/usc-Keyboard.md" + - "game-support/games/wacca-Single.md" + - "game-support/games/pms-Controller.md" + - "game-support/games/pms-Keyboard.md" + - "game-support/games/itg-Stamina.md" + - "game-support/games/ongeki-Single.md" - Wiki: - "wiki/index.md" diff --git a/run.bat b/run.bat new file mode 100755 index 000000000..7be80b388 --- /dev/null +++ b/run.bat @@ -0,0 +1,49 @@ +@echo off + +where docker > nul 2>&1 + +if %errorlevel% NEQ 0 ( + echo Docker isn't installed. Please install docker! + pause + exit 1 +) + +if "%1"=="" ( + set "cmd=start" +) else ( + set "cmd=%" +) + +echo "running %cmd%" + +if "%cmd%" == "start" ( + docker compose -f docker-compose-dev.yml up --build -d + echo "Go to http://127.0.0.1:3000 to view Tachi!" + echo "Go to http://127.0.0.1:3001 to view Tachi's Documentation!" +) else if "%cmd%" == "stop" ( + docker compose -f docker-compose-dev.yml down +) else if "%cmd%" == "logs-server" ( + docker logs tachi-server -f +) else if "%cmd%" == "logs-client" ( + docker logs tachi-client -f +) else if "%cmd%" == "logs-seeds" ( + docker logs tachi-seeds -f +) else if "%cmd%" == "test-server" ( + docker exec tachi-server pnpm test +) else if "%cmd%" == "test-seeds" ( + docker exec tachi-seeds pnpm --filter ./scripts test +) else if "%cmd%" == "enter-seeds" ( + docker exec tachi-seeds bash +) else if "%cmd%" == "sort-seeds" ( + docker exec tachi-seeds node scripts/deterministic-collection-sort.js +) else if "%cmd%" == "load-seeds" ( + docker exec tachi-server pnpm sync-database-local +) else if "%cmd%" == "validate-db" ( + docker exec tachi-server pnpm validate-database +) else ( + echo "Unknown command %cmd%: Exiting." + pause + exit 1 +) + +pause diff --git a/run.sh b/run.sh new file mode 100755 index 000000000..693894193 --- /dev/null +++ b/run.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +if ! which docker >/dev/null; then + echo "Docker isn't installed. Please install docker!" + exit 1 +fi + +cmd=${1:-start} + +echo "running $cmd" + +set -eo pipefail + +case "$cmd" in + start) + docker compose -f docker-compose-dev.yml up --build -d + echo "Go to http://127.0.0.1:3000 to view Tachi!" + echo "Go to http://127.0.0.1:3001 to view Tachi's Documentation!" + ;; + stop) + docker compose -f docker-compose-dev.yml down + ;; + logs-server) + docker logs tachi-server -f + ;; + logs-client) + docker logs tachi-client -f + ;; + logs-seeds) + docker logs tachi-seeds -f + ;; + test-server) + docker exec tachi-server pnpm test + ;; + test-seeds) + docker exec tachi-seeds pnpm --filter ./scripts test + ;; + enter-seeds) + docker exec tachi-seeds bash + ;; + sort-seeds) + docker exec tachi-seeds node scripts/deterministic-collection-sort.js + ;; + load-seeds) + docker exec tachi-server pnpm sync-database-local + ;; + validate-db) + docker exec tachi-server pnpm validate-database + ;; + *) + echo "Unknown command $cmd" + exit 1 + ;; +esac \ No newline at end of file