Skip to content

Commit c2603ca

Browse files
Build improvements (#260)
* 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
1 parent 68cfe61 commit c2603ca

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ WORKDIR /usr/src/app
99
COPY bin/docs ./bin/docs
1010
COPY engine.json package.json yarn.lock ./
1111

12+
RUN mkdir /usr/local/node_modules
13+
ENV PREFIX=/usr/local/node_modules
14+
ENV PATH=$PREFIX/.bin:$PATH
15+
ENV NODE_PATH=$PREFIX
16+
ENV NPM_CONFIG_PREFIX=$PREFIX
17+
1218
RUN apt-get install -y git jq yarn && \
13-
yarn install && \
14-
version="v$(npm -j ls eslint | jq -r .dependencies.eslint.version)" && \
19+
yarn config set prefix $PREFIX && \
20+
yarn install --modules-folder $PREFIX && \
21+
version="v$(yarn list eslint | grep eslint | sed -n 's/.*@//p')" && \
1522
bin/docs "$version" && \
1623
cat engine.json | jq ".version = \"$version\"" > /engine.json && \
1724
apt-get purge -y git jq yarn && \
@@ -20,6 +27,7 @@ RUN apt-get install -y git jq yarn && \
2027
RUN adduser --uid 9000 --gecos "" --disabled-password app
2128
COPY . ./
2229
RUN chown -R app:app ./
30+
RUN chown -R app:app $PREFIX
2331

2432
USER app
2533

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,24 @@ endif
1414
image:
1515
docker build --rm -t $(IMAGE_NAME) .
1616

17-
integration: image
17+
integration: yarn.lock
1818
docker run -ti --rm \
19+
-v $(PWD):/usr/src/app \
1920
--workdir /usr/src/app \
2021
$(IMAGE_NAME) npm run $(NPM_INTEGRATION_TARGET)
2122

22-
test: image
23+
test: yarn.lock
2324
docker run -ti --rm \
25+
-v $(PWD):/usr/src/app \
2426
--workdir /usr/src/app \
2527
$(IMAGE_NAME) npm run $(NPM_TEST_TARGET)
2628

2729
citest:
2830
docker run --rm \
2931
--workdir /usr/src/app \
3032
$(IMAGE_NAME) sh -c "npm run test && npm run integration"
33+
34+
yarn.lock: package.json Dockerfile
35+
$(MAKE) image
36+
./bin/yarn install
37+
touch yarn.lock

0 commit comments

Comments
 (0)