Skip to content

Commit

Permalink
- Docker: Move environment variables out of the docker-compose.yml an…
Browse files Browse the repository at this point in the history
…d added a command to the Dockerfile to copy .env_template to .env
  • Loading branch information
paschmann committed Jan 27, 2022
1 parent d41165e commit 0350d78
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 43 deletions.
43 changes: 0 additions & 43 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,6 @@ services:
build:
context: ./server
dockerfile: Dockerfile
environment:
- NODE_ENV=prod

# Postgres DB Connection Parameters
- DB_HOST=db
- DB_NAME=postgres
- DB_PORT=5432
- DB_USERNAME=postgres
- DB_PASSWORD=password
- DB_SCHEMA=public

# Node/Express API Port
- API_PORT=8000
- TOKEN_SECRET=myappsecret

# Image comparison options
- PIXELMATCH_PROCESSING_THRESHOLD=0.0
- PIXELMATCH_OUTPUT_ALPHA=0.6
- CAPTURE_IMAGE_HEIGHT=5000
- CAPTURE_IMAGE_WIDTH=1024

# Option for saving screenshots locally or to AWS S3
- FILESYSTEM=LOCAL
- DOMAIN=api

# Required if FILESYSTEM=S3
- S3_BUCKET=
- AWS_ACCESS_KEY_ID=
- AWS_SECRET_ACCESS_KEY=

# Mail Notification Options
- MAILSYSTEM=SMTP #SMTP or SES
- [email protected]

# Required if MAILSYSTEM=S3
- SES_ACCESS_KEY=
- SES_ACCESS_SECRET=

# Required if MAILSYSTEM=SMTP
- SMTP_HOST=smtp.mailgun.org
- SMTP_PORT=587
- SMTP_USER=
- SMTP_PASSWORD=

ports:
- 8000:8000
Expand Down
2 changes: 2 additions & 0 deletions server/.env_template
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
NODE_ENV=prod

# Postgres DB Connection Parameters
DB_HOST=db
DB_NAME=postgres
Expand Down
1 change: 1 addition & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ RUN set -x \

WORKDIR /app
COPY . .
COPY /.env_template .env
RUN npm i --production
CMD ["pm2-runtime", "pm2.config.js"]

4 comments on commit 0350d78

@vladiiancu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi

Doesn't this change affect how easy it is to change variables after you deploy?

@paschmann
Copy link
Owner Author

@paschmann paschmann commented on 0350d78 Feb 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vladiiancu - that's a good point. I believe we could still override the variables in the compose file if needed, but it would not be as easy. A good compromise might be to add a reference from the compose file to the .env_template to provide this flexibility. Let me know your thoughts.

e.g.

api:
env_file:
- ./server/.env_template

@vladiiancu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that yes. As long the app is aware of the changes (without the need to restart)

@paschmann
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vladiiancu - the app server will always need to restarted because the environment variables are picked up when the nodeJS starts up.

Please sign in to comment.