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 startservesdist/with sirv (scripts/start.mjs), on every interface, on$PORT(8080 when unset), every file withCache-Controlmax-age=3600. The launcher exists since 4.1.8.public/assetsis committed in this repository, so the deploy needs Vite only, not Python. - A created project (
quest-n-click create): it has nostartscript and no static server (the engine package leavessirv-cliout), andpublic/assetsis 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 deploypushes 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
-
Create a Node application and link it to the folder:
# in the engine repository or the created project clever create --type node my-game
-
Configure the build.
Engine repository: Vite is a development dependency, the build is
build:web, andGAMEnames the game (elsepackage.json→config.game, elsedemo):# 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-gameCreated 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
buildrunsverify(the solver included) on the server, on every deploy.
- Leave
BASE_PATHunset: 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).
-
Deploy, and follow the logs:
# in the engine repository or the created project clever deploy clever logs
- Open it at the domain Clever Cloud gives (
clever open), or add yours withclever domain add play.example.organd its DNS record.
Expected result, and how to check it
clever logsshows 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
| Symptom | Cause | Fix |
|---|---|---|
vite: not found in the build log | Development dependencies not installed (engine repository) | CC_NODE_DEV_DEPENDENCIES=install |
| The application never becomes healthy | Nothing listens on $PORT, or only on 127.0.0.1 | npm 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 missing | Keep both parts of the created project's hook |
| The demo game instead of yours | GAME unset in the engine repository | clever env set GAME <id>, then deploy |
| The previous version still shows | The service worker waits for the player; index.html is cached for an hour | Cache and service worker |
Files or data changed
- The application and its variables on Clever Cloud; a
cleverremote and.clever.jsonin the folder. - Created project:
package.json(start, thesirv-clidependency) andpackage-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
scripts/start.mjs(npm start),package.json(build:web).tools/game.ts: howGAMEchooses the game.cli/quest-n-click.mjsandscripts/pack.mjs: a created project's commands, and the package withoutsirv-cli.- The variables:
CC_POST_BUILD_HOOK,CC_NODE_DEV_DEPENDENCIES,PORT,GAME.