Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit aa652e0

Browse files
committed
Refactor how environment variables are set
This is to avoid sensitive keys being checked into source control. I've specified the `.env` file after the application supplied config, so we can overwrite what the application has provided.
1 parent 3b9bd5b commit aa652e0

File tree

3 files changed

+121
-63
lines changed

3 files changed

+121
-63
lines changed

.env.example

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
CD_BADGES=badges
3+
CD_DOJOS=dojos
4+
CD_EVENTBRITE=eventbrite
5+
CD_EVENTS=events
6+
CD_ORGANISATIONS=organisations
7+
CD_USERS=users
8+
EMAIL_DEFAULT_FROM='The CoderDojo Team <[email protected]>'
9+
EMAIL_SERVICE=email
10+
EVENTS_SERVICE=events-service
11+
EVENT_URL=http://localhost:8000/events/
12+
# Eventbrite API: get these details from https://www.eventbrite.com/myaccount/apps/
13+
# Client secret
14+
EVENTBRITE_SECRET_KEY=
15+
# API key
16+
EVENTBRITE_PUBLIC_KEY=
17+
# Not sure what this does. Possibly a shared secret for use in the oauth process.
18+
EVENTBRITE_HASH_KEY=correct-horse-battery-staple
19+
# Get this from https://console.cloud.google.com/google/maps-apis/credentials
20+
GOOGLE_MAPS_KEY=
21+
ICS_EVENT_URL=http://localhost:8000/api/3.0/events/
22+
KUE_HOST=kue
23+
KUE_REQUIRED='true'
24+
MAILDEV_ENABLED=true
25+
MICROSERVICE_PORT=3000
26+
NODE_ENV=development
27+
POSTGRES_HOST=db
28+
POSTGRES_PASSWORD=QdYx3D5y
29+
SMTP_HOST=maildev
30+
SMTP_PORT=25
31+
SMTP_SECURE=false
32+
TEMPLATES_DIR=/usr/src/app/node_modules/cp-translations/email-templates
33+
TRANSPORT=smtp
34+
URL_BASE=http://localhost:8000

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ Note that the Forums and [Badges](installing-badgekit.md) will not be operable
8383
in local development mode, to run these, you need to install both
8484
[NodeBB](https://nodebb.org) and [BadgeKit](installing-badgekit.md) locally, which are a different problem.
8585

86+
87+
## Evironent settings
88+
89+
All these are in the `.env.example` file, which should be copied to `.env`.
90+
Once copied, you'll want to fill in some of the details. Currently you'll need
91+
keys for Google Maps and Eventbrite.
92+
8693
## Making code changes and working locally
8794

8895
### Creating your own forks
@@ -189,3 +196,6 @@ This is because both `cp-zen-frontent` and `cp-zen-platform` independently depen
189196

190197
You might find other dependency chains that are similar, so be aware that you might have to merge before updating dependent repos.
191198

199+
200+
201+

docker-compose.yml

+77-63
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
- pg-data:/data/postgres
1212
- ./cd-db/dumps:/db
1313
environment:
14-
- POSTGRES_PASSWORD=QdYx3D5y
14+
- POSTGRES_PASSWORD
1515
ports:
1616
- '5434:5432'
1717
kue:
@@ -22,7 +22,9 @@ services:
2222
working_dir: /usr/src/app
2323
ports:
2424
- '8000:8000'
25-
env_file: ./workspace-zen/cp-zen-platform/web/config/development.env
25+
env_file:
26+
- ./workspace-zen/cp-zen-platform/web/config/development.env
27+
- ./.env
2628
command: yarn dev
2729
depends_on:
2830
- users
@@ -38,16 +40,17 @@ services:
3840
- maildev
3941
- email
4042
environment:
41-
- CD_USERS=users
42-
- CD_DOJOS=dojos
43-
- CD_EVENTS=events
44-
- CD_BADGES=badges
45-
- CD_EVENTBRITE=eventbrite
46-
- CD_ORGANISATIONS=organisations
47-
- EVENTS_SERVICE=events-service
48-
- EMAIL_SERVICE=email
49-
- NODE_ENV=development
50-
- MAILDEV_ENABLED=true
43+
- CD_USERS
44+
- CD_DOJOS
45+
- CD_EVENTS
46+
- CD_BADGES
47+
- CD_EVENTBRITE
48+
- CD_ORGANISATIONS
49+
- EVENTS_SERVICE
50+
- EMAIL_SERVICE
51+
- GOOGLE_MAPS_KEY
52+
- NODE_ENV
53+
- MAILDEV_ENABLED
5154
volumes:
5255
- ./workspace-zen/cp-zen-platform:/usr/src/app:Z
5356
- ./workspace-zen/cp-zen-frontend:/usr/src/app/node_modules/cp-zen-frontend:ro
@@ -57,26 +60,27 @@ services:
5760
command: yarn dev
5861
working_dir: /usr/src/app
5962
environment:
60-
- NODE_ENV=development
63+
- NODE_ENV
6164
volumes:
6265
- ./workspace-zen/cp-zen-frontend:/usr/src/app:Z
6366
- ./workspace-zen/cp-translations:/usr/src/app/node_modules/cp-translations:ro
6467
dojos:
6568
image: node:carbon
66-
env_file: ./workspace-zen/cp-dojos-service/config/development.env
69+
env_file:
70+
- ./workspace-zen/cp-dojos-service/config/development.env
71+
- ./.env
6772
working_dir: /usr/src/app
6873
command: yarn dev
6974
environment:
70-
- NODE_ENV=development
71-
- CD_USERS=users
72-
- CD_EVENTS=events
73-
- CD_BADGES=badges
74-
- CD_ORGANISATIONS=organisations
75-
- POSTGRES_HOST=db
76-
- KUE_REQUIRED='true'
77-
- KUE_HOST=kue
78-
- GOOGLE_MAPS_KEY=AIzaSyAWA2gcHWQsS7Snr_p86QUxGwM0hBn95pQ
79-
- MAILDEV_ENABLED=true
75+
- NODE_ENV
76+
- CD_USERS
77+
- CD_EVENTS
78+
- CD_BADGES
79+
- CD_ORGANISATIONS
80+
- POSTGRES_HOST
81+
- KUE_REQUIRED
82+
- KUE_HOST
83+
- MAILDEV_ENABLED
8084
depends_on:
8185
- db
8286
- kue
@@ -85,35 +89,39 @@ services:
8589
- ./workspace-zen/cp-translations:/usr/src/app/node_modules/cp-translations:ro
8690
users:
8791
image: node:carbon
88-
env_file: ./workspace-zen/cp-users-service/config/development.env
92+
env_file:
93+
- ./workspace-zen/cp-users-service/config/development.env
94+
- ./.env
8995
working_dir: /usr/src/app
9096
command: yarn dev
9197
environment:
92-
- NODE_ENV=development
93-
- CD_DOJOS=dojos
94-
- CD_EVENTS=events
95-
- CD_BADGES=badges
96-
- POSTGRES_HOST=db
97-
98-
- MAILDEV_ENABLED=true
98+
- NODE_ENV
99+
- CD_DOJOS
100+
- CD_EVENTS
101+
- CD_BADGES
102+
- POSTGRES_HOST
103+
- CDF_ADMINS
104+
- MAILDEV_ENABLED
99105
depends_on:
100106
- db
101107
volumes:
102108
- ./workspace-zen/cp-users-service:/usr/src/app:Z
103109
- ./workspace-zen/cp-translations:/usr/src/app/node_modules/cp-translations:ro
104110
events:
105111
image: node:carbon
106-
env_file: ./workspace-zen/cp-events-service/config/development.env
112+
env_file:
113+
- ./workspace-zen/cp-events-service/config/development.env
114+
- ./.env
107115
working_dir: /usr/src/app
108116
command: yarn dev
109117
environment:
110-
- CD_USERS=users
111-
- CD_DOJOS=dojos
112-
- CD_BADGES=badges
113-
- NODE_ENV=development
114-
- POSTGRES_HOST=db
115-
- KUE_REQUIRED='true'
116-
- KUE_HOST=kue
118+
- CD_USERS
119+
- CD_DOJOS
120+
- CD_BADGES
121+
- NODE_ENV
122+
- POSTGRES_HOST
123+
- KUE_REQUIRED
124+
- KUE_HOST
117125
depends_on:
118126
- db
119127
- kue
@@ -122,37 +130,43 @@ services:
122130
badges:
123131
image: node:carbon
124132
working_dir: /usr/src/app
125-
env_file: ./workspace-zen/cp-badges-service/config/development.env
133+
env_file:
134+
- ./workspace-zen/cp-badges-service/config/development.env
135+
- ./.env
126136
command: yarn dev
127137
environment:
128-
- CD_USERS=users
129-
- CD_DOJOS=dojos
130-
- CD_EVENTS=events
131-
- NODE_ENV=development
138+
- CD_USERS
139+
- CD_DOJOS
140+
- CD_EVENTS
141+
- NODE_ENV
132142
volumes:
133143
- ./workspace-zen/cp-badges-service:/usr/src/app:Z
134144
- ./workspace-zen/cp-translations:/usr/src/app/node_modules/cp-translations:ro
135145
eventbrite:
136146
image: node:carbon
137147
command: yarn dev
138-
env_file: ./workspace-zen/cp-eventbrite-service/config/development.env
148+
env_file:
149+
- ./workspace-zen/cp-eventbrite-service/config/development.env
150+
- ./.env
139151
working_dir: /usr/src/app
140152
environment:
141-
- CD_DOJOS=dojos
142-
- CD_EVENTS=events
143-
- NODE_ENV=development
153+
- CD_DOJOS
154+
- CD_EVENTS
155+
- NODE_ENV
144156
volumes:
145157
- ./workspace-zen/cp-eventbrite-service:/usr/src/app:Z
146158
- ./workspace-zen/cp-translations:/usr/src/app/node_modules/cp-translations:ro
147159
organisations:
148160
image: node:carbon
149161
command: yarn dev
150162
working_dir: /usr/src/app
151-
env_file: ./workspace-zen/cp-organisations-service/config/development.env
163+
env_file:
164+
- ./workspace-zen/cp-organisations-service/config/development.env
165+
- ./.env
152166
environment:
153-
- CD_USERS=users
154-
- NODE_ENV=development
155-
- POSTGRES_HOST=db
167+
- CD_USERS
168+
- NODE_ENV
169+
- POSTGRES_HOST
156170
depends_on:
157171
- db
158172
volumes:
@@ -165,8 +179,8 @@ services:
165179
depends_on:
166180
- db
167181
environment:
168-
- ICS_EVENT_URL=http://localhost:8000/api/3.0/events/
169-
- EVENT_URL=http://localhost:8000/events/
182+
- ICS_EVENT_URL
183+
- EVENT_URL
170184
volumes:
171185
- ./workspace-zen/services/events-service:/usr/src/app:Z
172186
maildev:
@@ -178,14 +192,14 @@ services:
178192
command: yarn dev
179193
working_dir: /usr/src/app
180194
environment:
181-
- URL_BASE=http://localhost:8000
182-
- EMAIL_DEFAULT_FROM='The CoderDojo Team <[email protected]>'
183-
- MICROSERVICE_PORT=3000
184-
- TRANSPORT=smtp
185-
- SMTP_HOST=maildev
186-
- TEMPLATES_DIR=/usr/src/app/node_modules/cp-translations/email-templates
187-
- SMTP_SECURE=false
188-
- SMTP_PORT=25
195+
- URL_BASE
196+
- EMAIL_DEFAULT_FROM
197+
- MICROSERVICE_PORT
198+
- TRANSPORT
199+
- SMTP_HOST
200+
- TEMPLATES_DIR
201+
- SMTP_SECURE
202+
- SMTP_PORT
189203
volumes:
190204
- ./workspace-zen/services/cp-email-service:/usr/src/app:Z
191205
- ./workspace-zen/cp-translations:/usr/src/app/node_modules/cp-translations:ro

0 commit comments

Comments
 (0)