I have defined a env variable named GRPC_ADDR
in CircleCI under the project settings. I want to use this variable while deploying with my app on a server using ssh. I use docker-compose to orchestrate my containers and docker-compose
depends on the GRPC_ADDR
. However, when the job executes docker-compose
can seem to find the env variable. Here is my CircleCI config:
jobs:
deploy:
machine: true
steps:
- add_ssh_keys:
fingerprints:
- #fingerprint here
- run:
name: Setup Environment Variables
command: |
echo "export GRPC_ADDR=$GRPC_ADDR" >> $BASH_ENV
- run:
name: Deploy over SSH
command: |
ssh $SSH_USER@$SERVER bash << EOF
cd example-dir
docker-compose stop; # stop the containers if they are runnning
docker-compose up -d --build; #docker-compose can't find env variable here
EOF
workflows:
version: 2
build_and_deploy:
jobs:
- deploy
docker-compose
gives me this warning as it can’t find the env variable The GRPC_ADDR variable is not set. Defaulting to a blank string.
. This leads my deployment to fail as that env variable is required.
So, how can I fix this issue?
Thanks in advance.