From 1a6b5851b3e5c3cd238b1b6cd0203ae0e4a3b748 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sat, 7 Dec 2024 21:59:10 +0000 Subject: [PATCH] chore: update devcontainer --- .devcontainer/Dockerfile | 69 +++++++------------------------- .devcontainer/devcontainer.json | 31 +++++--------- .devcontainer/docker-compose.yml | 4 +- 3 files changed, 26 insertions(+), 78 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 49284e17..094a8fce 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7cbc3e8b..f65cd13b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,21 +11,7 @@ "customizations": { "vscode": { "settings": { - "terminal.integrated.defaultProfile.linux": "zsh", - "sqltools.connections": [ - // Default connection to dev DB container - { - "name": "Local Dev", - "server": "db", - "port": 5432, - "database": "postgres", - "username": "postgres", - "password": "postgres", - "driver": "PostgreSQL", - "askForPassword": false, - "connectionTimeout": 60 - } - ] + "terminal.integrated.defaultProfile.linux": "zsh" }, "extensions": [ "arcanis.vscode-zipfs", @@ -66,11 +52,16 @@ // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. "remoteUser": "node", "features": { - "common": { - "installZsh": true, - "installOhMyZsh": true, - "upgradePackages": true + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "true", + "installOhMyZsh": "true", + "username": "node", + "upgradePackages": "true" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "none" }, - "github-cli": "latest" + "ghcr.io/devcontainers/features/git:1": {}, + "ghcr.io/joedmck/devcontainer-features/cloudflared:1": {} } } diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 294973d4..bf012ad5 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: app: build: @@ -9,7 +7,7 @@ services: # Update 'VARIANT' to pick an LTS version of Node.js: 18, 16, 14, 12. # Append -bullseye or -buster to pin to an OS version. # Use -bullseye variants on local arm64/Apple Silicon. - VARIANT: 20-bullseye + VARIANT: 22-bookworm volumes: - ..:/workspace