Skip to content

Commit

Permalink
feat: add nginx based docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
jainpawan21 committed May 5, 2024
1 parent fb347b8 commit 5a3aff4
Show file tree
Hide file tree
Showing 2 changed files with 313 additions and 0 deletions.
68 changes: 68 additions & 0 deletions docker/local/deployment/nginx-based/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Secrets
# YOU MUST CHANGE THESE BEFORE GOING INTO PRODUCTION
# used as a secret to verify the JWT token signature
JWT_SECRET='your-secret'
# used to encrypt/decrypt the provider credentials
STORE_ENCRYPTION_KEY='<ENCRYPTION_KEY_MUST_BE_32_LONG>'


# General
# available values 'dev', 'test', 'production', 'ci', 'local'
NODE_ENV=production

# MongoDB
MONGO_MAX_POOL_SIZE=500
MONGO_MIN_POOL_SIZE=100
MONGO_INITDB_ROOT_USERNAME=novu-selfhost

Check warning on line 16 in docker/local/deployment/nginx-based/.env.example

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (selfhost)
MONGO_INITDB_ROOT_PASSWORD=qwertyuiop

Check warning on line 17 in docker/local/deployment/nginx-based/.env.example

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (qwertyuiop)
MONGO_URL=mongodb://novu-selfhost:qwertyuiop@mongodb:27017/novu-db?authSource=admin

Check warning on line 18 in docker/local/deployment/nginx-based/.env.example

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (selfhost)

Check warning on line 18 in docker/local/deployment/nginx-based/.env.example

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (qwertyuiop)

# REDIS
REDIS_HOST=redis
REDIS_PASSWORD=
REDIS_CACHE_SERVICE_HOST=

# AWS S3
S3_LOCAL_STACK=http://s3.eu-east-1.amazonaws.com
S3_BUCKET_NAME=novu-local
S3_REGION=us-east-1
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test

# Ports
API_PORT=3000
REDIS_PORT=6379
REDIS_CACHE_SERVICE_PORT=6379
WS_PORT=3002
WEB_PORT=4200
EMBED_PORT=4701
WIDGET_PORT=4500

# Hosts
REACT_APP_WS_HOST=ws.novu.domain.com
API_ROOT_HOST=api.novu.domain.com
FRONT_BASE_HOST=novu.domain.com
EMBED_HOST=embed.novu.domain.com
WIDGET_HOST=widget.novu.domain.com

# URLs
REACT_APP_WS_URL=https://$REACT_APP_WS_HOST
# Uncomment this one when deploying Novu in the local environment
# as Web app local Dockerfile will have to load this to be used.
# Deployment version doesn't need as we inject it with API_ROOT_URL value.
# REACT_APP_API_URL=http://localhost:3000
API_ROOT_URL=https://$API_ROOT_HOST
FRONT_BASE_URL=https://$FRONT_BASE_HOST
WIDGET_EMBED_PATH=https://$EMBED_HOST/embed.umd.min.js
EMBED_URL=https://$EMBED_HOST
WIDGET_URL=https://$WIDGET_HOST

# Analytics
SENTRY_DSN=
# change these values
NEW_RELIC_APP_NAME=
NEW_RELIC_LICENSE_KEY=

# Others
LETSENCRYPT_EMAIL=[email protected]

Check warning on line 67 in docker/local/deployment/nginx-based/.env.example

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (LETSENCRYPT)
DISABLE_USER_REGISTRATION=false
245 changes: 245 additions & 0 deletions docker/local/deployment/nginx-based/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
version: '3.9'
services:
redis:
image: 'redis:alpine'
container_name: redis
restart: unless-stopped
logging:
driver: 'none'

mongodb:
image: mongo
container_name: mongodb
logging:
driver: 'json-file'
options:
max-size: '50m'
max-file: '5'
environment:
- PUID=1000
- PGID=1000
- MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
volumes:
- mongodb:/data/db
ports:
- 27017:27017
restart: unless-stopped

