Skip to content

Commit

Permalink
Merge pull request #43 from duboisp/docker
Browse files Browse the repository at this point in the history
Docker build and docker setup instruction
  • Loading branch information
GormFrank authored May 20, 2020
2 parents 43b07eb + 6209d58 commit 2716a11
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV NODE_ENV=${NODE_ENV}

WORKDIR ./

COPY package*.json .
COPY package*.json ./

RUN npm install -g nodemon
RUN npm install
Expand Down
16 changes: 10 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
version: '3'
version: '3.8'
services:
mongo:
image: mongo:3.6
image: mongo:4.2
container_name: x-notify-mongo
ports:
- target: 27017
published: 27016
protocol: tcp
mode: host
networks:
- x-notify-net
x-notify:
build: ./
ports:
container_name: x-notify
ports:
- "8080:8080"
restart: on-failure
container_name: x-notify
environment:
- MONGODB_URI=mongodb://mongo:27017/test
- NODE_ENV=development
links:
- mongo
depends_on:
- mongo
volumes:
Expand Down
9 changes: 9 additions & 0 deletions docker/first-run-insert-topic-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use subs

db.topics.insertOne( {
_id: "test",
templateId: "<template id available in the template in Notify>",
notifyKey: "<A valid Notify API key>",
confirmURL: "https://canada.ca/en.html",
unsubURL: "https://canada.ca/en.html"
})
11 changes: 11 additions & 0 deletions docker/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Docker exec script

To be ran in a terminal at the root of the project.

## First run

Add a test topic in mongo

```
docker exec -i x-notify-mongo /bin/bash -c mongo < docker/first-run-insert-topic-test.js
```
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Run bash script "load-run.sh" for load testing. More instructions in the file.

`node server.js`

or

`docker-compose up --build`


## Create topic

A topic could be compared to a mailing list.
Expand Down
49 changes: 49 additions & 0 deletions setup.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@

# Setup

## Config setup

Run the following commands under the project root:
```
$ cp .env.example .env
$ vim .env
```

And modify the following variable, if needed
* user - For auth for management task
* password - For auth for management task
* flushAccessCode - For auth to flush alls "Topics" keep in memory
* flushAccessCode2 - For auth to flush alls "Topics" keep in memory
* more for prod - All variable that start with "OUR_NOTIFY" - Those is to notify the dev team
* more for prod - All variable that start with "CDS_NOTIFY" - Those is to let CDS know they need to send a 50k+ emails message
* more for prod - All variable that start with "AWS_" - Those is the S3 upload bucket to save the 50k+ emails list

## Docker

`docker-compose up --build`

### URLs

* Server: http://localhost:8080/
* MongoDB external connector: http://localhost:27016/

### Containers

* x-notify-mongo (Mongo DB instance)
* x-notify (Server)


## First run

You need:

* In mongo: Create at least 1 topic
* See the docker exec command "First run" in [docker readme](docker/readme.md)
* Setup one (1) email confirmation template with Notify (notification.alpha.canada.ca) - That template contains at least the personalisation `(( confirm_link ))`
* Update the topic with the appropriate template ID and notify API key
* You can update by connecting to mongo via port 27016 or via command line in the docker container `x-notify-mongo`
* Example of mongo command: `db.topics.updateOne( { _id: "test" }, { $set: { templateId: "<Notify template id>", notifyKey: "<Your team only notify API key>" } } );`

## Run locally

Require
* MongoDB 4.2.x
* NodeJS

* Create a `.env` and configure MONGODB_URI, user, password
* `npm install`
* `npm run start`
Expand Down

0 comments on commit 2716a11

Please sign in to comment.