This repository was archived by the owner on Jul 19, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +134
-0
lines changed Expand file tree Collapse file tree 6 files changed +134
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Logs
2
+ logs
3
+ * .log
4
+ npm-debug.log *
5
+ yarn-debug.log *
6
+ yarn-error.log *
7
+
8
+ # Runtime data
9
+ pids
10
+ * .pid
11
+ * .seed
12
+ * .pid.lock
13
+
14
+ # Directory for instrumented libs generated by jscoverage/JSCover
15
+ lib-cov
16
+
17
+ # Coverage directory used by tools like istanbul
18
+ coverage
19
+
20
+ # nyc test coverage
21
+ .nyc_output
22
+
23
+ # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24
+ .grunt
25
+
26
+ # Bower dependency directory (https://bower.io/)
27
+ bower_components
28
+
29
+ # node-waf configuration
30
+ .lock-wscript
31
+
32
+ # Compiled binary addons (http://nodejs.org/api/addons.html)
33
+ build /Release
34
+
35
+ # Dependency directories
36
+ node_modules /
37
+ jspm_packages /
38
+
39
+ # Typescript v1 declaration files
40
+ typings /
41
+
42
+ # Optional npm cache directory
43
+ .npm
44
+
45
+ # Optional eslint cache
46
+ .eslintcache
47
+
48
+ # Optional REPL history
49
+ .node_repl_history
50
+
51
+ # Output of 'npm pack'
52
+ * .tgz
53
+
54
+ # Yarn Integrity file
55
+ .yarn-integrity
56
+
57
+ # dotenv environment variables file
58
+ .env
Original file line number Diff line number Diff line change
1
+ FROM node:6-alpine
2
+
3
+ RUN mkdir -p /usr/src \
4
+ && mkdir -p /run/secrets \
5
+ && echo "admin" > /run/secrets/db_user \
6
+ && echo "password" > /run/secrets/db_pass
7
+
8
+ WORKDIR /usr/src
9
+
10
+ COPY ./ /usr/src
11
+
12
+ RUN npm install
13
+
14
+ CMD [ "node" , "./test/index.js" ]
Original file line number Diff line number Diff line change
1
+ # Docker Secrets
2
+ This NPM module loads Docker secrets from the ` /run/secrets ` directory created by Docker Swarm into a JS object for use within Node.js applications.
3
+
4
+
5
+ ``` javascript
6
+ const secrets = require (' docker-secrets' );
7
+ cosnole .log (secrets);
8
+ ```
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const fs = require ( 'fs' ) ;
4
+ const path = require ( 'path' ) ;
5
+
6
+ const SECRETS_DIR = '/run/secrets' ;
7
+ const output = { } ;
8
+
9
+ const files = fs . readdirSync ( SECRETS_DIR ) ;
10
+
11
+ files . forEach ( function ( file , index ) {
12
+ const fullPath = path . join ( SECRETS_DIR , file ) ;
13
+ const key = file ;
14
+ const data = fs . readFileSync ( fullPath , 'utf8' ) . toString ( ) . trim ( ) ;
15
+
16
+ output [ key ] = data ;
17
+ } ) ;
18
+
19
+ module . exports = output ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " docker-sercrets" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " Converts Docker Secrets mounted into a container to an object." ,
5
+ "keywords" : [
6
+ " docker" ,
7
+ " swarm" ,
8
+ " docker-secrets" ,
9
+ " node-docker" ,
10
+ " containers" ,
11
+ " node.js" ,
12
+ " secrets"
13
+ ],
14
+ "main" : " index.js" ,
15
+ "scripts" : {
16
+ "test" : " echo \" Error: no test specified\" && exit 1"
17
+ },
18
+ "author" : " Alex Rhea <alex.rhea@gmail.com>" ,
19
+ "repository" : {
20
+ "type" : " git" ,
21
+ "url" : " https://github.com/arhea/node-docker-secrets.git"
22
+ },
23
+ "bugs" : {
24
+ "url" : " http://github.com/arhea/node-docker-secrets/issues"
25
+ },
26
+ "license" : " Apache-2.0" ,
27
+ "engines" : {
28
+ "node" : " >= 6"
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const secrets = require ( '../index.js' ) ;
4
+
5
+ console . log ( secrets ) ;
You can’t perform that action at this time.
0 commit comments