From 11cc25b63819b68547f6d9b1df1219d36f78682d Mon Sep 17 00:00:00 2001 From: Valeriy Date: Thu, 7 Feb 2019 01:36:33 +0300 Subject: [PATCH] fix(tools): use docker for development --- client/gatsby-config.js | 8 +++- docker-compose.yml | 100 ++++++++++++++++++++++++++++------------ 2 files changed, 77 insertions(+), 31 deletions(-) diff --git a/client/gatsby-config.js b/client/gatsby-config.js index 571da899f3..f1bcd6b55d 100644 --- a/client/gatsby-config.js +++ b/client/gatsby-config.js @@ -6,7 +6,11 @@ const { localeChallengesRootDir } = require('./utils/buildChallenges'); -const { NODE_ENV: env, LOCALE: locale = 'english' } = process.env; +const { + NODE_ENV: env, + LOCALE: locale = 'english', + API_PROXY: proxyUrl = 'http://localhost:3000' +} = process.env; const selectedGuideDir = `../${ env === 'production' ? 'guide' : 'mock-guide' @@ -21,7 +25,7 @@ module.exports = { }, proxy: { prefix: '/internal', - url: 'http://localhost:3000' + url: proxyUrl }, plugins: [ 'gatsby-plugin-react-helmet', diff --git a/docker-compose.yml b/docker-compose.yml index 8d7465de61..e090d2c0b4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,37 +1,79 @@ # Docker Compose file for FreeCodeCamp # +# if using Docker Toolbox, replace `localhost` to output form `docker-machine ip` +# # Bootstrap with: -# docker-compose run --rm freecodecamp npm install -# docker-compose run --rm freecodecamp npm run only-once +# docker-compose run --rm freecodecamp bash +# npm install --unsafe-perm +# npm run seed +# exit +# +# if during install you see errors like `ETXTBSY: text file is busy, rename` +# then before install downgrade npm with command: +# npm install -g npm@5.7.1 # # Run with: # docker-compose up # -version: "3" +version: '3' services: - freecodecamp: - image: node:8.10 - depends_on: - - db - - mailhog - environment: - - MAILHOG_HOST=mailhog - - MONGOHQ_URL=mongodb://db:27017/freecodecamp - volumes: - - ./api-server:/app - working_dir: /app - command: - - npm - - run - - develop - ports: - - "3000:3000" - db: - image: mongo:3.6 - ports: - - "27017:27017" - mailhog: - image: mailhog/mailhog - ports: - - "1025:1025" - - "8025:8025" + freecodecamp: + image: node:lts + depends_on: + - db + - mailhog + environment: + - MAILHOG_HOST=mailhog + - MONGOHQ_URL=mongodb://db:27017/freecodecamp + volumes: + - .:/app + working_dir: /app + client: + image: node:lts + environment: + - API_PROXY=http://api-server:3000 + - GATSBY_WEBPACK_PUBLICPATH=http://localhost:8000/ + - HOME_LOCATION=http://localhost:8000 + - API_LOCATION=http://localhost:3000 + volumes: + - .:/app + working_dir: /app/client + command: + - npm + - run + - develop + - -- + - -H + - '0.0.0.0' + ports: + - '8000:8000' + - '9228:9228' + api-server: + image: node:lts + depends_on: + - db + - mailhog + environment: + - MAILHOG_HOST=mailhog + - MONGOHQ_URL=mongodb://db:27017/freecodecamp + - COOKIE_DOMAIN=localhost + - HOME_LOCATION=http://localhost:8000 + - API_LOCATION=http://localhost:3000 + volumes: + - .:/app + working_dir: /app/api-server + command: + - node + - development-entry.js + ports: + - '3000:3000' + - '9229:9229' + db: + image: mongo:3.6 + ports: + - '27017:27017' + mailhog: + image: mailhog/mailhog + ports: + - '1025:1025' + - '8025:8025'