chore: update devcontainer

pull/6816/merge
NGPixel 3 weeks ago
parent 57d4097296
commit 1a6b5851b3
No known key found for this signature in database
GPG Key ID: B755FB6870B30F63

@ -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=22-bookworm
ARG VARIANT=20-bullseye
FROM node:${VARIANT} FROM node:${VARIANT}
ENV DEBIAN_FRONTEND=noninteractive ARG USERNAME=node
ARG NPM_GLOBAL=/usr/local/share/npm-global
# Copy library scripts to execute ENV DEBIAN_FRONTEND=noninteractive
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/
# [Option] Install zsh # Add NPM global to PATH.
ARG INSTALL_ZSH="true" ENV PATH=${NPM_GLOBAL}/bin:${PATH}
# [Option] Upgrade OS packages to their latest versions
ARG UPGRADE_PACKAGES="true"
# Install needed packages, yarn, nvm and setup non-root user. Use a separate RUN statement to add your own dependencies. RUN \
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}" \
# Configure global npm install location, use group to adapt to UID/GID changes # 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} \ && usermod -a -G npm ${USERNAME} \
&& umask 0002 \ && umask 0002 \
&& mkdir -p ${NPM_GLOBAL} \ && mkdir -p ${NPM_GLOBAL} \
@ -41,50 +21,29 @@ RUN apt-get update \
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \ && chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
&& chmod g+s ${NPM_GLOBAL} \ && chmod g+s ${NPM_GLOBAL} \
&& npm config -g set prefix ${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 # Install eslint
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \ && su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
&& npm cache clean --force > /dev/null 2>&1 \ && 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
# Enable PNPM # Enable PNPM
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
RUN sudo corepack enable \ RUN corepack enable \
&& corepack prepare pnpm@latest --activate && corepack prepare pnpm@latest --activate
EXPOSE 3000 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 # 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 \ bash \
build-essential \ build-essential \
cloudflared \
curl \ curl \
docker-ce-cli \
jq \ jq \
less \ less \
git \ git \
gnupg2 \ gnupg2 \
localazy \
nano \ nano \
netcat \ netcat-openbsd \
pandoc \ pandoc \
unzip \ unzip \
wget wget

@ -11,21 +11,7 @@
"customizations": { "customizations": {
"vscode": { "vscode": {
"settings": { "settings": {
"terminal.integrated.defaultProfile.linux": "zsh", "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
}
]
}, },
"extensions": [ "extensions": [
"arcanis.vscode-zipfs", "arcanis.vscode-zipfs",
@ -66,11 +52,16 @@
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node", "remoteUser": "node",
"features": { "features": {
"common": { "ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true, "installZsh": "true",
"installOhMyZsh": true, "installOhMyZsh": "true",
"upgradePackages": 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": {}
} }
} }

@ -1,5 +1,3 @@
version: '3.8'
services: services:
app: app:
build: build:
@ -9,7 +7,7 @@ services:
# Update 'VARIANT' to pick an LTS version of Node.js: 18, 16, 14, 12. # Update 'VARIANT' to pick an LTS version of Node.js: 18, 16, 14, 12.
# Append -bullseye or -buster to pin to an OS version. # Append -bullseye or -buster to pin to an OS version.
# Use -bullseye variants on local arm64/Apple Silicon. # Use -bullseye variants on local arm64/Apple Silicon.
VARIANT: 20-bullseye VARIANT: 22-bookworm
volumes: volumes:
- ..:/workspace - ..:/workspace

Loading…
Cancel
Save