Skip to content

Commit

Permalink
feat: Allows sharing of network (freeCodeCamp#16937)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ojongerius authored and raisedadead committed Mar 30, 2018
1 parent 1d9eca3 commit ef37c3b
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 45 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,3 @@ public/css/main*
webpack-bundle-stats.html
server/rev-manifest.json
google-credentials.json

docker-compose.yml
26 changes: 15 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions docker-compose-shared.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 37 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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"
31 changes: 0 additions & 31 deletions sample.docker-compose.yml

This file was deleted.

1 change: 1 addition & 0 deletions sample.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
COMPOSE_PROJECT_NAME=freecodecamp
MONGOHQ_URL='mongodb://localhost:27017/freecodecamp'

OPBEAT_FRONTEND_ORG_ID=stuff
Expand Down
3 changes: 2 additions & 1 deletion server/datasources.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -26,4 +26,5 @@ if (!process.env.SES_ID) {
} else {
debug('using AWS SES to deliver emails');
}

module.exports = ds;

0 comments on commit ef37c3b

Please sign in to comment.