api:
image: 'ghcr.io/novuhq/novu/api:latest'
depends_on:
- mongodb
- redis
- nginx-proxy
- nginx-proxy-acme
container_name: api
restart: unless-stopped
logging:
driver: 'json-file'
options:
max-size: '50m'
max-file: '5'
expose:
- "${API_PORT}"
environment:
VIRTUAL_HOST: ${API_ROOT_HOST}
VIRTUAL_PORT: ${API_PORT}
LETSENCRYPT_HOST: ${API_ROOT_HOST}

Check warning on line 48 in docker/local/deployment/nginx-based/docker-compose.yml

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (LETSENCRYPT)
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}

Check warning on line 49 in docker/local/deployment/nginx-based/docker-compose.yml

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (LETSENCRYPT)

Check warning on line 49 in docker/local/deployment/nginx-based/docker-compose.yml

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (LETSENCRYPT)
NODE_ENV: ${NODE_ENV}
API_ROOT_URL: ${API_ROOT_URL}
DISABLE_USER_REGISTRATION: ${DISABLE_USER_REGISTRATION}
PORT: ${API_PORT}
FRONT_BASE_URL: ${FRONT_BASE_URL}
MONGO_URL: ${MONGO_URL}
MONGO_MIN_POOL_SIZE: ${MONGO_MIN_POOL_SIZE}
MONGO_MAX_POOL_SIZE: ${MONGO_MAX_POOL_SIZE}
REDIS_HOST: ${REDIS_HOST}
REDIS_PORT: ${REDIS_PORT}
REDIS_DB_INDEX: 2
REDIS_CACHE_SERVICE_HOST: ${REDIS_CACHE_SERVICE_HOST}
REDIS_CACHE_SERVICE_PORT: ${REDIS_CACHE_SERVICE_PORT}
S3_LOCAL_STACK: ${S3_LOCAL_STACK}
S3_BUCKET_NAME: ${S3_BUCKET_NAME}
S3_REGION: ${S3_REGION}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
JWT_SECRET: ${JWT_SECRET}
STORE_ENCRYPTION_KEY: ${STORE_ENCRYPTION_KEY}
SENTRY_DSN: ${SENTRY_DSN}
NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME}
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY}

worker:
image: 'ghcr.io/novuhq/novu/worker:latest'
depends_on:
- mongodb
- redis
container_name: worker
restart: unless-stopped
logging:
driver: 'json-file'
options:
max-size: '50m'
max-file: '5'
environment:
NODE_ENV: ${NODE_ENV}
MONGO_URL: ${MONGO_URL}
MONGO_MIN_POOL_SIZE: ${MONGO_MIN_POOL_SIZE}
MONGO_MAX_POOL_SIZE: ${MONGO_MAX_POOL_SIZE}
REDIS_HOST: ${REDIS_HOST}
REDIS_PORT: ${REDIS_PORT}
REDIS_DB_INDEX: 2
REDIS_CACHE_SERVICE_HOST: ${REDIS_CACHE_SERVICE_HOST}
REDIS_CACHE_SERVICE_PORT: ${REDIS_CACHE_SERVICE_PORT}
S3_LOCAL_STACK: ${S3_LOCAL_STACK}
S3_BUCKET_NAME: ${S3_BUCKET_NAME}
S3_REGION: ${S3_REGION}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
STORE_ENCRYPTION_KEY: ${STORE_ENCRYPTION_KEY}
SENTRY_DSN: ${SENTRY_DSN}
NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME}
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY}

ws:
image: 'ghcr.io/novuhq/novu/ws:latest'
depends_on:
- mongodb
- redis
- nginx-proxy
- nginx-proxy-acme
container_name: ws
restart: unless-stopped
logging:
driver: 'json-file'
options:
max-size: '50m'
max-file: '5'
expose:
- "${WS_PORT}"
environment:
VIRTUAL_HOST: ${REACT_APP_WS_HOST}
VIRTUAL_PORT: ${WS_PORT}
LETSENCRYPT_HOST: ${REACT_APP_WS_HOST}

