diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a755f74..c6287f9 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -5,8 +5,8 @@ on: branches: - main paths: - - 'docs/**' - - 'mkdocs.yml' + - "docs/**" + - "mkdocs.yml" jobs: deploy: diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml deleted file mode 100644 index 4e9ea69..0000000 --- a/.github/workflows/publish-image.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: registry - -on: - workflow_dispatch: - push: - paths: - - 'Dockerfile' - - 'build/nginx/lichess.conf' - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - build-and-publish: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46ff246 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/site/ diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 18b6687..0000000 --- a/.gitpod.yml +++ /dev/null @@ -1,116 +0,0 @@ -image: ghcr.io/lichess-org/lila-gitpod:main - -tasks: - - name: ui - command: | - gp sync-await setup - ## Compile js + css - cd /workspace/lila - ./ui/build -w - - name: lila - command: | - gp sync-await setup - cd /workspace/lila - export COURSIER_CACHE=/workspace/coursier-cache - sbt bloopInstall - mkdir ~/.bloop && echo '{"javaOptions": [ "-Dfile.encoding=UTF-8" ]}' > ~/.bloop/bloop.json - gp sync-done lila-sbt - bloop compile lila - bloop run lila -m lila.app.Lila - - name: lila-ws - command: | - gp sync-await lila-sbt - cd /workspace/lila-ws - export COURSIER_CACHE=/workspace/coursier-cache - sbt compile - sbt -Dconfig.file=/workspace/lila-ws-gitpod-application.conf run - - name: setup - command: | - gp open /workspace/lila-gitpod/gitpod/Welcome.md - sudo service nginx restart - cd /workspace - git clone https://github.com/lichess-org/lila.git - git clone https://github.com/lichess-org/lila-ws.git - git clone https://github.com/lichess-org/lila-db-seed.git - git clone https://github.com/lichess-org/fishnet.git --recursive - git clone https://github.com/lichess-org/lila-fishnet.git - ## Create config for lila - cp /workspace/lila/conf/application.conf.default /workspace/lila/conf/application.conf - tee -a /workspace/lila/conf/application.conf < /etc/timezone -RUN locale-gen "en_US.UTF-8" - -# Install coursier (dependency of bloop) -RUN curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz | gzip -d > cs \ - && chmod +x cs \ - && sudo mv cs /usr/local/bin/cs \ - && cs setup --yes - -# Add mongodb apt source -RUN wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - -RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list - -RUN sudo apt-get update && sudo apt update \ - && sudo apt-get install -y git-all mongodb-org nginx psmisc python3.9 python3-pip redis-server unzip vim zip - -# Install Golang (For Picfit + Mailhog) -RUN wget https://go.dev/dl/go1.20.5.linux-amd64.tar.gz \ - && sudo tar -C /usr/local -xzf go1.20.5.linux-amd64.tar.gz \ - && rm go1.20.5.linux-amd64.tar.gz - -# Cleanup -RUN sudo apt-get autoremove -y \ - && sudo apt-get clean - -# Add nginx site config -COPY build/nginx/lichess.conf /etc/nginx/sites-enabled/ -RUN rm /etc/nginx/sites-enabled/default - -# Build bbbpairings -RUN mkdir -p /opt \ - && git clone https://github.com/cyanfish/bbpPairings /opt/bbpPairings \ - && cd /opt/bbpPairings \ - && make \ - && chmod +x bbpPairings.exe - -RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod -USER gitpod - -# Install pymongo needed for lila-db-seed -RUN python3.9 -m pip install pymongo - -# Install nvm, npm, and pnpm -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash \ - && export NVM_DIR="$HOME/.nvm" \ - && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \ - && echo ". \"$HOME/.nvm/nvm.sh\"" >> ~/.bashrc \ - && nvm install 19 \ - && npm install -g pnpm - -# Install Java -RUN curl -s "https://get.sdkman.io" | bash \ - && source "$HOME/.sdkman/bin/sdkman-init.sh" \ - && sdk version \ - && sdk install java 21-tem \ - && sdk install sbt - -# Install Rust and Cargo, needed for fishnet -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - -# Install bloop + scala formatter -RUN cs install bloop --only-prebuilt=true \ - && cs install scalafmt \ - && echo 'export PATH="$PATH:$HOME/.local/share/coursier/bin"' >> ~/.bashrc - -# Add golang binary to path -RUN echo 'export PATH="$PATH:/usr/local/go/bin"' >> ~/.bashrc diff --git a/README.md b/README.md index c2ee359..0d1dc6f 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,8 @@ You can use Gitpod (a free, online, VS Code-like IDE) for contributing. With a s Read the full [Lichess on Gitpod documentation](https://lichess-org.github.io/lila-gitpod/). -Click here to create a workspace: [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lichess-org/lila-gitpod) +Click here to create a workspace: -![lila-on-gitpod](https://user-images.githubusercontent.com/271432/183785811-dc00e385-f13f-4226-9654-93b6465c75cb.png) - -## Credits +[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/new/#https://github.com/lichess-org/lila-docker) -Base Dockerfile modified from [benediktwerner/lichess-docker](https://github.com/benediktwerner/lichess-docker) +![lila-on-gitpod](https://user-images.githubusercontent.com/271432/183785811-dc00e385-f13f-4226-9654-93b6465c75cb.png) diff --git a/build/nginx/errors/502.html b/build/nginx/errors/502.html deleted file mode 100644 index a0609ae..0000000 --- a/build/nginx/errors/502.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - lila-gitpod - - -
-

