Reputation: 1749
I am new to Gitlab CI/CD and I have the following issue.
Suppose I have some environment variables in my local setup in an .env
file. Something like this:
SOME_URL=https://someurl.com/
SECRET_KEY=verysecretkey
For my setup to work, I need both of these environment variables. The SECRET_KEY
is not in the .env
for the deployment. It is in the "secrets" in GitLab. If I have something like this in my Docker Compose file:
environment:
SECRET_KEY: ${SECRET_KEY}
env_file:
- .env
My two questions are:
SECRET_KEY
and SOME_URL
?SECRET_KEY
with secrets?Thanks for your answers in advance!
Upvotes: 1
Views: 587
Reputation: 2017
The variables defined in Gitlab CI/CD are available inside the pipeline (.gitlab-ci.yml). In the step, you are executing the docker-compose command, the variable will be replaced then set in your container thanks to environment: SECRET_KEY: ${SECRET_KEY}. That should be fine.
https://docs.gitlab.com/ee/ci/variables/
https://docs.docker.com/compose/compose-file/#variable-substitution
Upvotes: 1