|
6 | 6 |
|
7 | 7 | - [Environment Variables](#environment-variables) |
8 | 8 | - [Global npm dependencies](#global-npm-dependencies) |
9 | | -- [Upgrading/downgrading Yarn](#upgradingdowngrading-yarn) |
10 | | - - [Local](#local) |
11 | | - - [Global](#global) |
12 | 9 | - [Handling Kernel Signals](#handling-kernel-signals) |
13 | 10 | - [Non-root User](#non-root-user) |
14 | 11 | - [Memory](#memory) |
@@ -38,54 +35,6 @@ ENV NPM_CONFIG_PREFIX=/home/node/.npm-global |
38 | 35 | ENV PATH=$PATH:/home/node/.npm-global/bin # optionally if you want to run npm global bin without specifying path |
39 | 36 | ``` |
40 | 37 |
|
41 | | -## Upgrading/downgrading Yarn |
42 | | - |
43 | | -### Local |
44 | | - |
45 | | -If you need to upgrade/downgrade `yarn` for a local install, you can do so by issuing the following commands in your `Dockerfile`: |
46 | | - |
47 | | -> 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. |
48 | | -
|
49 | | -> When following the local install instructions, due to duplicated yarn the image will end up being bigger. |
50 | | -
|
51 | | -```Dockerfile |
52 | | -FROM node:6 |
53 | | - |
54 | | -ENV YARN_VERSION=1.16.0 |
55 | | - |
56 | | -RUN yarn policies set-version $YARN_VERSION |
57 | | -``` |
58 | | - |
59 | | -### Global |
60 | | - |
61 | | -```Dockerfile |
62 | | -FROM node:6 |
63 | | - |
64 | | -ENV YARN_VERSION=1.16.0 |
65 | | - |
66 | | -RUN curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ |
67 | | - && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ |
68 | | - && ln -snf /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ |
69 | | - && ln -snf /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ |
70 | | - && rm yarn-v$YARN_VERSION.tar.gz |
71 | | -``` |
72 | | - |
73 | | -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: |
74 | | - |
75 | | -```Dockerfile |
76 | | -FROM node:6-alpine |
77 | | - |
78 | | -ENV YARN_VERSION=1.5.1 |
79 | | - |
80 | | -RUN apk add --no-cache --virtual .build-deps-yarn curl \ |
81 | | - && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ |
82 | | - && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ |
83 | | - && ln -snf /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ |
84 | | - && ln -snf /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ |
85 | | - && rm yarn-v$YARN_VERSION.tar.gz \ |
86 | | - && apk del .build-deps-yarn |
87 | | -``` |
88 | | - |
89 | 38 | ## Handling Kernel Signals |
90 | 39 |
|
91 | 40 | 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. |
|
0 commit comments