Refactor to use a different name for the env vars (otherwise resin-vars overrides it with a null value)

This commit is contained in:
Pablo Carranza Vélez 2015-10-14 18:50:26 -03:00
parent 33d402c3c0
commit 4bcba5adf6
3 changed files with 13 additions and 7 deletions

View File

@ -1,4 +1,4 @@
* Remove default Pubnub and Mixpanel keys as they are now passed at build time [Pablo]
* Use buildtime env vars as the default Pubnub and Mixpanel keys [Pablo]
# v1.1.0

View File

@ -58,9 +58,9 @@ stop-supervisor:
supervisor: gosuper
cp Dockerfile.$(ARCH) Dockerfile
echo "ENV VERSION "`jq -r .version package.json` >> Dockerfile
echo "ENV PUBNUB_PUBLISH_KEY $(PUBNUB_PUBLISH_KEY)" >> Dockerfile
echo "ENV PUBNUB_SUBSCRIBE_KEY $(PUBNUB_SUBSCRIBE_KEY)" >> Dockerfile
echo "ENV MIXPANEL_TOKEN $(MIXPANEL_TOKEN)" >> Dockerfile
echo "ENV DEFAULT_PUBNUB_PUBLISH_KEY $(PUBNUB_PUBLISH_KEY)" >> Dockerfile
echo "ENV DEFAULT_PUBNUB_SUBSCRIBE_KEY $(PUBNUB_SUBSCRIBE_KEY)" >> Dockerfile
echo "ENV DEFAULT_MIXPANEL_TOKEN $(MIXPANEL_TOKEN)" >> Dockerfile
docker build --no-cache=$(DISABLE_CACHE) -t $(IMAGE) .
-rm Dockerfile

View File

@ -7,15 +7,21 @@ checkInt = (s) ->
return
return i
checkValidKey = (s) ->
# Make sure `s` exists and is not an empty string, or 'null'.
if !s? or s == 'null' or s == ''
return
return s
module.exports = config =
apiEndpoint: process.env.API_ENDPOINT ? 'https://api.resin.io'
listenPort: process.env.LISTEN_PORT ? 80
gosuperAddress: "http://unix:#{process.env.GOSUPER_SOCKET}:"
registryEndpoint: process.env.REGISTRY_ENDPOINT ? 'registry.resin.io'
pubnub:
subscribe_key: process.env.PUBNUB_SUBSCRIBE_KEY ? ''
publish_key: process.env.PUBNUB_PUBLISH_KEY ? ''
mixpanelToken: process.env.MIXPANEL_TOKEN ? ''
subscribe_key: checkValidKey(process.env.PUBNUB_SUBSCRIBE_KEY) ? process.env.DEFAULT_PUBNUB_SUBSCRIBE_KEY
publish_key: checkValidKey(process.env.PUBNUB_PUBLISH_KEY) ? process.env.DEFAULT_PUBNUB_PUBLISH_KEY
mixpanelToken: checkValidKey(process.env.MIXPANEL_TOKEN) ? process.env.DEFAULT_MIXPANEL_TOKEN
dockerSocket: process.env.DOCKER_SOCKET ? '/run/docker.sock'
supervisorImage: process.env.SUPERVISOR_IMAGE ? 'resin/rpi-supervisor'
configMountPoint: process.env.CONFIG_MOUNT_POINT ? '/mnt/mmcblk0p1/config.json'