Skip to content

Commit

Permalink
chore: Decrease CI build time by using a prebuild docker image (#127)
Browse files Browse the repository at this point in the history
* Foo

* Comment out cache

* Readd the correct image

* Remove cypress install. not needed anymore

* Add Now.sh docker file
  • Loading branch information
thangngoc89 committed Aug 21, 2018
1 parent c6dece9 commit cf15501
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
19 changes: 6 additions & 13 deletions .circleci/config.yml
Expand Up @@ -15,16 +15,15 @@ refs:

defaults: &defaults
docker:
- image: circleci/node:10-browsers
- image: thangngoc89/sketch-sh

version: 2
jobs:
build:
<<: *defaults
working_directory: ~/rtop/client
docker:
- image: circleci/node:10-browsers
- image: cypress/base:8
- image: thangngoc89/sketch-sh
- image: circleci/postgres:10-alpine
environment:
POSTGRES_USER: gql_test
Expand Down Expand Up @@ -55,9 +54,9 @@ jobs:
- checkout:
path: ~/rtop
- restore_cache:
key: v4-deps-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
key: v4-deps-{{ .Branch }}
key: v4-deps
key: v5-deps-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
key: v5-deps-{{ .Branch }}
key: v5-deps
- run:
name: Install Dependencies
command: npm ci
Expand Down Expand Up @@ -89,9 +88,6 @@ jobs:
name: Unit tests
command: |
npm test
- run:
name: Install required Cypress dependencies
command: sudo apt-get install xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
- run:
name: E2E tests with Cypress
command: npm run ci:cypress
Expand All @@ -100,7 +96,7 @@ jobs:
command: npm run ci:build

- save_cache:
key: v4-deps-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
key: v5-deps-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
paths:
- ~/.npm
- ~/.cache
Expand Down Expand Up @@ -129,9 +125,6 @@ jobs:
cd build
../node_modules/.bin/now --token $NOW_TOKEN
../node_modules/.bin/now alias --token $NOW_TOKEN sketch-staging.now.sh
- run:
name: Install required Cypress dependencies
command: sudo apt-get install xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
- run:
name: E2E test on staging
command: |
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
@@ -1,6 +1,6 @@
FROM node:10.8.0
RUN npm -g config set user root
RUN npm install -g bs-platform@4.0.3
# This docker file must be in repository root folder
# For now.sh Github integration to work
FROM thangngoc89/sketch-sh:now
WORKDIR /usr/src
COPY client/package-lock.json client/package.json ./
RUN npm link bs-platform
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Expand Up @@ -13,7 +13,7 @@
"start": "webpack-dev-server",
"ci:build": "rm -rf build && node ./set-bsconfig-production.js && bsb -clean-world && npm run build",
"ci:cypress": "start-server-and-test start http-get://localhost:3000 cy:run:record",
"ci:cypress:staging": "cypress install && cypress run --record --browser chrome -c baseUrl=\"https://staging.sketch.sh\",defaultCommandTimeout=20000",
"ci:cypress:staging": "cypress run --record --browser chrome -c baseUrl=\"https://staging.sketch.sh\",defaultCommandTimeout=20000",
"cy:open": "cypress open",
"cy:run": "cypress run",
"cy:run:record": "cypress run --record --browser chrome"
Expand Down
9 changes: 9 additions & 0 deletions docker/Dockerfile
@@ -0,0 +1,9 @@
FROM circleci/node:10-browsers

RUN sudo apt-get install xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
# RUN cat /etc/passwd
WORKDIR /home/circleci/temp
RUN sudo chown -R circleci:circleci /home/circleci/temp
USER circleci
RUN echo "{}" > package.json && npm install cypress && \
cd .. && rm -rf ~/temp/
9 changes: 9 additions & 0 deletions docker/Dockerfile.now
@@ -0,0 +1,9 @@
# Prebuild docker image for now deployment
# - Prebuild bs-platform
# - Cache cypress's download
FROM node:10.8.0
RUN npm -g config set user root
RUN npm install -g bs-platform@4.0.3
WORKDIR ~/temp/
RUN echo "{}" > package.json && npm install cypress && \
cd .. && rm -rf ~/temp/

0 comments on commit cf15501

Please sign in to comment.