Skip to content

dot env

Robert Konigsberg edited this page Feb 4, 2024 · 6 revisions

dotenv

A .env file allows you to store environment variables. For instance, PORT=443 defines the server's HTTP port. All environment variables are optional since there's a default value.

Here is just a few of the environment variables. A full set are in https://github.com/terraforming-mars/terraforming-mars/blob/main/.env.sample.

  • PORT: (default 8080) Which port to use for this server
  • HOST: What hostname to use
  • CERT_PATH: Your TLS certificate path (=> fullchain.pem created by certbot)
  • KEY_PATH: Your TLS private key path (=> privkey.pem created by certbot)
  • MAX_GAME_DAYS: (default 10 for Postgres, default for SQLite is no purge.) How many days to keep unfinished games before deleting them
  • WAITING_FOR_TIMEOUT: (default 5000) How many milliseconds to check for game update on multi-player games
  • ASSET_CACHE_MAX_AGE: (default 0) How many seconds should assets (fonts, stylesheets, images) be cached by browsers
  • SERVER_ID: (default random) Static pass phrase to restrict access to /games-overview and /api/games endpoints
  • LOCAL_FS_DB: When non-empty, stores game states in JSON files. Good for local development and debugging, bad for hosting lots of games.

The .env.sample file can be used as a template. You can rename it to .env and it will take effect in your environment. Note that .env is ignored in source control.

HTTPS

To set up an HTTPS sub/domain for use with this project, set the paths for KEY_PATH and CERT_PATH in your .env. If you do not have a TLS cert/key for your domain, you can get one for free from certbot.