Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Latest commit

 

History

History
65 lines (44 loc) · 1.98 KB

ENV.md

File metadata and controls

65 lines (44 loc) · 1.98 KB

Configuration with environment variables

Some values need to be kept secret. The best option is to configure environment variables during deploymen.

AWS Elastic Beanstalk

The use of environment variables on AWS EB is described at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.managing.html.

In version 0.3.0 of our application, we have modified index.js to display NODE_ENV:

var express = require('express');

// Constants
var PORT = 8080;

// App
var app = express();
app.get('/', function (req, res) {
    res.send('Hello world with a great new feature and NODE_ENV=' + process.env.NODE_ENV + '\n');
});

app.listen(PORT);
console.log('Running on http://localhost:' + PORT);

Accordingly Dockerrun.aws.json now targets v0.3.0:

{
  "AWSEBDockerrunVersion": 1,
  "Image": {
    "Name": "jlchereau/docker-aws:v0.3.0"
  },
  "Ports" : [
    {
      "ContainerPort": "8080"
    }
  ]
}

Since dockerfile/nodejs-runtime has been deprecated overnight, we need to replace Dockerfile :

# FROM dockerfile/nodejs-runtime
FROM node:onbuild

As explained for the integration with Github via Docker hub, we have tagged this new version v0.3.0 in Git, pushed to Github and created the corresponding tag in Docker hub.

After setting up a Docker single instance in AWS, EB, click configuration.

Configuration

Then click the gear close to software configuration and add your environment variables including NODE_ENV.

Environment variables

Finally run the application in your web browser to confirm:

Application in browser

AWS Elastic Container Service