Strapi, Docker, and Fly: Managing multiple environment variables / configuration

From my personal apps that need production, staging and local environments I’ve used a simple approach:

  1. Add .env to your .dockerignore so your local env doesn’t go anywhere
  2. Create a production app and commit the fly.toml. Now you can fly deploy to production.
  3. 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.
  4. Set secrets as fly secrets set SOME_ENV=supersecret for prod and fly secrets set -c fly.staging.toml SOME_ENV=supersecret for staging.
  5. Use [env] in your toml only for things that are ok to be public like NODE_ENV or TZ.

Hopefully this will be helpful :slight_smile:

3 Likes