diff --git a/.gitignore b/.gitignore index bf4bb5f2a7..c591aad2cc 100644 --- a/.gitignore +++ b/.gitignore @@ -56,5 +56,3 @@ public/css/main* webpack-bundle-stats.html server/rev-manifest.json google-credentials.json - -docker-compose.yml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 988e0ae1de..d38f2a307f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/docker-compose-shared.yml b/docker-compose-shared.yml new file mode 100755 index 0000000000..dfffca2735 --- /dev/null +++ b/docker-compose-shared.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..43d6452dac --- /dev/null +++ b/docker-compose.yml @@ -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" diff --git a/sample.docker-compose.yml b/sample.docker-compose.yml deleted file mode 100644 index bed671423f..0000000000 --- a/sample.docker-compose.yml +++ /dev/null @@ -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 diff --git a/sample.env b/sample.env index 2d4f82a7ad..b2bae1d2ad 100644 --- a/sample.env +++ b/sample.env @@ -1,3 +1,4 @@ +COMPOSE_PROJECT_NAME=freecodecamp MONGOHQ_URL='mongodb://localhost:27017/freecodecamp' OPBEAT_FRONTEND_ORG_ID=stuff diff --git a/server/datasources.development.js b/server/datasources.development.js index 2239ded02c..1c52e784b8 100644 --- a/server/datasources.development.js +++ b/server/datasources.development.js @@ -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;