|
| 1 | +FROM node:12 |
| 2 | + |
| 3 | +# Avoid warnings by switching to noninteractive |
| 4 | +ENV DEBIAN_FRONTEND=noninteractive |
| 5 | + |
| 6 | +# The node image comes with a base non-root 'node' user which this Dockerfile |
| 7 | +# gives sudo access. However, for Linux, this user's GID/UID must match your local |
| 8 | +# user UID/GID to avoid permission issues with bind mounts. Update USER_UID / USER_GID |
| 9 | +# if yours is not 1000. See https://aka.ms/vscode-remote/containers/non-root-user. |
| 10 | +ARG USER_UID=1000 |
| 11 | +ARG USER_GID=$USER_UID |
| 12 | + |
| 13 | +# Configure apt and install packages |
| 14 | +RUN apt-get update \ |
| 15 | + && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ |
| 16 | + # |
| 17 | + # Verify git and needed tools are installed |
| 18 | + && apt-get install -y git procps \ |
| 19 | + # |
| 20 | + # Remove outdated yarn from /opt and install via package |
| 21 | + # so it can be easily updated via apt-get upgrade yarn |
| 22 | + && rm -rf /opt/yarn-* \ |
| 23 | + && rm -f /usr/local/bin/yarn \ |
| 24 | + && rm -f /usr/local/bin/yarnpkg \ |
| 25 | + && apt-get install -y curl apt-transport-https lsb-release \ |
| 26 | + && curl -sS https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/pubkey.gpg | apt-key add - 2>/dev/null \ |
| 27 | + && echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ |
| 28 | + && apt-get update \ |
| 29 | + && apt-get -y install --no-install-recommends yarn \ |
| 30 | + # |
| 31 | + # Install eslint globally |
| 32 | + && npm install -g eslint \ |
| 33 | + # |
| 34 | + # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. |
| 35 | + && if [ "$USER_GID" != "1000" ]; then groupmod node --gid $USER_GID; fi \ |
| 36 | + && if [ "$USER_UID" != "1000" ]; then usermod --uid $USER_UID node; fi \ |
| 37 | + # [Optional] Add sudo support for non-root users |
| 38 | + && apt-get install -y sudo \ |
| 39 | + && echo node ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/node \ |
| 40 | + && chmod 0440 /etc/sudoers.d/node \ |
| 41 | + # |
| 42 | + # Clean up |
| 43 | + && apt-get autoremove -y \ |
| 44 | + && apt-get clean -y \ |
| 45 | + && rm -rf /var/lib/apt/lists/* |
| 46 | + |
| 47 | +# Switch back to dialog for any ad-hoc use of apt-get |
| 48 | +ENV DEBIAN_FRONTEND= |
0 commit comments