feat: Allows sharing of network (#16937)

build(docker): Expose mailhog port.

build(Docker): Improve wording.

build(docker): Mailhog and network changes.

    * Add mailhog container to shared network to enable connectivity
    * Configure project name for docker compose in .env sample file,
        without it the basename of the repo directory is used, which
        makes it unreachable for other services
    * Set mailhog host to mailhog (instead of localhost) if MAILHOG_HOST
      env var is set
    * Expose 1025 to enable local troubleshooting

build(docker): Update README to reflect compose changes.
pull/16987/head
Otto Jongerius 2018-03-30 16:51:09 +13:00 committed by mrugesh mohapatra
parent 1d9eca3700
commit ef37c3bee2
7 changed files with 75 additions and 45 deletions

2
.gitignore vendored
View File

@ -56,5 +56,3 @@ public/css/main*
webpack-bundle-stats.html
server/rev-manifest.json
google-credentials.json
docker-compose.yml

View File

@ -288,26 +288,30 @@ node seed
npm run develop
```
### Setup freeCodeCamp via Docker
### Setup freeCodeCamp using Docker
#### Isolated
Use this if you just want to work on freeCodeCamp.
You need to have [docker](https://docs.docker.com/install/) and [docker-compose](https://docs.docker.com/compose/install/) installed before executing commands below.
You will need to have [docker](https://docs.docker.com/install/) and [docker-compose](https://docs.docker.com/compose/install/) installed before executing the commands below.
Create docker-compose.yml from sample file
Setup:
```bash
cp sample.docker-compose.yml docker-compose.yml
docker-compose run --rm freecodecamp npm install
docker-compose run --rm freecodecamp npm run only-once
```
Setup and run project:
Run:
```bash
# Setup project
docker-compose run --rm node npm install
docker-compose run --rm node npm run only-once
```
```bash
# Run project
docker-compose up
```
#### Shared
Use this if you want to work on other services that will run alongside
of freeCodeCamp, using the database directly. An example is the [open-api](https://github.com/freeCodeCamp/open-api) project.
```bash
docker-compose -f docker-compose.yml -f docker-compose-shared.yml up
```
### Make Changes

20
docker-compose-shared.yml Executable file
View File

@ -0,0 +1,20 @@
# Docker Compose over ride file for FreeCodeCamp
#
# Run with:
# docker-compose -f docker-compose.yml -f docker-compose-shared.yml up
#
version: "3"
services:
db:
networks:
- shared
mailhog:
networks:
- shared
freecodecamp:
networks:
- shared
networks: # Used by by other projects like open-api
shared:
driver: bridge

37
docker-compose.yml Normal file
View File

@ -0,0 +1,37 @@
# Docker Compose file for FreeCodeCamp
#
# Bootstrap with:
# docker-compose run --rm server npm install
# docker-compose run --rm server npm run only-once
#
# Run with:
# docker-compose up
#
version: "3"
services:
freecodecamp:
image: node:8.9.4
depends_on:
- db
- mailhog
environment:
- MAILHOG_HOST=mailhog
- MONGOHQ_URL=mongodb://db:27017/freecodecamp
volumes:
- .:/app
working_dir: /app
command:
- npm
- run
- develop
ports:
- "3000:3000"
db:
image: mongo:3.2.6
ports:
- "27017:27017"
mailhog:
image: mailhog/mailhog
ports:
- "1025:1025"
- "8025:8025"

View File

@ -1,31 +0,0 @@
# Docker Compose sample file for freeCodeCamp
# Copy this file to docker-compose.yml
#
# Bootstrap with:
# docker-compose run --rm node npm install
# docker-compose run --rm node npm run only-once
#
# Run with:
# docker-compose up
#
version: "3"
services:
node:
image: node:8.9.4
volumes:
- .:/app
working_dir: /app
depends_on:
- mongo
ports:
- "3000:3000"
- "3002:3002"
environment:
- MONGOHQ_URL=mongodb://mongo:27017/freecodecamp
command: npm run develop
mongo:
image: mongo:3.0.15
mailhog:
image: mailhog/mailhog

View File

@ -1,3 +1,4 @@
COMPOSE_PROJECT_NAME=freecodecamp
MONGOHQ_URL='mongodb://localhost:27017/freecodecamp'
OPBEAT_FRONTEND_ORG_ID=stuff

View File

@ -10,7 +10,7 @@ if (!process.env.SES_ID) {
connector: 'mail',
transport: {
type: 'smtp',
host: 'localhost',
host: process.env.MAILHOG_HOST || 'localhost',
secure: false,
port: 1025,
tls: {
@ -26,4 +26,5 @@ if (!process.env.SES_ID) {
} else {
debug('using AWS SES to deliver emails');
}
module.exports = ds;