Currently all of the configurable values are handled by environment variables. These are listed in the env.example file,
which you should copy to .env and modify as needed.
First things first, it helps to understand a bit how the system is set up.
| Component Name | Tech | Description |
|---|---|---|
server |
Node.js | The main server. Handles client web requests (page loads, vote activity, etc.) |
math |
Clojure/JVM | The math engine. |
client-participation |
Javascript | The client code for end-users. |
client-admin |
Javascript | The client code for administrators. |
client-report |
Node.js | The code for detailed analytics reports. |
While this document will try to outline some of the more important configuration steps and options, you'll need to see the individual READMEs for more detailed descriptions of how to configure these components.
Quickstart
In development, the default values of example.env should work as-is.
cp example.env .env
By default, docker compose will look for and use an .env file if one exists. However, any value present in your
environment or passed in on the command line will overwrite those in the file. Thus you should be able to set your
configuration values in whatever way suits your given scenario. (A plain text .env file is not always appropriate in
production deployments.)
If you are running these applications without Docker, just make sure that any environment variables you need are set in the environment where the application is running.
If you are doing development on a url other than localhost or localhost:5000, you need to update the
API_DEV_HOSTNAME value to your development hostname:port, e.g. myhost:8000 or api.testserver.net.
DEV_MODE should be true.
If you are deploying to a custom domain (not pol.is) then you need to update both the API_PROD_HOSTNAME and
DOMAIN_OVERRIDE values to your custom hostname (omitting http(s):// protocol).
DEV_MODE should be false.
ADMIN_UIDSan array of user UIDs for site admins. These users will have moderator capabilities on all conversations hosted on the site.EMAIL_TRANSPORT_TYPEScomma-separated list of email services to use (see Email Transports below)GIT_HASHSet programmatically usinggit rev-parse HEAD(e.g. inMakefile) to tag docker container versions and other release assets. Can be left blank.MATH_ENVSet toprod(default),preprod,devor arbitrary feature flag. In cases where a single database is used for multiple environments, this value is used by the API service to request the correct data. (Using a single DB for multiple environments in this fashion is no longer recommended, and so the default value ofprodis recommended.)MATH_LOG_LEVELUsed by the math service to determine how much logging to output. Reasonable values aredebug,info,warn, anderror. Defaults towarn.SERVER_ENV_FILEThe name of an environment file to be passed into the API Server container by docker compose. Defaults to.envif left blank. Used especially for building atestversion of the project for end-to-end testing.SERVER_LOG_LEVELUsed by Winston.js in the API server to determine how much logging to output. Reasonable values aredebug,info,warn, anderror. Defaults towarn.
READ_ONLY_DATABASE_URL(optional) Database replica for reads.
POSTGRES_DBdatabase name (e.g.polis-dev)POSTGRES_HOSTdatabase host (e.g.postgres:5432if using docker compose,localhost:5432if using local db)POSTGRES_PASSWORDdatabase passwordPOSTGRES_PORTtypically 5432POSTGRES_USERtypicallypostgres. Any username will be used by the docker container to create a db user.
DATABASE_URLshould be the combination of above values,postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/${POSTGRES_DB}POSTGRES_DOCKERSet tofalseif using a postgres database outside of docker. Defaults totrue. Read by Makefile.
DYNAMODB_ENDPOINT(optional) DynamoDB endpoint. If not set, the default AWS SDK endpoint will be used.
TAGused byCOMPOSE_PROJECT_NAMEbelow. Defaults todev.COMPOSE_PROJECT_NAMEUsed by docker compose to label containers and volumes. Useful in development if you are (re)-building and deleting groups of docker assets.
API_SERVER_PORTtypically 5000. Used internally within a docker network and/or behind a proxy. APORTvalue is used as a fallback ifAPI_SERVER_PORTis not set (for Heroku compatibility).HTTP_PORTtypically 80. Port exposed by Nginx reverse proxy.HTTPS_PORTtypically 443. Port exposed by Nginx reverse proxy.STATIC_FILES_PORTtypically 8080. Used internally within a docker network and/or behind a proxy.STATIC_FILES_ADMIN_PORTsame asSTATIC_FILES_PORTunless you are hosting client-admin separately from file-server. Useful in local development.STATIC_FILES_PARTICIPATION_PORTsame asSTATIC_FILES_PORTunless you are hosting client-participation separately from file-server. Useful in local development.
ADMIN_EMAIL_DATA_EXPORTemail address from which data export emails are sent.ADMIN_EMAIL_DATA_EXPORT_TESTemail address to receive periodic export test results, if configured below.ADMIN_EMAIL_EMAIL_TESTemail address to receive backup email system test.ADMIN_EMAILSarray of email addresses to receive team notifications.POLIS_FROM_ADDRESSemail address from which other emails are sent.
(All can be left blank, or false)
BACKFILL_COMMENT_LANG_DETECTIONSet totrue, if Comment Translation was enabled, to instruct the server upon the next initialization (reboot) to backfill detected language of stored comments. Defaultfalse.CACHE_MATH_RESULTSSet this totrueto instruct the API server to use LRU caching for results from the math service. Default istrueif left blank.DATABASE_SSLSet this totruefor some production environments. Default isfalse.DEV_MODESet this totruein development andfalseotherwise. Used by API Server to make a variety of assumptions about HTTPS, logging, notifications, etc.RUN_PERIODIC_EXPORT_TESTSSet this totrueto run periodic export tests, sent to theADMIN_EMAIL_DATA_EXPORT_TESTaddress.SERVER_LOG_TO_FILESet this totrueto tell Winston.js to also write log files to server/logs/. Defaults tofalse. Note that if using docker compose, server/logs is mounted as a persistent volume.SHOULD_USE_TRANSLATION_APISet this totrueif using Google translation service. See Enabling Comment Translation below.USE_NETWORK_HOSTSet this totrueif using server within an internal network (e.g. AWS) such that SSL is not required.
API_DEV_HOSTNAMEtypicallylocalhostunless you are running a development instance elsewhere.API_PROD_HOSTNAMEthe hostname of your site (e.g.pol.is, orexample.com). Should matchDOMAIN_OVERRIDE. (In the future these two options may be combined into one.)DOMAIN_OVERRIDEthe hostname of your site. Should matchAPI_PROD_HOSTNAME.DOMAIN_WHITELIST_ITEM_01-08up to 8 possible additional whitelisted domains for client applications to make API requests from. Typical setups that use the same URL for the API service as for the public-facing web sites do not need to configure these.EMBED_SERVICE_HOSTNAMEshould matchAPI_DEV_HOSTNAMEin production, orAPI_DEV_HOSTNAMEin development. Embedded conversations make API requests to this host.SERVICE_URLused by client-report to make API calls. Only necessary if client-report is hosted separately from the API service. Can be left blank.STATIC_FILES_HOSTUsed by the API service to fetch static assets (the compiled client applications) from a static file server. Within the docker compose setup this isfile-server, but could be an external hostname, such as a CDN or S3 bucket.
AUTH_ISSUERThe OIDC tenant domain URL for standard user authentication (e.g.https://your-tenant.auth0.com/).AUTH_AUDIENCEThe API identifier/audience for OIDC (e.g.usersorhttps://your-api.com).AUTH_CLIENT_IDThe OIDC SPA client ID for your application.JWKS_URIThe JWKS URI for your OIDC tenant (e.g.https://your-tenant.auth0.com/.well-known/jwks.json).POLIS_JWT_ISSUERThe issuer for in-house JWTs (XID and anonymous participants). Defaults tohttps://pol.is/.POLIS_JWT_AUDIENCEThe audience for in-house JWTs. Defaults toparticipants.JWT_PRIVATE_KEY_PATHPath to the RSA private key for signing in-house JWTs.JWT_PUBLIC_KEY_PATHPath to the RSA public key for validating in-house JWTs.JWT_PRIVATE_KEYBase64-encoded RSA private key (alternative to file path).JWT_PUBLIC_KEYBase64-encoded RSA public key (alternative to file path).OIDC_CACHE_KEY_PREFIXThe prefix for the OIDC cache key. Defaults to@@auth0spajs@@.OIDC_CACHE_KEY_ID_TOKEN_SUFFIXThe suffix for the OIDC cache key. Defaults to@@user@@.
(All are optional, and omitting them will disable the related feature.)
AKISMET_ANTISPAM_API_KEYComment spam detection and filtering.GA_TRACKING_IDFor using Google Analytics on client pages.GOOGLE_CREDENTIALS_BASE64Required if using Google Translate API. (See below).GOOGLE_CREDS_STRINGIFIEDAlternative toGOOGLE_CREDENTIALS_BASE64(See below).MAILGUN_API_KEY,MAILGUN_DOMAINIf using Mailgun as an email transport.AWS_REGIONUsed for some data import/export.AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEYUseful for AWS SDK operations.ANTHROPIC_API_KEYFor using Anthropic as a generative AI model.GEMINI_API_KEYFor using Gemini as a generative AI model.OPENAI_API_KEYFor using OpenAI as a generative AI model.
ENCRYPTION_PASSWORD_00001(deprecated) a password used to encrypt and decrypt participants' IP addresses. Can be left blank.WEBSERVER_PASS(deprecated) basic auth setting for certain requests sent between math and api services.WEBSERVER_USERNAME(deprecated) basic auth setting for certain requests sent between math and api services.
Note: This feature is optional.
We use Google to automatically translate submitted comments into the language of participants, as detected by the browser's language.
-
Ensure the
client-participationuser interface is manually translated into participant language(s).- Noteworthy strings include:
showTranslationButton,hideTranslationButton,thirdPartyTranslationDisclaimer
- Noteworthy strings include:
-
Click
Set up a projectbutton within the Cloud Translation Quickstart Guide.- Follow the wizard and download the JSON private key, aka credentials file.
-
Convert the file contents into a base64-encoded string. You can do this in many ways, including:
- copying its contents into a client-side base64 encoder web app (inspect the simple JS code), or
- using your workstation terminal:
cat path/to/My-Project-abcdef0123456789.json | base64(linux/mac)
-
Set
GOOGLE_CREDENTIALS_BASE64in.env -
Set
SHOULD_USE_TRANSLATION_API=truein.env
translate strings can be found in: client-participation/js/strings/en_us.js
We use AWS SES to send email.