Skip to content

Commit

Permalink
PP-3004 Switch to standard npm dep install pattern
Browse files Browse the repository at this point in the history
- Copied pattern used in all our other Node.js dockerfiles using a symlink for node_modules
  • Loading branch information
maxcbc committed Nov 30, 2017
1 parent d02606f commit c28286b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Jenkinsfile
CONTRIBUTING.md
env.sh
.snyk
build-local.sh
node_modules
node_modules_local
logs/**/*
.sass-lint.yml
.jshintrc
.sass-lint.yml
Dockerfile
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ RUN apk update &&\
ENV PORT 9000
EXPOSE 9000

ADD package.json /tmp/package.json
RUN cd /tmp && npm install --production

WORKDIR /app
ADD . /app

RUN ln -s /tmp/node_modules /app/node_modules

CMD npm start
8 changes: 3 additions & 5 deletions build-local.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
docker build --file docker/build_and_test.Dockerfile -t govukpay/frontend-build:local . &&\
docker run --volume $(pwd):/app:rw govukpay/frontend-build:local &&\
docker build -t govukpay/frontend:local . &&\
npm rebuild &&\
npm i

npm install && npm run compile &&\
docker build -t govukpay/frontend:local .
6 changes: 3 additions & 3 deletions docker/build_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ grep -rnw './test' -e 'it.only' && echo '' && echo 'ERROR: it.only() found in te
grep -rnw './test' -e 'describe.only' && echo '' && echo 'ERROR: describe.only() found in tests, Exiting' && exit 1
grep -rnw './test' -e 'context.only' && echo '' && echo 'ERROR: context.only() found in tests, Exiting' && exit 1

mkdir -p /app &&\
cp -a /tmp/node_modules /app/ &&\
rm -rf node_modules &&\
ln -s /tmp/node_modules /app/node_modules &&\
npm run compile &&\
npm test &&\
npm prune --production
rm -rf node_modules

0 comments on commit c28286b

Please sign in to comment.