Skip to content
Permalink
Browse files

chore(tools): use data volumes for node_modules

  • Loading branch information...
ValeraS authored and raisedadead committed Feb 25, 2019
1 parent aa63057 commit 76ec4acb6e980549d202fa1194254afaa0f2049b
Showing with 71 additions and 17 deletions.
  1. +9 −0 change_volumes_owner.sh
  2. +22 −3 docker-compose.tests.yml
  3. +34 −9 docker-compose.yml
  4. +6 −5 package.json
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

chown node:staff node_modules
chown node:staff api-server/node_modules
chown node:staff client/node_modules
chown node:staff client/plugins/fcc-create-nav-data/node_modules
chown node:staff curriculum/node_modules
chown node:staff tools/challenge-md-parser/node_modules
chown node:staff tools/scripts/seed/node_modules
@@ -1,8 +1,11 @@
# Docker Compose file for FreeCodeCamp
# Docker Compose file for FreeCodeCamp tests
#
# Before run tests, bootstrap project with commands from a docker-compose.yml
#
# Note, first run takes a long time.
# Bootstrap with:
# npm run docker:test:init
#
# Note, bootstrap takes a long time.
#
# Run with:
# npm run docker:test -- -c "npm run test"
@@ -12,7 +15,7 @@
# npm run docker:test -- -c "npm run test:server"
#
# If need to test one challenge:
# npm run docker:test -- -c "cd curriculum && npm run test -f 'Title of Challenge'"
# npm run docker:test -- -c "cd curriculum && npm run test -- -f 'Title of Challenge'"
#
version: '3'
services:
@@ -22,4 +25,20 @@ services:
dockerfile: Dockerfile.tests
volumes:
- .:/app
- node_modules:/app/node_modules
- client_node_modules:/app/client/node_modules
- server_node_modules:/app/api-server/node_modules
- curriculum_node_modules:/app/curriculum/node_modules
- challenge_md_parser_node_modules:/app/tools/challenge-md-parser/node_modules
- seed_node_modules:/app/tools/scripts/seed/node_modules
- client_plugin_nav_data_node_modules:/app/client/plugins/fcc-create-nav-data/node_modules
working_dir: /app

volumes:
node_modules:
client_node_modules:
server_node_modules:
curriculum_node_modules:
challenge_md_parser_node_modules:
seed_node_modules:
client_plugin_nav_data_node_modules:
@@ -3,20 +3,17 @@
# If using Docker Toolbox, set `DOCKER_HOST_LOCATION` env var to output from
# `docker-machine ip`
#
# If you have previously run freeCodeCamp outside of docker, run
# npm run clean
# and select 'yes' to remove all node_module folders
# before trying to bootstrap the project
#
# Bootstrap with:
# npm run docker:init
# npm run docker:install
# npm run docker:seed
#
# if during install you see errors like `ETXTBSY: text file is busy, rename`
# then use npm run docker:install2
#
# Run with:
# npm run docker:develop
# npm run docker:develop
#
# If plan to make a contribution to the project then install root node_modules
# with:
# npm install --ignore-scripts
#
version: '3'
services:
@@ -31,6 +28,13 @@ services:
- MONGOHQ_URL=mongodb://db:27017/freecodecamp
volumes:
- .:/app
- node_modules:/app/node_modules
- client_node_modules:/app/client/node_modules
- server_node_modules:/app/api-server/node_modules
- curriculum_node_modules:/app/curriculum/node_modules
- challenge_md_parser_node_modules:/app/tools/challenge-md-parser/node_modules
- seed_node_modules:/app/tools/scripts/seed/node_modules
- client_plugin_nav_data_node_modules:/app/client/plugins/fcc-create-nav-data/node_modules
working_dir: /app
client:
image: node:lts
@@ -42,6 +46,13 @@ services:
- API_LOCATION=http://$DOCKER_HOST_LOCATION:3000
volumes:
- .:/app
- node_modules:/app/node_modules
- client_node_modules:/app/client/node_modules
- server_node_modules:/app/api-server/node_modules
- curriculum_node_modules:/app/curriculum/node_modules
- challenge_md_parser_node_modules:/app/tools/challenge-md-parser/node_modules
- seed_node_modules:/app/tools/scripts/seed/node_modules
- client_plugin_nav_data_node_modules:/app/client/plugins/fcc-create-nav-data/node_modules
working_dir: /app/client
command: npm run develop -- -H '0.0.0.0'
ports:
@@ -61,6 +72,13 @@ services:
- API_LOCATION=http://$DOCKER_HOST_LOCATION:3000
volumes:
- .:/app
- node_modules:/app/node_modules
- client_node_modules:/app/client/node_modules
- server_node_modules:/app/api-server/node_modules
- curriculum_node_modules:/app/curriculum/node_modules
- challenge_md_parser_node_modules:/app/tools/challenge-md-parser/node_modules
- seed_node_modules:/app/tools/scripts/seed/node_modules
- client_plugin_nav_data_node_modules:/app/client/plugins/fcc-create-nav-data/node_modules
working_dir: /app/api-server
command: node development-entry.js
ports:
@@ -80,3 +98,10 @@ services:

volumes:
dbdata:
node_modules:
client_node_modules:
server_node_modules:
curriculum_node_modules:
challenge_md_parser_node_modules:
seed_node_modules:
client_plugin_nav_data_node_modules:
@@ -7,12 +7,13 @@
"develop": "npm-run-all ensure-env -p develop:*",
"develop:client": "cd ./client && npm run develop",
"develop:server": "cd ./api-server && node development-entry.js",
"docker:bash": "docker-compose run --rm freecodecamp bash",
"docker:develop": "docker-compose up",
"docker:install": "npm run docker:bash -- -c \"npm install\"",
"docker:install2": "docker-compose run --rm -u root freecodecamp bash -c \"npm install -g npm@5.7.1 && su node -c 'npm install'\"",
"docker:seed": "npm run docker:bash -- -c \"npm run seed\"",
"docker:clean": "docker-compose run -u root --rm freecodecamp bash -c \"rm -rf **/node_modules/* **/node_modules/..?* **/node_modules/.[!.]* node_modules/* node_modules/..?* node_modules/.[!.]*\"",
"docker:develop": "docker-compose up client api-server",
"docker:init": "docker-compose run -u root --rm freecodecamp bash change_volumes_owner.sh && docker-compose run -u root --rm client bash -c \"cd .. && bash change_volumes_owner.sh\" && docker-compose run -u root --rm api-server bash -c \"cd .. && bash change_volumes_owner.sh\"",
"docker:install": "docker-compose run --rm freecodecamp npm install",
"docker:seed": "docker-compose run --rm freecodecamp npm run seed",
"docker:test": "docker-compose -f docker-compose.tests.yml run --rm tests bash",
"docker:test:init": "docker-compose -f docker-compose.tests.yml run -u root --rm tests bash change_volumes_owner.sh",
"ensure-env": "cross-env DEBUG=fcc:* node ./tools/scripts/ensure-env.js",
"format": "npm run lint -- --fix",
"hooks:install": "node node_modules/husky/husky.js install",

0 comments on commit 76ec4ac

Please sign in to comment.
You can’t perform that action at this time.