diff --git a/docs/BestPractices.md b/docs/BestPractices.md index bbc64c634..f0d1c2c66 100644 --- a/docs/BestPractices.md +++ b/docs/BestPractices.md @@ -6,9 +6,6 @@ - [Environment Variables](#environment-variables) - [Global npm dependencies](#global-npm-dependencies) -- [Upgrading/downgrading Yarn](#upgradingdowngrading-yarn) - - [Local](#local) - - [Global](#global) - [Handling Kernel Signals](#handling-kernel-signals) - [Non-root User](#non-root-user) - [Memory](#memory) @@ -38,54 +35,6 @@ ENV NPM_CONFIG_PREFIX=/home/node/.npm-global ENV PATH=$PATH:/home/node/.npm-global/bin # optionally if you want to run npm global bin without specifying path ``` -## Upgrading/downgrading Yarn - -### Local - -If you need to upgrade/downgrade `yarn` for a local install, you can do so by issuing the following commands in your `Dockerfile`: - -> Note that if you create some other directory which is not a descendant one from where you ran the command, you will end up using the global (dated) version. If you wish to upgrade `yarn` globally, follow the instructions in the next section. - -> When following the local install instructions, due to duplicated yarn the image will end up being bigger. - -```Dockerfile -FROM node:6 - -ENV YARN_VERSION=1.16.0 - -RUN yarn policies set-version $YARN_VERSION -``` - -### Global - -```Dockerfile -FROM node:6 - -ENV YARN_VERSION=1.16.0 - -RUN curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ - && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ - && ln -snf /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ - && ln -snf /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ - && rm yarn-v$YARN_VERSION.tar.gz -``` - -If you're using an Alpine-based image, `curl` won't be present, so you'll need to make sure it's installed while using it: - -```Dockerfile -FROM node:6-alpine - -ENV YARN_VERSION=1.5.1 - -RUN apk add --no-cache --virtual .build-deps-yarn curl \ - && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ - && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ - && ln -snf /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ - && ln -snf /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ - && rm yarn-v$YARN_VERSION.tar.gz \ - && apk del .build-deps-yarn -``` - ## Handling Kernel Signals Node.js was not designed to run as PID 1 which leads to unexpected behaviour when running inside of Docker. For example, a Node.js process running as PID 1 will not respond to `SIGINT` (`CTRL-C`) and similar signals. As of Docker 1.13, you can use the `--init` flag to wrap your Node.js process with a [lightweight init system](https://github.com/krallin/tini) that properly handles running as PID 1.