-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve docker layer caching and build times
Currently, the apt-get package install layer is invalidated anytime we update npm dependencies. This commit splits package installation and npm dependency installation into separate steps, which should improve docker layer caching and speed up build times. This commit also extracts the inline docs installation into a separate bin script.
- Loading branch information
Showing
2 changed files
with
29 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,26 @@ | ||
FROM node:6.10.0-slim | ||
MAINTAINER Code Climate <[email protected]> | ||
LABEL maintainer "Code Climate <[email protected]>" | ||
|
||
RUN apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg && \ | ||
echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ | ||
apt-get update && \ | ||
apt-get install -y yarn | ||
apt-get update | ||
|
||
WORKDIR /usr/src/app | ||
COPY package.json yarn.lock /usr/src/app/ | ||
|
||
RUN yarn install | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y git jq && \ | ||
git clone https://github.com/eslint/eslint.git && \ | ||
ESLINT_DOCS_VERSION=`npm -j ls eslint | jq -r .dependencies.eslint.version` && \ | ||
cd eslint && \ | ||
git checkout v$ESLINT_DOCS_VERSION && \ | ||
cd .. && \ | ||
mkdir -p /usr/src/app/lib/docs/rules/ && \ | ||
cp ./eslint/docs/rules/* /usr/src/app/lib/docs/rules/ && \ | ||
rm -rf eslint && \ | ||
apt-get purge -y git jq && \ | ||
apt-get autoremove -y | ||
|
||
RUN adduser -u 9000 --gecos "" --disabled-password app | ||
COPY . /usr/src/app | ||
RUN chown -R app:app /usr/src/app | ||
COPY bin/docs ./bin/docs | ||
COPY engine.json package.json yarn.lock ./ | ||
|
||
RUN apt-get install -y git jq yarn && \ | ||
yarn install && \ | ||
version="v$(npm -j ls eslint | jq -r .dependencies.eslint.version)" && \ | ||
bin/docs "$version" && \ | ||
cat engine.json | jq ".version = \"$version\"" > /tmp/engine.json && \ | ||
apt-get purge -y git jq yarn && \ | ||
apt-get autoremove --yes | ||
|
||
RUN adduser --uid 9000 --gecos "" --disabled-password app | ||
COPY . ./ | ||
RUN chown -R app:app ./ && \ | ||
mv /tmp/engine.json ./ | ||
|
||
USER app | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
version=$1 | ||
printf "Pulling docs from ESlint %s\n" "$version" | ||
|
||
git clone https://github.com/eslint/eslint.git /tmp/eslint | ||
(cd /tmp/eslint && git reset --hard "$version") | ||
mkdir --parents ./lib/docs | ||
cp --recursive /tmp/eslint/docs/rules ./lib/docs/rules | ||
rm --force --recursive /tmp/eslint |