Skip to content
quest'n'click

CreateHow-toFor authorsApplies from 4.2.5

The static game on Clever Cloud

Cette page en françaisThis page on the GitHub wiki

The game is a static site; on Clever Cloud it runs as a small Node application that builds dist/ at each deploy and serves it. This page is for the game alone. Hosting the team Studio is another matter: Clever Cloud overview.

What you get

A Clever Cloud Node application, deployed with git push through clever deploy, that serves your game at its domain. Each deploy builds the game again from the pushed commit.

Context and versions

Two cases, with different set-ups:

  • The engine repository (a game in games/<id>/): npm start serves dist/ with sirv (scripts/start.mjs), on every interface, on $PORT (8080 when unset), every file with Cache-Control max-age=3600. The launcher exists since 4.1.8. public/assets is committed in this repository, so the deploy needs Vite only, not Python.
  • A created project (quest-n-click create): it has no start script and no static server (the engine package leaves sirv-cli out), and public/assets is not committed, so the deploy must run the asset step, which needs Python and Pillow.

The page applies from 4.2.5. Verified on: not verified. The engine repository's settings below are the ones docs/en/TOOLS.md gave through 4.4.0; nobody has replayed this page on a live Clever Cloud application, and the created-project case has never been deployed there by the project. Read each command before you run it.

Prerequisites

  • A Clever Cloud account and clever-tools, logged in (clever login).
  • The game builds on your machine (Build and release a game): the deploy runs the build again, and a failing build leaves the previous version online.
  • The project is a Git repository with its work committed: clever deploy pushes the current branch's commit.

Where to run the commands

On your machine, in the engine repository or in the created project: clever … links that folder to the application and pushes its Git history. The build itself runs on Clever Cloud.

Steps

  1. Create a Node application and link it to the folder:

    # in the engine repository or the created project
    clever create --type node my-game
  1. Configure the build.

    Engine repository: Vite is a development dependency, the build is build:web, and GAME names the game (else package.json → config.game, else demo):

    # in the engine repository
    clever env set CC_NODE_DEV_DEPENDENCIES install
    clever env set CC_POST_BUILD_HOOK "npm run build:web"
    clever env set GAME my-game

    Created project: give it a server and a start command, then a build hook that installs Pillow next to the application and builds:

    # in the created project
    npm install sirv-cli@3
    npm pkg set scripts.start="sirv dist --host 0.0.0.0 --port \$PORT --maxage 3600"
    clever env set CC_POST_BUILD_HOOK "python3 -m pip install --target .python -r node_modules/quest-n-click/requirements.txt && PYTHONPATH=.python npm run build"
    git add package.json package-lock.json && git commit -m "Serve dist/ on Clever Cloud"

    The created project's build runs verify (the solver included) on the server, on every deploy.

  1. Leave BASE_PATH unset: the application serves the game at the root of its domain. Set it only if a proxy in front publishes the game under a sub-path (Sub-path).
  1. Deploy, and follow the logs:

    # in the engine repository or the created project
    clever deploy
    clever logs
  1. Open it at the domain Clever Cloud gives (clever open), or add yours with clever domain add play.example.org and its DNS record.

Expected result, and how to check it

  • clever logs shows the hook's build, then sirv listening on port 8080.
  • The game opens at the application's domain; the pause menu's "Offline" row (or its translation) ends at "complete" (the engine's default text; a game translates it).
  • In the engine repository, node scripts/e2e.mjs https://<your-domain>/ plays it to the end.

Common errors

SymptomCauseFix
vite: not found in the build logDevelopment dependencies not installed (engine repository)CC_NODE_DEV_DEPENDENCIES=install
The application never becomes healthyNothing listens on $PORT, or only on 127.0.0.1npm start must serve on 0.0.0.0:$PORT (the launcher and the script above do)
No module named 'PIL'The hook did not install Pillow, or PYTHONPATH is missingKeep both parts of the created project's hook
The demo game instead of yoursGAME unset in the engine repositoryclever env set GAME <id>, then deploy
The previous version still showsThe service worker waits for the player; index.html is cached for an hourCache and service worker

Files or data changed

  • The application and its variables on Clever Cloud; a clever remote and .clever.json in the folder.
  • Created project: package.json (start, the sirv-cli dependency) and package-lock.json.
  • dist/ and .python/ on the application's file system, rebuilt at each deploy.

Recovery or going back

A failed build is not deployed: the running instance keeps serving the previous version. To go back to an earlier version, revert the commit and clever deploy again; players' caches and saves then follow Going back. clever delete removes the application.

References