How to access service variables in dockerfile template

docker

#1

Is it possible to set ARG variables in the dockerfile templates based on a service variables in Resin.io? I’d like to do something like this:

ARG sas_token
RUN curl -o node.zip "https://####.blob.core.windows.net/releases/####/node.zip$sas_token"

Unfortunately this doesn’t appear to be working currently. When I run

RUN echo "The token is '$sas_token'"

The output is

The token is ‘’


#4

The build happens independently of the eventual environment of the device. We do have two solutions for providing configuration to inform the build process that isn’t stored in the repo, one done and one in the works.

  1. You could build locally and then provide the resin infrastructure with the built artefact, it will then deploy this to the fleet. ( https://docs.resin.io/reference/cli/#deploy-appname-image- and https://resin.io/blog/multi-stage-docker-builds-for-tiny-iot-images/ )
  2. We are working on the ability to provide build time env vars, and have linked this topic to that so that here should be updated when progress is made.

#5

2 sounds like just what we need so I’m very much looking forward to that happy day. Thanks for your work!


#7

Regarding 1, sorry I misread that a bit at first. This is a good idea, however as we’re using VSTS for CI/CD, it becomes a bit more difficult. You guys should totally create a third-party VSTS release task (and probably an Octopus Deploy task) that uses the Resin CLI to push an artifact directly to Resin. That would make deploying so much better than it is now.


#8

Thanks for your feedback. I created an internal feature request for a VSTS release task and also linked it to this topic, so we can update it with news from the feature request.