diff --git a/.circleci/config.yml b/.circleci/config.yml index e2f7e51dd95..c5506ae1b01 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -219,12 +219,9 @@ jobs: - ${GLOBAL_CACHE_VERSION}-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} - ${GLOBAL_CACHE_VERSION}-node-modules-{{ .Branch }} - ${GLOBAL_CACHE_VERSION}-node-modules-master - - run: - name: Install Reaction CLI - command: sudo npm install -g reaction-cli - run: name: Load App Plugins - command: reaction plugins load + command: node --experimental-modules ./.reaction/scripts/build.mjs - run: name: Run Meteor Integration Tests command: .circleci/tests.sh @@ -292,7 +289,7 @@ jobs: name: Frankfurt command: | .circleci/bin/calibre-deploy.sh ${STAGING_URL} Frankfurt - + dockerfile-lint: <<: *defaults docker: @@ -303,7 +300,7 @@ jobs: docker_layer_caching: true - run: name: Dockerfile Lint - command: | + command: | hadolint Dockerfile snyk-security: @@ -365,7 +362,7 @@ workflows: requires: - deploy-to-ecs-release-branch - test-metrics: - requires: + requires: - deploy-to-ecs-release-branch - eslint: requires: diff --git a/.reaction/run/index.mjs b/.reaction/scripts/appSetup.mjs similarity index 52% rename from .reaction/run/index.mjs rename to .reaction/scripts/appSetup.mjs index 495a813a45e..2a2940e88b7 100644 --- a/.reaction/run/index.mjs +++ b/.reaction/scripts/appSetup.mjs @@ -1,12 +1,9 @@ -// Assumes Node 8.x -import _ from "lodash"; -import childProcess from "child_process"; import Log from "./logger"; import loadPlugins from "./loadPlugins"; import loadStyles from "./loadStyles"; import provisionAssets from "./provisionAssets"; -function run() { +export default function appSetup() { let start, sec, ns; start = process.hrtime(); @@ -26,24 +23,4 @@ function run() { provisionAssets(); [sec, ns] = process.hrtime(start); Log.info(`Provisioning assets took ${sec}s ${ns / 1000000}ms\n`); - - // Whatever debugging-related command line arguments were passed in to - // the first node process, forward them along through meteor - const inspect = process.argv - .filter((arg) => arg.startsWith("--inspect")) - .join(" "); - let cmd = `meteor run --no-lint --no-release-check --raw-logs ${inspect}`; - - Log.info(`Running command: ${cmd}`); - cmd = `REACTION_METEOR_APP_COMMAND_START_TIME=${Date.now()} ${cmd}`; - - try { - childProcess.execSync(cmd, { stdio: "inherit" }); - } catch (err) { - Log.default(err); - Log.error("\nError: App failed to start"); - process.exit(1); - } } - -run(); diff --git a/.reaction/scripts/build.mjs b/.reaction/scripts/build.mjs new file mode 100644 index 00000000000..ccd4d9dba65 --- /dev/null +++ b/.reaction/scripts/build.mjs @@ -0,0 +1,3 @@ +import appSetup from "./appSetup"; + +appSetup(); diff --git a/.reaction/run/fs.mjs b/.reaction/scripts/fs.mjs similarity index 100% rename from .reaction/run/fs.mjs rename to .reaction/scripts/fs.mjs diff --git a/.reaction/run/loadPlugins.mjs b/.reaction/scripts/loadPlugins.mjs similarity index 100% rename from .reaction/run/loadPlugins.mjs rename to .reaction/scripts/loadPlugins.mjs diff --git a/.reaction/run/loadStyles.mjs b/.reaction/scripts/loadStyles.mjs similarity index 100% rename from .reaction/run/loadStyles.mjs rename to .reaction/scripts/loadStyles.mjs diff --git a/.reaction/run/logger.mjs b/.reaction/scripts/logger.mjs similarity index 100% rename from .reaction/run/logger.mjs rename to .reaction/scripts/logger.mjs diff --git a/.reaction/run/provisionAssets.mjs b/.reaction/scripts/provisionAssets.mjs similarity index 100% rename from .reaction/run/provisionAssets.mjs rename to .reaction/scripts/provisionAssets.mjs diff --git a/.reaction/scripts/run.mjs b/.reaction/scripts/run.mjs new file mode 100644 index 00000000000..82ec530ed4f --- /dev/null +++ b/.reaction/scripts/run.mjs @@ -0,0 +1,29 @@ +// Assumes Node 8.x +import _ from "lodash"; +import childProcess from "child_process"; +import Log from "./logger"; +import appSetup from "./appSetup"; + +function run() { + appSetup(); + + // Whatever debugging-related command line arguments were passed in to + // the first node process, forward them along through meteor + const inspect = process.argv + .filter((arg) => arg.startsWith("--inspect")) + .join(" "); + let cmd = `meteor run --no-lint --no-release-check --raw-logs ${inspect}`; + + Log.info(`Running command: ${cmd}`); + cmd = `REACTION_METEOR_APP_COMMAND_START_TIME=${Date.now()} ${cmd}`; + + try { + childProcess.execSync(cmd, { stdio: "inherit" }); + } catch (err) { + Log.default(err); + Log.error("\nError: App failed to start"); + process.exit(1); + } +} + +run(); diff --git a/Dockerfile b/Dockerfile index 1709fa0c42e..9f027f0c4d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,8 +25,7 @@ COPY --chown=node . $APP_SOURCE_DIR ############################################################################## FROM meteor-dev as builder -RUN printf "\\n[-] Running Reaction plugin loader...\\n" \ - && reaction plugins load +RUN node --experimental-modules ./.reaction/scripts/build.mjs RUN printf "\\n[-] Building Meteor application...\\n" \ && meteor build --server-only --architecture os.linux.x86_64 --directory "$APP_BUNDLE_DIR" diff --git a/docker-compose.yml b/docker-compose.yml index 7ae41a1d3f0..a0a67ad8c9b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,7 @@ services: build: context: . target: meteor-dev - command: bash -c "time meteor npm install --no-audit && node ./.reaction/waitForMongo.js && node --experimental-modules ./.reaction/run/index.mjs" + command: bash -c "time meteor npm install --no-audit && node ./.reaction/waitForMongo.js && node --experimental-modules ./.reaction/scripts/run.mjs" depends_on: - mongo env_file: diff --git a/package.json b/package.json index ec8a53642c8..4d7830a6079 100644 --- a/package.json +++ b/package.json @@ -210,11 +210,11 @@ }, "scripts": { "devserver": "ROOT_URL=http://localhost:3030 MONGO_URL=mongodb://localhost:27017/reaction NODE_ENV=reaction-node BABEL_DISABLE_CACHE=1 nodemon ./imports/node-app/devserver/index.js", - "dev": "node --experimental-modules ./.reaction/run/index.mjs", - "inspect": "node --experimental-modules ./.reaction/run/index.mjs --inspect", - "inspect-brk": "node --experimental-modules ./.reaction/run/index.mjs --inspect-brk", - "inspect-docker": "node --experimental-modules ./.reaction/run/index.mjs --inspect=0.0.0.0:9229", - "inspect-brk-docker": "node --experimental-modules ./.reaction/run/index.mjs --inspect-brk=0.0.0.0:9229", + "dev": "node --experimental-modules ./.reaction/scripts/run.mjs", + "inspect": "node --experimental-modules ./.reaction/scripts/run.mjs --inspect", + "inspect-brk": "node --experimental-modules ./.reaction/scripts/run.mjs --inspect-brk", + "inspect-docker": "node --experimental-modules ./.reaction/scripts/run.mjs --inspect=0.0.0.0:9229", + "inspect-brk-docker": "node --experimental-modules ./.reaction/scripts/run.mjs --inspect-brk=0.0.0.0:9229", "lint": "eslint .", "lint:errors": "eslint . --quiet", "test": "npm run test:unit && npm run test:integration && npm run test:app",