Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Application Docker Support #20

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,28 @@ The app consists of two parts: a web frontend for viewing stored mail and a SMTP

2. Install dependencies:
```sh
docker-compose run --rm --no-deps app npm install
docker-compose run --rm --no-deps pleasenospam-app npm install
```

3. Start RethinkDB:
```sh
docker-compose up -d db
docker-compose up -d pleasenospam-db
```

4. Start the mail server:
```sh
docker-compose up -d mail
docker-compose up -d pleasenospam-mail-server
```

5. Start the frontend and watch for code changes:
```sh
docker-compose run app npm run watch
docker-compose run pleasenospam-app npm run watch
```

## Deployment
1. Follow the first two development steps.
1. Configure `docker-compose.yml` with Docker options and ports to use

2. Configure `config/docker.json` with any custom setting overrides

3. Configure `docker-compose.yml` with Docker options and ports to use

4. Start the frontend, database and mail server:
2. Start the frontend, database and mail server:
```sh
docker-compose up
docker-compose up --build
```
18 changes: 18 additions & 0 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:11.6.0-alpine

WORKDIR /usr/src/app

COPY package*.json /usr/src/app/
COPY config /usr/src/app/config/
COPY lib /usr/src/app/lib/
COPY controllers /usr/src/app/controllers/
COPY public /usr/src/app/public/
COPY models /usr/src/app/models/
COPY views /usr/src/app/views/
COPY app.js db.js router.js server.js /usr/src/app/

RUN cd /usr/src/app && npm install --only=production

EXPOSE 80

CMD [ "npm", "start" ]
24 changes: 24 additions & 0 deletions config/docker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var defer = require('config/defer').deferConfig;

module.exports = {
"app": {
"port": process.env.PLEASE_NO_SPAM_APP_PORT || 80,
"mail": {
"host": process.env.DOCKER_MAIL_HOST_NAME || "pleasenospam-mail-server",
"port": process.env.DOCKER_MAIL_HOST_PORT || 25
}
},
"db": {
"host": process.env.PLEASE_NO_SPAM_DOCKER_DB_NAME || "pleasenospam-db",
"port": process.env.PLEASE_NO_SPAM_DOCKER_DB_PORT || 28015
},
"mail": {
"hostname": process.env.PLEASE_NO_SPAM_MAIL_HOST_NAME || "pleasenospam-mail-server",
"banner": process.env.PLEASE_NO_SPAM_MAIL_BANNER || "Hi can I have some mail please?",
"domains": defer(function () {
var domains = process.env.NO_SPAM_MAIL_DOMAINS.replace(/^"(.+(?="$))"$/, '$1').split(' ');
console.log(domains);
return domains;
})
}
}
18 changes: 0 additions & 18 deletions config/docker.json

This file was deleted.

56 changes: 30 additions & 26 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
version: '2'
version: '3'
services:
app:
image: node:latest
command: "npm start"
working_dir: /app
links:
- mail
- db
pleasenospam-app:
image: joebiellik/pleasenospam:1.0.0-app
restart: always
container_name: pleasenospam-app
build:
context: ./
dockerfile: ./app/Dockerfile
depends_on:
- pleasenospam-mail-server
- pleasenospam-db
environment:
- NODE_ENV=docker
volumes:
- .:/app
- NO_SPAM_MAIL_DOMAINS="pleasenospam.email spamlessmail.org"
ports:
- "3000:80"
mail:
image: node:latest
command: "npm run mail-server"
working_dir: /app
links:
- db
pleasenospam-mail-server:
image: joebiellik/pleasenospam:1.0.0-mail-server
restart: always
container_name: pleasenospam-mail-server
build:
context: ./
dockerfile: ./mail-server/Dockerfile
depends_on:
- pleasenospam-db
environment:
- NODE_ENV=docker
volumes:
- .:/app
- PLEASE_NO_SPAM_MAIL_HOST_NAME="pleasenospam.email"
- NO_SPAM_MAIL_DOMAINS="pleasenospam.email spamlessmail.org"
expose:
- 25
ports:
- "2525:25"
db:
pleasenospam-db:
image: rethinkdb:latest
restart: always
container_name: pleasenospam-db
volumes:
- ./db:/data
expose:
- 28015
ports:
- "8080:8080"
- "28015:28015"
- "28016:28016"
- pleasenospam-db:/data

volumes:
pleasenospam-db:
15 changes: 15 additions & 0 deletions mail-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:11.6.0-alpine

WORKDIR /usr/src/app

COPY package*.json /usr/src/app/
COPY config /usr/src/app/config/
COPY lib /usr/src/app/lib/
COPY models /usr/src/app/models/
COPY mail-server.js db.js /usr/src/app/

RUN cd /usr/src/app && npm install --only=production

EXPOSE 25

CMD [ "npm", "run", "mail-server" ]