From 4f1fdfdd1461e3a590cc808855926b57e1d9cb2f Mon Sep 17 00:00:00 2001 From: Valeriy Date: Sun, 28 Apr 2019 21:04:22 +0300 Subject: [PATCH] chore(tools): update docker setup to use npm ci --- client/package.json | 2 +- docker-compose.yml | 4 +-- ...setup-freecodecamp-locally-using-docker.md | 26 ++----------------- libcimp_index_js.patch | 13 ++++++++++ package.json | 2 +- patch_npm_and_install.sh | 4 +++ 6 files changed, 23 insertions(+), 28 deletions(-) create mode 100644 libcimp_index_js.patch create mode 100644 patch_npm_and_install.sh diff --git a/client/package.json b/client/package.json index bde79aae5be..e075eccf962 100644 --- a/client/package.json +++ b/client/package.json @@ -75,7 +75,7 @@ "build": "node --max_old_space_size=7168 node_modules/gatsby-cli build", "build:workers": "node --max_old_space_size=7168 node_modules/webpack-cli --env.production --config ./webpack-workers.js --progress", "predevelop": "npm run prebuild", - "develop": "gatsby develop", + "develop": "node --inspect=0.0.0.0:9228 node_modules/gatsby-cli develop", "format:gatsby": "prettier-eslint --write --trailing-comma none --single-quote './gatsby-*.js'", "format:src": "prettier-eslint --write --trailing-comma none --single-quote './src/**/*.js'", "format:utils": "prettier-eslint --write --trailing-comma none --single-quote './utils/**/*.js'", diff --git a/docker-compose.yml b/docker-compose.yml index b180faf55ac..8003aa120c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ # # If plan to make a contribution to the project then install root node_modules # with: -# npm install --ignore-scripts +# npm ci --ignore-scripts # version: '3' services: @@ -87,7 +87,7 @@ services: db: image: mongo:3.6 ports: - - '27017:27017' + - '27016:27017' volumes: - dbdata:/data/db mailhog: diff --git a/docs/how-to-setup-freecodecamp-locally-using-docker.md b/docs/how-to-setup-freecodecamp-locally-using-docker.md index 3d1fcbc477f..171904aa2ec 100644 --- a/docs/how-to-setup-freecodecamp-locally-using-docker.md +++ b/docs/how-to-setup-freecodecamp-locally-using-docker.md @@ -176,7 +176,7 @@ Each of the above commands will take a little time to complete and you should wa Next you need to install a few npm packages outside of docker. You can skip this step if you are only running the app locally and will not use git. ```shell -npm install --ignore-scripts +npm ci --ignore-scripts ``` All of the above needs to be run only the first time you set up the local dev environment. @@ -214,7 +214,7 @@ npm run docker:develop Your local setup automatically populates a local user in the database. Clicking the sign in button will automatically authenticate you into the local application. -However, accessing the user portfolio page is a little tricky. In development, Gatsby takes over serving the client side pages and hence you will get a 404 page for the user portfolio when working locally. +However, accessing the user portfolio page is a little tricky. In development, Gatsby takes over serving the client side pages and hence you will get a 404 page for the user portfolio when working locally. Simply clicking the `Preview Custom 404 Page` button will forward you to the correct page. @@ -438,25 +438,3 @@ Follow these steps: If you are stuck, and need help, let us know by asking in the ['Contributors' category on our forum](https://www.freecodecamp.org/forum/c/contributors) or the [Contributors chat room](https://gitter.im/FreeCodeCamp/Contributors) on Gitter. There might be an error in the console of your browser or in Bash / Terminal / Command Line that will help identify the problem. - -### Troubleshooting - -If the app launches but you are encountering errors with the UI itself, for example if fonts are not being loaded or if the code editor is not displaying properly, you may try the following troubleshooting steps at least once: - -```shell -# We use a mono repo and have multiple components (server, client, tools, plugins, etc.) -# Use this command to clean up all dependencies in all of the components -npm run clean - -# Reinstall npm packages -npm install - -# Bootstrap the project -npm run bootstrap - -# Seed the database -npm run seed - -# Restart the application -npm run develop -``` diff --git a/libcimp_index_js.patch b/libcimp_index_js.patch new file mode 100644 index 00000000000..b8f8299cfd8 --- /dev/null +++ b/libcimp_index_js.patch @@ -0,0 +1,13 @@ +diff --git a/index.js b/index.js +index 61bf354..c00dc03 100644 +--- a/index.js ++++ b/index.js +@@ -156,7 +156,7 @@ class Installer { + ) + return BB.join( + this.checkLock(), +- stat && rimraf(path.join(this.prefix, 'node_modules')) ++ stat && rimraf(path.join(this.prefix, 'node_modules/*')) + ) + }).then(() => { + // This needs to happen -after- we've done checkLock() diff --git a/package.json b/package.json index 6a63a04695e..e59c703b066 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "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:install": "docker-compose run -u root --rm freecodecamp bash patch_npm_and_install.sh", "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", diff --git a/patch_npm_and_install.sh b/patch_npm_and_install.sh new file mode 100644 index 00000000000..e32d3d3a2e6 --- /dev/null +++ b/patch_npm_and_install.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +patch /usr/local/lib/node_modules/npm/node_modules/libcipm/index.js < libcimp_index_js.patch +su node -c "npm ci"