Can I use DNS or other means to determine that I am running on gomix?


#1

I need to configure differently depending on whether I am on gomix or a local host.

I’m currently depending on PROJECT_NAME set in the environment. That is probably good enough. But wondering if there is a better way.

I tried to use DNS to see if it would resolve to the right domain, but the hostname I get is 73ed16d4aec2 and DNS resolve of tight-timpani.gomix.me followed by reverse DNS lookup of the resulting IP address gives `ec2-52-20-246-120.compute-1.amazonaws.com’ which I guess is where my container is being hosted.

Code, for reference:

console.log(os.hostname());
new Promise( (resolve,reject) => dns.lookup('tight-timpani.gomix.me', (err,addresses,family) => resolve(addresses)))
    .then((address) =>{console.log(address);return address})
    .then( (address) => new Promise(( resolve, reject) => dns.reverse(address, (err, hostnames) => resolve(hostnames)))) 
    .then((address) =>{console.log( address);return address})

Gives this result

73ed16d4aec2
52.20.246.120
54.86.139.237
[ 'ec2-52-20-246-120.compute-1.amazonaws.com' ]

Config code is

if (process.env.PROJECT_NAME ) {
  devServer = 'webpack-dev-server/client?https://' + process.env.PROJECT_NAME + '.gomix.me';
} else {
  devServer = 'webpack-dev-server/client?https://localhost:3000'
}

Thanks,
Mike


#2

Hi Mike,

sorry if this went out of our radar! Yes, you can use process.env.INSIDE_DOCKER. We didn’t document it because this is likely to change to something more informative, like INSIDE_GOMIX… but for now you can use it :slight_smile: