Skip to content

Commit

Permalink
feat(ci): speed up docker image creation (#275)
Browse files Browse the repository at this point in the history
When a commit is merged on `master`, our GitHub Actions workflow creates a Docker image and publishes it to [our Docker Hub page](https://hub.docker.com/r/openwhyd/openwhyd/tags).

As of today, this step does a `npm install`, which wastes time by installing Cypress and other dev dependencies. => The "Publish to Docker Hub registry" step ends up taking 3mn16 to run. (See https://github.com/openwhyd/openwhyd/runs/478006896)

Also, the resulting images weights 596.25 MB (compressed), which could be reduced.

This PR also uses `npx` to be able to run `mocha` when `npm run docker:test` is used against the Docker image.
  • Loading branch information
adrienjoly committed Mar 1, 2020
1 parent a610bd6 commit 80e7056
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKDIR /usr/src/app
# Install app dependencies

COPY ./package*.json /usr/src/app/
RUN npm install
RUN npm install --prefer-offline --no-audit --production

# Fix Error: Cannot find module '../build/Release/bson' on newer node / MongoDB versions
# RUN sed -i.backup 's/..\/build\/Release\/bson/bson/g' /usr/src/app/node_modules/bson/ext/index.js
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"forever:restart": "npm run forever:stop; npm run forever:start $@;",
"start": "node app.js --fakeEmail --digestInterval -1 $@",
"test-reset": "node test/reset-test-db.js",
"test-api": "npm run test-reset && node_modules/.bin/mocha test/api/*.js --exit",
"test-unit": "node_modules/.bin/mocha test/unit/*.js --exit",
"test-api": "npm run test-reset && npx mocha test/api/*.js --exit",
"test-unit": "npx mocha test/unit/*.js --exit",
"test-acceptance": "npm run test-reset && wdio wdio.conf.js $@",
"test-acceptance-dev": "npm run test-acceptance -- --spec ./test/specs/*.tests.js --logLevel verbose",
"test:cypress:dev": "npm run docker:seed && . ./.env-docker && node_modules/.bin/cypress open",
Expand Down

0 comments on commit 80e7056

Please sign in to comment.