Reputation: 913
I am using skaffold to deploy a developer-instance of a service into a local cluster, and one of the Dockerfile's uses a deploy-token to grab code from a local repo.
FROM something
ARG DEPLOY_TOKEN
ARG DEPLOY_SECRET
## stuff
RUN git clone https://${DEPLOY_TOKEN}:${DEPLOY_SECRET}@gitlab.example.com/myGroup/funky_plugin local/path
## more stuff
This is known, and I can use .env
to feed a docker-compose.yml
file, and gitlab CI/CD variables to feed a CI/CD build process :thumbs up:
In my skaffold.yaml file, I then match this with:
build:
artifacts:
- image: registry.gitlab.example.com/myGroup/awesome_app
context: ../awesome_app
docker:
buildArgs:
STACK_TOKEN: "{{.DEPLOY_TOKEN}}"
STACK_SECRET: "{{.DEPLOY_SECRET}}"
My understanding (from reading https://skaffold.dev/docs/environment/env-file/) is that I can define these variables in skaffold.env
(in the same dir as skaffold.yaml
), and they will be picked up as environment variables - eg:
DEPLOY_TOKEN=abc
DEPLOY_SECRET=123
..... that's not happening
If I actually export DEPLOY_TOKEN=abc
& export DEPLOY_SECRET=123
... then it works.
skaffold.env
does?Upvotes: 1
Views: 2014
Reputation: 41
I don't know why it doesn't work this way. I had the same thought as you after reading the documentation.
What I found that works is that the variables in the skaffold.env
file are available to use in the skaffold.yaml
file through go templating.
So if you have MY_VAR=asdf
defined then in skaffold.yaml
file you can use it like:
...
build:
artifacts:
- image: myimage
docker:
buildArgs:
MY_VAR: "{{ .MY_VAR }}"
https://skaffold.dev/docs/environment/templating/
Upvotes: 0