Skip to content

Commit

Permalink
Build improvements (#260)
Browse files Browse the repository at this point in the history
* Make sure yarn.lock is updated during development
* Install node_modules aside from src directory so it can be overridden as a mounted volume
  - This helps speeding up tests during development as it allows test execution without requiring the image to be rebuilt
  • Loading branch information
filipesperandio authored May 3, 2017
1 parent 68cfe61 commit c2603ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ WORKDIR /usr/src/app
COPY bin/docs ./bin/docs
COPY engine.json package.json yarn.lock ./

RUN mkdir /usr/local/node_modules
ENV PREFIX=/usr/local/node_modules
ENV PATH=$PREFIX/.bin:$PATH
ENV NODE_PATH=$PREFIX
ENV NPM_CONFIG_PREFIX=$PREFIX

RUN apt-get install -y git jq yarn && \
yarn install && \
version="v$(npm -j ls eslint | jq -r .dependencies.eslint.version)" && \
yarn config set prefix $PREFIX && \
yarn install --modules-folder $PREFIX && \
version="v$(yarn list eslint | grep eslint | sed -n 's/.*@//p')" && \
bin/docs "$version" && \
cat engine.json | jq ".version = \"$version\"" > /engine.json && \
apt-get purge -y git jq yarn && \
Expand All @@ -20,6 +27,7 @@ RUN apt-get install -y git jq yarn && \
RUN adduser --uid 9000 --gecos "" --disabled-password app
COPY . ./
RUN chown -R app:app ./
RUN chown -R app:app $PREFIX

USER app

Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@ endif
image:
docker build --rm -t $(IMAGE_NAME) .

integration: image
integration: yarn.lock
docker run -ti --rm \
-v $(PWD):/usr/src/app \
--workdir /usr/src/app \
$(IMAGE_NAME) npm run $(NPM_INTEGRATION_TARGET)

test: image
test: yarn.lock
docker run -ti --rm \
-v $(PWD):/usr/src/app \
--workdir /usr/src/app \
$(IMAGE_NAME) npm run $(NPM_TEST_TARGET)

citest:
docker run --rm \
--workdir /usr/src/app \
$(IMAGE_NAME) sh -c "npm run test && npm run integration"

yarn.lock: package.json Dockerfile
$(MAKE) image
./bin/yarn install
touch yarn.lock

0 comments on commit c2603ca

Please sign in to comment.