From 44af7e7a403fbef877094b2cffbe15e570941fed Mon Sep 17 00:00:00 2001 From: Felix Rizzolli Date: Sun, 9 Nov 2025 10:24:56 +0000 Subject: [PATCH] chore: initialize devcontainer setup for better DX --- .devcontainer/.env | 2 + .devcontainer/Dockerfile | 31 ++++++++++++++++ .devcontainer/compose.yml | 28 ++++++++++++++ .devcontainer/devcontainer.json | 65 +++++++++++++++++++++++++++++++++ .devcontainer/setup.sh | 16 ++++++++ 5 files changed, 142 insertions(+) create mode 100644 .devcontainer/.env create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/compose.yml create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/setup.sh diff --git a/.devcontainer/.env b/.devcontainer/.env new file mode 100644 index 0000000000..9b9096d853 --- /dev/null +++ b/.devcontainer/.env @@ -0,0 +1,2 @@ +PORT=5055 +HOST=0.0.0.0 \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..0a2972494e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,31 @@ +FROM mcr.microsoft.com/devcontainers/typescript-node:18 + +RUN echo "INSTALL OVERSEER DEVCONTAINER IMAGE" && \ + # Configure Bash + # --> Disable Bash's bracket paste mode + echo "bind 'set enable-bracket-paste off'" >> ~/.bashrc && \ + # --> Always show hidden files in ls and colorize the output + echo "alias ls='ls -a --color=auto'" >> ~/.bashrc && \ + # Configure Git + # --> Ensure that git treats /workspace as a safe directory to avoid permission-related issues. + git config --global --add safe.directory /workspace && \ + # Install common dependencies + apt-get update && \ + (type -p curl >/dev/null || (apt-get install curl -y)) && \ + (type -p ca-certificates >/dev/null || (apt-get install ca-certificates -y)) && \ + (type -p gnupg >/dev/null || (apt-get install gnupg -y)) && \ + (type -p wget >/dev/null || (apt-get install wget -y)) && \ + (type -p unzip >/dev/null || (apt-get install unzip -y)) && \ + (type -p lsb-release >/dev/null || (apt-get install lsb-release -y)) && \ + # Install GitHub CLI + mkdir -p -m 755 /etc/apt/keyrings /etc/apt/sources.list.d && \ + wget -nv -O /etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg && \ + chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list && \ + apt-get update && apt-get install -y gh && \ + gh --version && \ + # Clean up + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +EXPOSE 5055 diff --git a/.devcontainer/compose.yml b/.devcontainer/compose.yml new file mode 100644 index 0000000000..b10533a5df --- /dev/null +++ b/.devcontainer/compose.yml @@ -0,0 +1,28 @@ +services: + devcontainer: + build: + context: . + dockerfile: Dockerfile + environment: + GH_TOKEN: ${GH_TOKEN} + env_file: + - path: ./.env + required: true + volumes: + - ../:/workspace + # Mount the SSH keys from the host to the container for git access + - ~/.ssh:/root/local-ssh + # Mount the setup.sh script to the container + - ./setup.sh:/root/setup.sh + ports: + - 5055:5055 + networks: + - default + command: ["sleep", "infinity"] + +networks: + default: + name: devcontainer + driver: bridge + driver_opts: + com.docker.network.bridge.name: devcontainer diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..b71d6da863 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,65 @@ +{ + "name": "Overseer Dev Container", + "dockerComposeFile": "./compose.yml", + "service": "devcontainer", + "shutdownAction": "none", + + "remoteUser": "root", + "workspaceFolder": "/workspace", + + "postCreateCommand": "bash /root/setup.sh", + + "customizations": { + "vscode": { + "extensions": [ + "EditorConfig.editorconfig", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "Orta.vscode-jest", + "stylelint.vscode-stylelint", + "bradlc.vscode-tailwindcss", + "mskelton.npm-outdated", + "eamodio.gitlens", + "wix.vscode-import-cost", + "gruntfuggly.todo-tree", + "aaron-bond.better-comments", + "usernamehw.errorlens" + ], + "settings": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "prettier.configPath": "/workspace/.prettierrc", + "prettier.ignorePath": "/workspace/.prettierignore", + "eslint.enable": true, + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], + "typescript.tsdk": "node_modules/typescript/lib", + "typescript.preferences.importModuleSpecifier": "non-relative", + "sqltools.connections": [ + { + "previewLimit": 50, + "driver": "SQLite", + "name": "Local SQLite", + "database": "./config/db/db.sqlite3" + } + ], + "files.associations": { + "globals.css": "tailwindcss" + }, + "i18n-ally.localesPaths": ["src/i18n/locale"] + } + } + }, + + "forwardPorts": [5055], + "portsAttributes": { + "5055": { + "label": "Overseer", + "onAutoForward": "notify" + } + } +} diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100644 index 0000000000..59cf8cb1cc --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +echo "🚀 Setting up development environment..." + +# Copy SSH keys +echo "🔑 Configuring SSH keys..." +mkdir -p /root/.ssh +cp -p /root/local-ssh/* /root/.ssh/ + +echo "🔒 Setting SSH key permissions..." +chmod 700 /root/.ssh +find /root/.ssh -type f -exec sh -c 'case "$1" in *.pub) chmod 644 "$1";; *) chmod 600 "$1";; esac' _ {} \; +chown -R root:root /root/.ssh + +echo "✅ Development environment ready!"