Skip to content

Commit

Permalink
update README and sample compose files
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand authored and dmitrizagidulin committed Jul 11, 2024
1 parent 7b494cf commit c013e57
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 35 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next
# Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Check out [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

# MongoDB
This app currently requires MongoDB for its backend storage. To set up MongoDB for this app:
Expand All @@ -42,18 +42,19 @@ This app currently requires MongoDB for its backend storage. To set up MongoDB f
* From there create a collection, as well as a user with read and write permissions.
* Copy `.env.example`, and rename the copy `.env`
* Copy all the information from your Atlas cluster into the appropriate fields in the `.env` file.
* NOTE: If the app can't connect to your Mongo Atlas collection, make sure that you've added your server IP to the whitelist for your Mongo Atlas account.

TROUBLESHOOTING: If the app can't connect to your Mongo Atlas collection, make sure that you've added your server IP to the whitelist for your Mongo Atlas account.

# Docker

We've provided both a sample Dockerfile and two sample docker compose files.

The docker compose files are identical except that the production version includes configuration for [nginxproxy/nginx-proxy](https://github.com/nginx-proxy/nginx-proxy) and [nginxproxy/acme-companion](https://github.com/nginx-proxy/acme-companion).
The two docker compose files are identical except that the production version includes configuration for [nginxproxy/nginx-proxy](https://github.com/nginx-proxy/nginx-proxy) and [nginxproxy/acme-companion](https://github.com/nginx-proxy/acme-companion).

Both compose files includes a HEALTHCHECK configuration that monitors the running web app container. If the healthcheck returns 'unhealthy' three times in a row, the the [willfarrell/autoheal](https://github.com/willfarrell/docker-autoheal) service restarts the container.
Both compose files include a HEALTHCHECK configuration that monitors the running web app container. If the healthcheck returns 'unhealthy' three times in a row, the the [willfarrell/autoheal](https://github.com/willfarrell/docker-autoheal) service restarts the container.

You can also configure an SMTP email server, which the healtcheck will use to send emails to an email recipient whose address you can also configure. The healthcheck only sends emails if the check returns unhealthy.

And finally you can set a webhook on both the healtcheck and the autoheal, to which the same notifications of unhealthy status will be sent. We use the Slack webhook for this.

We've set the configuation values in the 'environment' sections of the compose file, but you can also use a .env file. We've in fact also provided a .env file in which we've configured the mongo user, password, and host. Feel free to add environment variable either way - they are equivalent. The .env file may be more secure.
We've set the configuation values in the 'environment' sections of the compose file, but you can also use a .env file, like the .env.example we provide. The .env file may be more secure.
36 changes: 20 additions & 16 deletions docker-compose.example.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ services:
container_name: web-verifier-plus
build: .
environment:
- VIRTUAL_HOST=${URL}
- VIRTUAL_PORT=3000
- LETSENCRYPT_HOST=${URL}
- HEALTH_CHECK_SMTP_HOST=
- HEALTH_CHECK_SMTP_HOST=add your email host, like smtp.sendgrid.net
- HEALTH_CHECK_SMTP_USER=
- HEALTH_CHECK_SMTP_PASS=
- HEALTH_CHECK_EMAIL_FROM=Digital Credentials Consortium Demo Issuer <[email protected]>
- HEALTH_CHECK_EMAIL_RECIPIENT=
- HEALTH_CHECK_EMAIL_RECIPIENT=the email addresss of whoever should receive unhealthy notications
- HEALTH_CHECK_EMAIL_SUBJECT="DCC Dashboard Issuer Coordinator Microservice Healthcheck"
- HEALTH_CHECK_WEB_HOOK=
- HEALTH_CHECK_SERVICE_URL=http://localhost:3000/api/healthz
- HEALTH_CHECK_WEB_HOOK=a webhook like those of Slack
- HEALTH_CHECK_SERVICE_URL=http://testing.dcconsortium.org/api/healthz - the healthz endpoint
- HEALTH_CHECK_SERVICE_NAME=VERIFIER-PLUS
- DB_USER=your mongo user
- DB_PASS=and mongo password
- DB_HOST=and mongo host
- VIRTUAL_HOST=testing.dcconsortium.org - replace with your server host
- VIRTUAL_PORT=3000 - and port
- LETSENCRYPT_HOST=testing.dcconsortium.org - usually the same as VIRTUAL_HOST
healthcheck:
test: ["CMD", "node", "healthcheck.mjs"]
interval: 120s
interval: 30m
retries: 3
start_period: 30s
timeout: 80s
Expand All @@ -28,21 +31,21 @@ services:
labels:
autoheal: true
autoheal:
image: willfarrell/autoheal:latest
restart: always
environment:
- AUTOHEAL_INTERVAL=60
- AUTOHEAL_START_PERIOD=30
- WEBHOOK_URL=
image: willfarrell/autoheal:latest
restart: always
- WEBHOOK_URL=an optional webhook to report restarts
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock
nginx-proxy:
container_name: nginx-proxy
image: nginxproxy/nginx-proxy
ports:
- "${HTTPPORT}:80"
- "${HTTPSPORT}:443"
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs
Expand All @@ -51,15 +54,16 @@ services:
nginx-proxy-acme:
container_name: nginx-proxy-acme
image: nginxproxy/acme-companion
environment:
- [email protected] - replace with the admin/maintainer
- NGINX_PROXY_CONTAINER=nginx-proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./acme:/etc/acme.sh
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs
- ./vhost:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
environment:
- "DEFAULT_EMAIL=${EMAIL}"
- NGINX_PROXY_CONTAINER=nginx-proxy
depends_on:
- "nginx-proxy"

32 changes: 18 additions & 14 deletions docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,38 @@ services:
web-verifier-plus:
container_name: web-verifier-plus
build: .
healthcheck:
test: ["CMD", "node", "healthcheck.mjs"]
interval: 120s
retries: 3
start_period: 30s
timeout: 80s
environment:
- HEALTH_CHECK_SMTP_HOST=
- HEALTH_CHECK_SMTP_HOST=add your email host, like smtp.sendgrid.net
- HEALTH_CHECK_SMTP_USER=
- HEALTH_CHECK_SMTP_PASS=
- HEALTH_CHECK_EMAIL_FROM=Digital Credentials Consortium Demo Issuer <[email protected]>
- HEALTH_CHECK_EMAIL_RECIPIENT=
- HEALTH_CHECK_EMAIL_RECIPIENT=the email addresss of whoever should receive unhealthy notications
- HEALTH_CHECK_EMAIL_SUBJECT="DCC Dashboard Issuer Coordinator Microservice Healthcheck"
- HEALTH_CHECK_WEB_HOOK=
- HEALTH_CHECK_SERVICE_URL=http://localhost:3000/api/healthz
- HEALTH_CHECK_WEB_HOOK=a webhook like those of Slack
- HEALTH_CHECK_SERVICE_URL=http://localhost:3000/api/healthz - the healthz endpoint
- HEALTH_CHECK_SERVICE_NAME=VERIFIER-PLUS
- DB_USER=your mongo user
- DB_PASS=and mongo password
- DB_HOST=and mongo host
healthcheck:
test: ["CMD", "node", "healthcheck.mjs"]
interval: 30m
retries: 3
start_period: 30s
timeout: 80s
ports:
- "3000:3000"
labels:
autoheal: true
autoheal:
image: willfarrell/autoheal:latest
restart: always
environment:
- AUTOHEAL_INTERVAL=60
- AUTOHEAL_START_PERIOD=30
- WEBHOOK_URL=
image: willfarrell/autoheal:latest
restart: always
- WEBHOOK_URL=an optional webhook to report restarts
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock



0 comments on commit c013e57

Please sign in to comment.