We currently deploy all apps using Docker.
This project contains Docker infrastructure and a
GitHub action that automatically
builds and tags a Docker image on each commit. The image name is
pcic/plan2adaptv2.
It is best practice to configure a web app externally, at run-time, typically using environment variables for any simple (atomic, e.g., string) configuration values.
CRA makes this a little challenging, but we use the following build flow to allow us to inject this configuration.
- Configuration information is stored in
public/config.js. This file is mounted in our docker containers with environment specific configuration options. - Avoid use of
process.env. While convenient, these variables are build time required so can't be used for environments unless we build at run time. Building at runtime incurs a significant time delay, so shouldbe avoided. - Use
window.env(defined in config.js) as an alternative, any environment specific information is appropriate here. PUBLIC_URLis special and is handled using a replacement during docker container startup. A full explanation can be found in the build documentation.
See the contents of the docker directory for an example of how
to run the P2A Docker image. The Makefile shows how to run the
image using docker-compose. You may wish to copy and modify
docker-compose.yaml to construct a production deployment.
Note: All deployment environment variables, except REACT_APP_APP_VERSION,
are provided by docker/docker-compose.yaml via the /app/config.js file mount.
The frontend fetches region boundaries from the URL configured by
REACT_APP_REGIONS_GEOJSON_URL.
For production, prefer hosting the GeoJSON on the same external file service used for other managed datasets such as impacts, stats, and assessments, rather than mounting it into the frontend container.
In Docker deployments, set REACT_APP_REGIONS_GEOJSON_URL in config.js to
that hosted file URL.