|
|
|
@ -1,39 +1,19 @@
|
|
|
|
|
# Based of https://github.com/microsoft/vscode-dev-containers/blob/main/containers/javascript-node/.devcontainer/base.Dockerfile
|
|
|
|
|
# Based of https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
|
|
|
|
|
|
|
|
|
|
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster
|
|
|
|
|
ARG VARIANT=20-bullseye
|
|
|
|
|
ARG VARIANT=22-bookworm
|
|
|
|
|
FROM node:${VARIANT}
|
|
|
|
|
|
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
ARG USERNAME=node
|
|
|
|
|
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
|
|
|
|
|
|
|
|
|
# Copy library scripts to execute
|
|
|
|
|
ADD https://raw.githubusercontent.com/microsoft/vscode-dev-containers/main/containers/javascript-node/.devcontainer/library-scripts/common-debian.sh /tmp/library-scripts/
|
|
|
|
|
ADD https://raw.githubusercontent.com/microsoft/vscode-dev-containers/main/containers/javascript-node/.devcontainer/library-scripts/node-debian.sh /tmp/library-scripts/
|
|
|
|
|
ADD https://raw.githubusercontent.com/microsoft/vscode-dev-containers/main/containers/javascript-node/.devcontainer/library-scripts/meta.env /tmp/library-scripts/
|
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
|
|
# [Option] Install zsh
|
|
|
|
|
ARG INSTALL_ZSH="true"
|
|
|
|
|
# [Option] Upgrade OS packages to their latest versions
|
|
|
|
|
ARG UPGRADE_PACKAGES="true"
|
|
|
|
|
# Add NPM global to PATH.
|
|
|
|
|
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
|
|
|
|
|
|
|
|
|
|
# Install needed packages, yarn, nvm and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
|
|
|
|
ARG USERNAME=node
|
|
|
|
|
ARG USER_UID=1000
|
|
|
|
|
ARG USER_GID=$USER_UID
|
|
|
|
|
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
|
|
|
|
ENV NVM_DIR=/usr/local/share/nvm
|
|
|
|
|
ENV NVM_SYMLINK_CURRENT=true \
|
|
|
|
|
PATH=${NPM_GLOBAL}/bin:${NVM_DIR}/current/bin:${PATH}
|
|
|
|
|
RUN apt-get update \
|
|
|
|
|
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
|
|
|
|
|
&& apt-get purge -y imagemagick imagemagick-6-common \
|
|
|
|
|
# Install common packages, non-root user, update yarn and install nvm
|
|
|
|
|
&& bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
|
|
|
|
|
# Install yarn, nvm
|
|
|
|
|
&& rm -rf /opt/yarn-* /usr/local/bin/yarn /usr/local/bin/yarnpkg \
|
|
|
|
|
&& bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "none" "${USERNAME}" \
|
|
|
|
|
RUN \
|
|
|
|
|
# Configure global npm install location, use group to adapt to UID/GID changes
|
|
|
|
|
&& if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
|
|
|
|
|
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
|
|
|
|
|
&& usermod -a -G npm ${USERNAME} \
|
|
|
|
|
&& umask 0002 \
|
|
|
|
|
&& mkdir -p ${NPM_GLOBAL} \
|
|
|
|
@ -41,50 +21,29 @@ RUN apt-get update \
|
|
|
|
|
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
|
|
|
|
|
&& chmod g+s ${NPM_GLOBAL} \
|
|
|
|
|
&& npm config -g set prefix ${NPM_GLOBAL} \
|
|
|
|
|
&& sudo -u ${USERNAME} npm config -g set prefix ${NPM_GLOBAL} \
|
|
|
|
|
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
|
|
|
|
|
# Install eslint
|
|
|
|
|
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
|
|
|
|
&& npm cache clean --force > /dev/null 2>&1 \
|
|
|
|
|
# Install python-is-python3 on bullseye to prevent node-gyp regressions
|
|
|
|
|
&& . /etc/os-release \
|
|
|
|
|
&& if [ "${VERSION_CODENAME}" = "bullseye" ]; then apt-get -y install --no-install-recommends python-is-python3; fi \
|
|
|
|
|
# Clean up
|
|
|
|
|
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /root/.gnupg /tmp/library-scripts
|
|
|
|
|
&& npm cache clean --force > /dev/null 2>&1
|
|
|
|
|
|
|
|
|
|
# Enable PNPM
|
|
|
|
|
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
|
|
|
|
RUN sudo corepack enable \
|
|
|
|
|
RUN corepack enable \
|
|
|
|
|
&& corepack prepare pnpm@latest --activate
|
|
|
|
|
|
|
|
|
|
EXPOSE 3000
|
|
|
|
|
|
|
|
|
|
# Add Docker Source
|
|
|
|
|
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
|
|
|
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
|
|
|
|
|
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
|
|
|
|
|
|
|
|
# Add cloudflared Source
|
|
|
|
|
RUN curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null && \
|
|
|
|
|
echo "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflared.list
|
|
|
|
|
|
|
|
|
|
# Add Localazy Source
|
|
|
|
|
RUN curl -sS https://dist.localazy.com/debian/pubkey.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/localazy.gpg && \
|
|
|
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/trusted.gpg.d/localazy.gpg] https://maven.localazy.com/repository/apt/ stable main" | sudo tee /etc/apt/sources.list.d/localazy.list
|
|
|
|
|
|
|
|
|
|
# Install the packages we need
|
|
|
|
|
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get install -qy \
|
|
|
|
|
RUN apt-get update && apt-get install -qy \
|
|
|
|
|
bash \
|
|
|
|
|
build-essential \
|
|
|
|
|
cloudflared \
|
|
|
|
|
curl \
|
|
|
|
|
docker-ce-cli \
|
|
|
|
|
jq \
|
|
|
|
|
less \
|
|
|
|
|
git \
|
|
|
|
|
gnupg2 \
|
|
|
|
|
localazy \
|
|
|
|
|
nano \
|
|
|
|
|
netcat \
|
|
|
|
|
netcat-openbsd \
|
|
|
|
|
pandoc \
|
|
|
|
|
unzip \
|
|
|
|
|
wget
|
|
|
|
|