Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
valterh4ck3r committed May 1, 2018
1 parent e8bd102 commit c58480c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typings/

# Optional npm cache directory
.npm
*-lock.json

# Optional eslint cache
.eslintcache
Expand All @@ -54,6 +55,3 @@ typings/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "3.3"
services:
node:
image: node:9.11.1
volumes:
- ./node:/node
command: sh -c "cd /node && npm install --save && node app"
env_file:
- ./env/local.env
1 change: 1 addition & 0 deletions env/local.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_USER=DATABASE_USER
1 change: 1 addition & 0 deletions node/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('Envs : ' + JSON.stringify(process.env))
12 changes: 12 additions & 0 deletions node/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "node",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
16 changes: 16 additions & 0 deletions node/secrets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// secrets.js
const fs = require("fs"),
util = require("util");

module.exports = {
// Get a secret from its name
get(secret){
try{
// Swarm secret are accessible within tmpfs /run/secrets dir
return fs.readFileSync(util.format('/run/secrets/%s', secret), "utf8").trim();
}
catch(e){
return false;
}
}
};

0 comments on commit c58480c

Please sign in to comment.