I’ve setup a Strapi project and have deployed with Fly.io using a
Dockerfile. Have followed guidance from Fly.io Deployment - Strapi Developer Docs
With each approach there is many ways of defining environment variables used in the application and that includes:
- Defining a
.env file at the root i.e. [NAME]=[VALUE]
- Defining in the
Dockerfile i.e. `ENV [NAME]=[VALUE]
- Defining under
My question is how do you manage for multiple environments i.e. common, development, qa / test, production? The environment variables should be secret and should not be committed to VCS.
There is the following information on how to use environment specific Docker or toml files: Monorepo and Multi-Environment Deployments · Fly Docs
From my personal apps that need production, staging and local environments I’ve used a simple approach:
.env to your .dockerignore so your local env doesn’t go anywhere
- Create a production app and commit the fly.toml. Now you can
fly deploy to production.
- Create another app and save the toml file with other name like
fly.staging.toml. Now you can
fly deploy -c fly.staging.toml to staging.
- Set secrets as
fly secrets set SOME_ENV=supersecret for prod and
fly secrets set -c fly.staging.toml SOME_ENV=supersecret for staging.
[env] in your toml only for things that are ok to be public like
Hopefully this will be helpful