We have a simple pipeline that builds a Docker image with our app, pushes it to DockerHub, and finally deploys it to an ECS cluster.
Each cluster runs to a different environment (e.g. Development, Staging, Production), and we need to pass different environment variables for our application in each of these deployed environments. For example, the Google Analytics Tracker ID is different in Development and in Production.
We are using Deployment Variables in Bitbucket Pipelines to achieve this. For example:
- Test Deployment
- GOOGLE_ANALYTICS_ID = myDevId
- Production Deployemtn
- GOOGLE_ANALYTICS_ID = myProductionId
But we can't figure out this...
How do we take these values (e.g. $GOOGLE_ANALYTICS_ID) in the bitbucket-pipelines.yml file and pass them all the way through to our deployed Docker containers in ECS? What is the best practice approach?
We're new to CI/CD, so trying to figure out what the right approach is.
Do we need to build and deploy separate Docker images for each environment? Or is there a way to pass in these environment variables to ECS as part of deploying the Docker image?
Any help, reference articles, etc, is really appreciated. Thanks