Not defined env vars in microservice app

I have not seen this behaviour in resin docs, and it seems unexpected for me.

In the context of a microservices application, if an environment var, let’s say MY_VAR is not defined as service variable in resin, the env var MY_VAR is set to “$MY_VAR”. I expect that, as well as it happens in docker-compose, that the env var MY_VAR is set to blank string.

Hi,

Is this still an issue with the latest resinOS version (Resin OS 2.12.7+rev1)? Do you have a minimal test case and docker-compose.yml, so that we can try to reproduce it?

Thanks!

Hi,

I have checked it right now, and yes it does.

My docker-compose.yml is this:

version: '2.1'
services:
  watchdog:
    build:
      context: ./myservice
      environment:
          MY_VAR: $MY_VAR

myservice is a folder with a Dockerfile using FROM resin/raspberrypi3-python:3.6-slim. The service just runs a python script with this code inside:

import os

if __name__ == '__main__':
    print(os.getenv("MY_VAR"))

The result is that, if I define an env var in resin named “MY_VAR” it prints its value. However, if I do not define the variable MY_VAR in resin, it prints literally: $MY_VAR.

Thank you for your attention!