This repository was archived by the owner on Jan 27, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,19 @@ sha: COMMIT_INFO_SHA
5555remote: COMMIT_INFO_REMOTE
5656```
5757
58+ ### For Docker containers
59+
60+ When running your application inside a Docker container, you should set these environment variables using ` -e ` syntax.
61+
62+ ``` shell
63+ $ docker run \
64+ -e COMMIT_INFO_BRANCH=develop \
65+ -e COMMIT_INFO_SHA=e5d9eb66474bc0b681da9240aa5a457fe17bc8f3 \
66+ < container name>
67+ ```
68+
69+ See [ docker-example] ( docker-example ) for a full example.
70+
5871## Individual methods
5972
6073In addition to ` commitInfo ` this module also exposes individual promise-returning
Original file line number Diff line number Diff line change 1+ FROM node:alpine
2+ WORKDIR /app
3+ COPY index.js /app
4+ ENTRYPOINT [ "node" , "." ]
Original file line number Diff line number Diff line change 1+ # Docker example
2+
3+ Shows how to pass environment variables with Git commit information when starting a Docker container.
4+
5+ To see the example:
6+
7+ ``` text
8+ $ ./build.sh
9+ ...
10+
11+ Successfully built 54bcfe1f016e
12+ Successfully tagged local/test:latest
13+ docker-example index.js
14+ {
15+ branch: 'develop',
16+ message: 'This is commit message',
17+ email: null,
18+ author: null,
19+ sha: 'e5d9eb66474bc0b681da9240aa5a457fe17bc8f3',
20+ remote: null
21+ }
22+ ```
23+
24+ See [ build.sh] ( build.sh ) to see how we are passing the commit values as environment variables.
25+
26+ If you want to see debug messages, run the command with ` DEBUG=commit-info ` environment variable.
27+
28+ ``` text
29+ $ DEBUG=commit-info ./build.sh
30+ ```
Original file line number Diff line number Diff line change 1+ set e+x
2+
3+ LOCAL_NAME=local/test
4+
5+ docker build -t $LOCAL_NAME .
6+
7+ # run the example with source code and node_modules
8+ # mapped from the parent folder
9+ # pass commit message and branch and sha using environment variable -e
10+ # you can pass all other COMMIT_INFO_* if needed
11+ # if the user wants to see debug messages, just pass the environment
12+ # variable DEBUG as is
13+ docker run \
14+ -v $PWD /../src:/app/src -v $PWD /../node_modules:/app/node_modules \
15+ -e COMMIT_INFO_BRANCH=develop \
16+ -e COMMIT_INFO_MESSAGE=" This is commit message" \
17+ -e COMMIT_INFO_SHA=e5d9eb66474bc0b681da9240aa5a457fe17bc8f3 \
18+ -e DEBUG \
19+ local/test
Original file line number Diff line number Diff line change 1+ console . log ( 'docker-example index.js' )
2+
3+ const { commitInfo } = require ( './src' )
4+ commitInfo ( ) . then ( console . log )
You can’t perform that action at this time.
0 commit comments