diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..3d1f19e9 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,39 @@ +# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster +ARG VARIANT=16-bullseye +FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT} + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +###################### Firefox +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get install --no-install-recommends -y firefox-esr +###################### + +###################### Chrome +RUN useradd apps +RUN mkdir -p /home/apps && chown apps:apps /home/apps +# Install xvfb. +RUN apt-get install -y xvfb +# Install wget. +RUN apt-get install -y wget +# Install wmctrl. +RUN apt-get install -y wmctrl +# Set the Chrome repo. +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list +# Install Chrome. +RUN apt-get update && apt-get -y install google-chrome-stable + +COPY bootstrap.sh / + +CMD '/bootstrap.sh' + +#################### + +# [Optional] Uncomment if you want to install an additional version of node using nvm +# ARG EXTRA_NODE_VERSION=10 +# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" + +# [Optional] Uncomment if you want to install more global node packages +# RUN su node -c "npm install -g " diff --git a/.devcontainer/base.Dockerfile b/.devcontainer/base.Dockerfile new file mode 100644 index 00000000..35b6654f --- /dev/null +++ b/.devcontainer/base.Dockerfile @@ -0,0 +1,17 @@ +# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster +ARG VARIANT=16-bullseye +FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT} + +# Install tslint, typescript. eslint is installed by javascript image +ARG NODE_MODULES="tslint-to-eslint-config typescript" +COPY library-scripts/meta.env /usr/local/etc/vscode-dev-containers +RUN su node -c "umask 0002 && npm install -g ${NODE_MODULES}" \ + && npm cache clean --force > /dev/null 2>&1 + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment if you want to install an additional version of node using nvm +# ARG EXTRA_NODE_VERSION=10 +# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" diff --git a/.devcontainer/bootstrap.sh b/.devcontainer/bootstrap.sh new file mode 100644 index 00000000..b058bf0d --- /dev/null +++ b/.devcontainer/bootstrap.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Based on: http://www.richud.com/wiki/Ubuntu_Fluxbox_GUI_with_x11vnc_and_Xvfb + +readonly G_LOG_I='[INFO]' +readonly G_LOG_W='[WARN]' +readonly G_LOG_E='[ERROR]' + +main() { + launch_xvfb + launch_window_manager +} + +launch_xvfb() { + # Set defaults if the user did not specify envs. + export DISPLAY=${XVFB_DISPLAY:-:1} + local screen=${XVFB_SCREEN:-0} + local resolution=${XVFB_RESOLUTION:-1280x1024x24} + local timeout=${XVFB_TIMEOUT:-5} + + # Start and wait for either Xvfb to be fully up or we hit the timeout. + Xvfb ${DISPLAY} -screen ${screen} ${resolution} & + local loopCount=0 + until xdpyinfo -display ${DISPLAY} > /dev/null 2>&1 + do + loopCount=$((loopCount+1)) + sleep 1 + if [ ${loopCount} -gt ${timeout} ] + then + echo "${G_LOG_E} xvfb failed to start." + exit 1 + fi + done +} + +launch_window_manager() { + local timeout=${XVFB_TIMEOUT:-5} + + # Start and wait for either fluxbox to be fully up or we hit the timeout. + fluxbox & + local loopCount=0 + until wmctrl -m > /dev/null 2>&1 + do + loopCount=$((loopCount+1)) + sleep 1 + if [ ${loopCount} -gt ${timeout} ] + then + echo "${G_LOG_E} fluxbox failed to start." + exit 1 + fi + done +} + +control_c() { + echo "" + exit +} + +trap control_c SIGINT SIGTERM SIGHUP + +main + +exit \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..bf8fd0b8 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,45 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/typescript-node +{ + "name": "Node.js & TypeScript", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick a Node version: 18, 16, 14. + // Append -bullseye or -buster to pin to an OS version. + // Use -bullseye variants on local on arm64/Apple Silicon. + "args": { + "VARIANT": "16-bullseye" + } + }, + + "features": { + "desktop-lite": { + "password": "vscode", + "webPort": "6080", + "vncPort": "5901" + } + }, + "runArgs": ["--shm-size=2g"], + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "k--kato.intellij-idea-keybindings", + "dbaeumer.vscode-eslint", + "svelte.svelte-vscode" + ] + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [6080,5901], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "node" +} diff --git a/vite.config.ts b/vite.config.ts index e0476014..9a4fdb4a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -31,8 +31,10 @@ export default defineConfig({ disableAutoLaunch: process.env.BROWSER === 'none', browser: process.env.BROWSER === 'firefox' ? 'firefox' : 'chrome', webExtConfig: { - startUrl: 'https://www.youtube.com/watch?v=5qap5aO4i9A' - } + startUrl: 'https://www.youtube.com/watch?v=jfKfPfyJRdk', + args: process.env.BROWSER === 'firefox' ? [''] : ['--no-sandbox', '--autoplay-policy=no-user-gesture-required'] + }, + verbose: true }), svelte({ configFile: path.resolve(__dirname, 'svelte.config.js'),