Check warning on line 125 in docker/local/deployment/nginx-based/docker-compose.yml

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (LETSENCRYPT)
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}

Check warning on line 126 in docker/local/deployment/nginx-based/docker-compose.yml

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (LETSENCRYPT)
PORT: ${WS_PORT}
NODE_ENV: ${NODE_ENV}
MONGO_URL: ${MONGO_URL}
MONGO_MIN_POOL_SIZE: ${MONGO_MIN_POOL_SIZE}
MONGO_MAX_POOL_SIZE: ${MONGO_MAX_POOL_SIZE}
REDIS_HOST: ${REDIS_HOST}
REDIS_PORT: ${REDIS_PORT}
JWT_SECRET: ${JWT_SECRET}

web:
image: 'ghcr.io/novuhq/novu/web:latest'
depends_on:
- api
- worker
- nginx-proxy
- nginx-proxy-acme
container_name: web
restart: unless-stopped
logging:
driver: 'json-file'
options:
max-size: '50m'
max-file: '5'
expose:
- "${WEB_PORT}"
environment:
VIRTUAL_HOST: ${FRONT_BASE_HOST}
VIRTUAL_PORT: ${WEB_PORT}
LETSENCRYPT_HOST: ${FRONT_BASE_HOST}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
REACT_APP_API_URL: ${API_ROOT_URL}
REACT_APP_ENVIRONMENT: ${NODE_ENV}
REACT_APP_WIDGET_EMBED_PATH: ${WIDGET_EMBED_PATH}
REACT_APP_DOCKER_HOSTED_ENV: 'true'
REACT_APP_WS_URL: ${REACT_APP_WS_URL}

widget:
image: 'ghcr.io/novuhq/novu/widget:latest'
depends_on:
- api
- worker
- web
- nginx-proxy
- nginx-proxy-acme
container_name: widget
restart: unless-stopped
logging:
driver: 'json-file'
options:
max-size: '50m'
max-file: '5'
expose:
- "${WIDGET_PORT}"
environment:
VIRTUAL_HOST: ${WIDGET_HOST}
VIRTUAL_PORT: ${WIDGET_PORT}
LETSENCRYPT_HOST: ${WIDGET_HOST}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
REACT_APP_API_URL: ${API_ROOT_URL}
REACT_APP_WS_URL: ${REACT_APP_WS_URL}
REACT_APP_ENVIRONMENT: ${NODE_ENV}

embed:
depends_on:
- widget
- nginx-proxy
- nginx-proxy-acme
image: 'ghcr.io/novuhq/novu/embed:latest'
container_name: embed
restart: unless-stopped
logging:
driver: 'json-file'
options:
max-size: '50m'
max-file: '5'
expose:
- "{EMBED_PORT}"
environment:
VIRTUAL_HOST: ${EMBED_HOST}
VIRTUAL_PORT: ${EMBED_PORT}
LETSENCRYPT_HOST: ${EMBED_HOST}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
WIDGET_URL: ${WIDGET_URL}

nginx-proxy:
image: nginxproxy/nginx-proxy
container_name: nginx-proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- certs:/etc/nginx/certs
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro

nginx-proxy-acme:
image: nginxproxy/acme-companion
container_name: nginx-proxy-acme
restart: always
volumes_from:
- nginx-proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- acme:/etc/acme.sh
environment:
- DEFAULT_EMAIL=${LETSENCRYPT_EMAIL}
- NGINX_PROXY_CONTAINER=nginx-proxy
depends_on:
- nginx-proxy


volumes:
mongodb:
certs:
vhost:
html:
acme:

0 comments on commit 5a3aff4

Please sign in to comment.