lila-gitpod

- -

The lila process is not currently running and/or port 9663 is not yet available.

- -

To Fix:

-

If you're just starting your workspace, wait until lila finishes compiling. It will automatically start after about 8-10 minutes.

-

Check the status in the lila terminal inside your workspace. Restart it manually if necessary.

-

For the full documentation, see https://lichess-org.github.io/lila-gitpod/

- - -
- - diff --git a/build/nginx/lichess.conf b/build/nginx/lichess.conf deleted file mode 100644 index 9d21385..0000000 --- a/build/nginx/lichess.conf +++ /dev/null @@ -1,34 +0,0 @@ -# Nginx is used to proxy lila and lila-ws traffic through the same port -# so they can be run on the same subdomain (necessary to share cookies) - -server { - listen 8080; - server_name lichess; - - location / { - try_files /nonexistent @$http_upgrade; - } - - # lila-ws (websocket) traffic - location @websocket { - proxy_pass http://0.0.0.0:9664; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } - - # lila traffic - location @ { - proxy_pass http://0.0.0.0:9663; - proxy_http_version 1.1; - - include /etc/nginx/proxy_params; - } - - error_page 502 /502.html; - location = /502.html { - ssi on; - internal; - root /workspace/lila-gitpod/build/nginx/errors; - } -} diff --git a/docs/api-testing.md b/docs/api-testing.md index c99afce..9f66521 100644 --- a/docs/api-testing.md +++ b/docs/api-testing.md @@ -11,8 +11,8 @@ Consider using a lila-gitpod workspace while you develop your API integration be ## Bot Development -1. Create an account for your bot -2. Point your bot to use your workspace's development site instead of `lichess.org` +1. Create an account for your bot +2. Point your bot to use your workspace's development site instead of `lichess.org` !!! info "Using lichess-bot" diff --git a/docs/contributing.md b/docs/contributing.md index 33029f4..458a34b 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -4,8 +4,9 @@ Before submitting any pull requests, run the linters: - sbt scalafmtAll - pnpm run format +```bash +./lila-docker format +``` ## Submitting a Pull Request diff --git a/docs/development.md b/docs/development.md index a87b5df..2b6af0c 100644 --- a/docs/development.md +++ b/docs/development.md @@ -8,30 +8,37 @@ The main Lichess code repositories have automatically been added to your workspace. You can find them at: - ls /workspace +```bash +ls /workspace/lila-docker/repos +``` To open them in your workspace: - open -r /workspace/lila # open main lila repository - open -r /workspace/lila-ws # open websocket repository +```bash +open -r repos/lila # open main lila repository +open -r repos/lila-ws # open websocket repository +``` ## Recompiling lila -When you edit a scala file, you'll have to restart `bloop`. Go to the `lila` terminal, type `Ctrl+c` to stop the running process, then rerun: +When you edit a scala file, you'll have to restart lila. In a terminal, type: - bloop run lila -m lila.app.Lila - -Bloop will detect any changed files, recompile them, then start lila. +```bash +docker compose restart lila +``` ## Recompiling frontend assets -If you're working on TypeScript or SCSS files, `./ui/build -w` will automatically detect the changes and recompile the assets. You can see the output in the `ui` terminal. +If you're working on TypeScript or SCSS files, you can automatically detect the changes and recompile the assets. In a terminal, type: -## Updating Routes +```bash +docker compose run --rm ui bash -c "/lila/ui/build -w" +``` -If you edit the `conf/routes` file, you'll need to update the route cache. Bloop will not automatically detect changes to this file. +## Updating Routes -Stop lila (see [Recompiling lila](#recompiling-lila) above), then run: +If you edit the `conf/routes` file, you'll need to update the route cache. - cd /workspace/lila - ./lila playRoutes +```bash +docker compose exec lila bash -c "./lila playRoutes" +``` diff --git a/docs/extensions.md b/docs/extensions.md deleted file mode 100644 index 2bc8da8..0000000 --- a/docs/extensions.md +++ /dev/null @@ -1,17 +0,0 @@ -You can install extensions within your workspace to make development easier. Browse and add them in the Extensions menu to the left of your workspace. - -These are a couple that might be helpful: - -## MongoDB for VSCode - -[This extension](https://github.com/mongodb-js/vscode) will let you browse your local Mongo database to see its structure and data. - -Use connection string: `mongodb://localhost` - -## Scala Metals - -[Metals](https://scalameta.org/metals/) is a Scala language server that provides rich IDE features. If you're working with Scala files, it can be helpful for: - -- Definitions/signatures on hover -- Autocomplete parameter hints -- Finding references diff --git a/docs/getting-started.md b/docs/getting-started.md index cd24d24..ef9ad18 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -2,15 +2,17 @@ Click here to start a workspace: -[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lichess-org/lila-gitpod) +[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/new/#https://github.com/lichess-org/lila-docker) -It will take about 8-10 minutes. You can watch the progress in the terminal windows that automatically open. +It will take about 10-15 minutes. You can watch the progress in the terminal that automatically opens. ## Your Development Site To get the URL for your development site, in a new terminal, type: - gp url 8080 +```bash +gp url 8080 +``` Once lila is running, your dev site will be available. You can check the status on the PORTS tab above your terminal. @@ -25,12 +27,17 @@ Your database is preloaded with a number of test accounts: To see all other test accounts (admins, titled accounts, flagged accounts, bots, etc): - mongosh lichess --quiet --file /workspace/lila-gitpod/scripts/mongodb/users.js +```bash +docker compose run --rm -v $(pwd)/scripts:/scripts mongodb bash -c \ + "mongosh --host mongodb lichess --file /scripts/mongodb/users.js" +``` ## Stopping Your Workspace Done for the day or make a mistake and want to start over? No problem. - gp stop +```bash +gp stop +``` Or just leave it and it'll shut down when it's been idle for 30 minutes. diff --git a/docs/optional-services.md b/docs/optional-services.md deleted file mode 100644 index a0a0633..0000000 --- a/docs/optional-services.md +++ /dev/null @@ -1,129 +0,0 @@ -# Optional Services - -By default, your lila-gitpod workspace will start with the basic services required to run lila. - -Depending on what you're working on, you may want to enable some of these additional services. - -## Stockfish - -The [Stockfish](https://stockfishchess.org/) engine is used for a couple of things within lila: - -- "Request a Computer Analysis" for post-game analysis -- "Play with the Computer" - -To enable: - -1. Compile the [fishnet](https://github.com/lichess-org/fishnet) client: - ``` - cd /workspace/fishnet/ - cargo build - ``` - -2. For **"Request a Computer Analysis"**, connect Fishnet to port 9663: - ``` - cargo run -- --endpoint http://localhost:9663/fishnet/ --max-backoff 1s - ``` - -3. For **"Play with the Computer"**, start the `lila-fishnet` service: - ``` - cd /workspace/lila-fishnet/ - sbt run -Dhttp.port=9665 - ``` - Then, connect Fishnet to port 9665. In a separate terminal: - ``` - cd /workspace/fishnet/ - cargo run -- --endpoint http://localhost:9665/fishnet/ --max-backoff 1s - ``` - -## External Engine - -The broker for external engine has its own service and port (9666). It must be started separately if you wish to use it. - -``` -git clone https://github.com/lichess-org/lila-engine.git /workspace/lila-engine -cd /workspace/lila-engine -LILA_ENGINE_LOG=lila_engine=debug,tower_http=debug cargo run -- --bind 127.0.0.1:9666 -``` - -You can then connect an external engine client to port 9666. - -## Email Debugging - -Lichess sends various emails (welcome, password reset, move notifiations for correspondence games, etc). - -By default, any emails from your development site will not really be sent, and only show in the logs of the `lila` terminal. - -If you're working on emails, you may find it helpful to use [MailHog](https://github.com/mailhog/MailHog) to debug them and get a more inbox-type view where you can see the rendered HTML emails. - -1. Append these 2 lines to `/workspace/lila/conf/application.conf`: - ``` - mailer.primary.mock = false - mailer.primary.tls = false - ``` - -2. Restart lila to apply the config changes (see [Recompiling lila](/development/#recompiling-lila)) - -3. Then start MailHog: - ``` - go get github.com/mailhog/MailHog - sudo ~/go/bin/MailHog -smtp-bind-addr 0.0.0.0:587 - ``` - -When you trigger an email to be sent, it will now show in the MailHog UI which is available at the URL when you type `gp url 8025` in a terminal. - -## lila-gif - -The [lila-gif](https://github.com/lichess-org/lila-gif) service will enable the functionality: - -- Game Analysis > Share & export > Game as GIF -- Game Analysis > Share & export > Screenshot current position - -``` -git clone https://github.com/lichess-org/lila-gif.git /workspace/lila-gif -cd /workspace/lila-gif -cargo run -``` - -You can verify it's working by running the following commands in another terminal: - -``` -curl http://localhost:6175/image.gif?fen=4k3/6KP/8/8/8/8/7p/8 --output image.gif -open image.gif -``` - -## picfit - -[Picfit](https://github.com/thoas/picfit) is used to resize blog and streamer page images. - -``` -git clone https://github.com/thoas/picfit.git /workspace/picfit -cd /workspace/picfit -make build -echo '{"port": 3001}' > config.json -./picfit -c config.json -``` - -You can verify it's working going to the URL that's returned when you type `echo $(gp url 3001)/healthcheck` in a terminal. - -## scalachess - -[Scalachess](https://github.com/lichess-org/scalachess) will automatically be installed from the maven source. But if you wish to make changes and develop locally: - -``` -git clone https://github.com/lichess-org/scalachess.git /workspace/scalachess -cd /workspace/scalachess -sbt publishLocal -``` - -## pgn-viewer + chessground - -[PGN Viewer](https://github.com/lichess-org/pgn-viewer) and [Chessground](https://github.com/lichess-org/chessground) will automatically be installed from NPM. You can install them locally if you wish to make changes and develop locally: - -``` -git clone https://github.com/lichess-org/pgn-viewer.git /workspace/pgn-viewer -git clone https://github.com/lichess-org/chessground.git /workspace/chessground - -cd /workspace/lila/ui/site -pnpm link /workspace/pgn-viewer -pnpm link /workspace/chessground -``` diff --git a/gitpod/Welcome.md b/gitpod/Welcome.md deleted file mode 100644 index e4e2b51..0000000 --- a/gitpod/Welcome.md +++ /dev/null @@ -1,16 +0,0 @@ -# Welcome to Lichess on Gitpod - -> Your development environment is now building. - -You can watch the progress in the terminal tabs that are running: - -1. `ui`: Watches the static assets for changes and automatically rebuilds the scripts and stylesheets -2. `lila`: Starts the main Lichess server -3. `lila-ws`: Starts the websocket server -4. `setup`: Sets up your configs, seeds your test database, and starts background services - -It will take about 8-10 minutes. - -For the URL of your development site, click the PORTS tab, then follow the link for port 8080. - -For test logins and more documentation, see https://lichess-org.github.io/lila-gitpod/ diff --git a/mkdocs.yml b/mkdocs.yml index 5349c38..7f57e55 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -9,8 +9,6 @@ nav: - Development: - Working with Lila: development.md - Lilaisms: lilaisms.md - - Extensions: extensions.md - - Optional Services: optional-services.md - Contributing: contributing.md - API Testing: api-testing.md - Sharing: sharing.md @@ -21,13 +19,13 @@ theme: logo: https://lichess1.org/assets/logo/lichess-white.svg font: false palette: - - media: '(prefers-color-scheme: light)' + - media: "(prefers-color-scheme: light)" scheme: default primary: blue toggle: icon: material/toggle-switch name: Switch to dark mode - - media: '(prefers-color-scheme: dark)' + - media: "(prefers-color-scheme: dark)" scheme: slate primary: blue toggle: diff --git a/scripts/docs.sh b/scripts/docs.sh index 1e3aba0..3fec65e 100755 --- a/scripts/docs.sh +++ b/scripts/docs.sh @@ -2,5 +2,5 @@ # Serve the lila-gitpod docs -python3.9 -m pip install mkdocs mkdocs-material -python3.9 -m mkdocs serve --config-file /workspace/lila-gitpod/mkdocs.yml +python -m pip install mkdocs mkdocs-material +python -m mkdocs serve diff --git a/scripts/mongodb/users.js b/scripts/mongodb/users.js deleted file mode 100644 index 659802a..0000000 --- a/scripts/mongodb/users.js +++ /dev/null @@ -1,23 +0,0 @@ -// View test users that were seeded in the database -// Usage: mongosh lichess --quiet --file users.js - -let users = db.user4 - .find() - .toArray() - .map((user) => { - return { - id: user._id, - roles: user.roles.join(', '), - title: user.title || '', - marks: user.marks.join(', '), - } - }) - -console.log('Special User Accounts') -console.table(users.filter((user) => user.roles)) - -console.log('Marked Accounts') -console.table(users.filter((user) => user.marks)) - -console.log('Regular Accounts') -console.table(users.filter((user) => !user.roles && !user.marks))