Skip to content

Commit c51fbbf

Browse files
msuzoaguimjosh
authored andcommitted
adds ability to dynamically set config env variable (#2)
Why: * current setup does not allow for dynamically setting what config to read via Dockerfile directly or via use of env variables in docker-compose file * given multiple instances/environemts, need to be able to use same Dockerfile to set what config to read dyamically This change address the need by: * introducing the use of ARG values in Dockerfile to set value of CONFIG env variable at image build time
1 parent b391cd4 commit c51fbbf

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ ENV PORT=3000
1010
EXPOSE ${PORT}
1111

1212
# Which configuration in the config.json file to load
13-
ENV CONFIG="production"
13+
ARG CONFIG="production"
14+
ENV CONFIG=${CONFIG}
1415

1516
# Location of config.json
1617
ENV CONFIG_DIR=/usr/src/app/config/

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Flow for automated deployment:
1313

1414
This webhook is intended for use with private Docker Hub repositories and self hosted Docker Swarm instances.
1515

16-
To get started, clone this repository, add an image of it to your Docker Hub account, configure `config.json` and deploy it to your Docker Swarm as a service (see steps below).
16+
To get started, clone this repository, add an image of it to your Docker Hub account, configure config.json and deploy it to your Docker Swarm as a service (see steps below).
1717

1818
[Read more about this service in this blog post.](https://medium.com/@iaincollins/docker-swarm-automated-deployment-cb477767dfcf)
1919

@@ -27,6 +27,14 @@ Supported environment variables:
2727
USERNAME="docker-hub-username" // A Docker Hub account username
2828
PASSWORD="docker-hub-password" // A Docker Hub account password
2929

30+
**note:** the value for `CONFIG` environment variable can be passed in at image build time:
31+
32+
```
33+
docker build \
34+
--build-arg CONFIG=part-of-config-dot-json-file-to-load \
35+
-t docker-hub-username/docker-deploy-webhook .
36+
```
37+
3038
The `config.json` file defines each environment:
3139

3240
{

0 commit comments

Comments
 (0)