mirror of
https://github.com/bitwarden/browser
synced 2026-01-31 00:33:33 +00:00
Restructure devcontainers with browser-gui, native-gui variants and shared config
This commit is contained in:
31
.devcontainer/browser-gui/devcontainer.json
Normal file
31
.devcontainer/browser-gui/devcontainer.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "Bitwarden Clients (macOS / GitHub Codespaces)",
|
||||
"dockerComposeFile": "../common/docker-compose.yml",
|
||||
"service": "bitwarden_clients",
|
||||
"workspaceFolder": "/workspace",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/rust:1": {},
|
||||
"ghcr.io/devcontainers/features/desktop-lite:1": {}
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"angular.ng-template",
|
||||
"orta.vscode-jest",
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"nrwl.angular-console",
|
||||
"bradlc.vscode-tailwindcss"
|
||||
]
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "bash .devcontainer/common/postCreateCommand.sh",
|
||||
"forwardPorts": [8080, 8081, 6006, 6080],
|
||||
"portsAttributes": {
|
||||
"default": { "onAutoForward": "ignore" },
|
||||
"8080": { "label": "Web Vault", "onAutoForward": "notify" },
|
||||
"8081": { "label": "Web Vault (Self-hosted)", "onAutoForward": "notify" },
|
||||
"6006": { "label": "Storybook", "onAutoForward": "notify" },
|
||||
"6080": { "label": "Desktop (noVNC)", "onAutoForward": "ignore" }
|
||||
}
|
||||
}
|
||||
11
.devcontainer/common/.env.example
Normal file
11
.devcontainer/common/.env.example
Normal file
@@ -0,0 +1,11 @@
|
||||
# Devcontainer setup configuration
|
||||
# Copy to .env and modify as needed
|
||||
|
||||
# Install Rust nightly toolchain and cargo tools for desktop native module
|
||||
SETUP_DESKTOP_NATIVE=yes
|
||||
|
||||
# Install mkcert and generate SSL certificates for localhost (needed for WebAuthn)
|
||||
SETUP_MKCERT=yes
|
||||
|
||||
# Run npm ci to install dependencies
|
||||
RUN_NPM_CI=yes
|
||||
@@ -1,8 +1,9 @@
|
||||
name: bitwarden_common
|
||||
name: bitwarden_clients
|
||||
|
||||
services:
|
||||
bitwarden_clients:
|
||||
image: mcr.microsoft.com/devcontainers/typescript-node:22
|
||||
volumes:
|
||||
- ../:/workspace:cached
|
||||
- ../../:/workspace:cached
|
||||
shm_size: "1gb"
|
||||
command: sleep infinity
|
||||
70
.devcontainer/common/postCreateCommand.sh
Executable file
70
.devcontainer/common/postCreateCommand.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "Running postCreateCommand.sh"
|
||||
|
||||
# Load configuration (use .env.example as fallback for defaults)
|
||||
if [ -f ".devcontainer/common/.env" ]; then
|
||||
source .devcontainer/common/.env
|
||||
else
|
||||
source .devcontainer/common/.env.example
|
||||
fi
|
||||
|
||||
# Configure git safe directory
|
||||
git config --global --add safe.directory /workspace
|
||||
|
||||
echo "Installing system dependencies..."
|
||||
# Packages needed:
|
||||
# libnss3-tools: mkcert certificate installation
|
||||
# build-essential, pkg-config: native module compilation
|
||||
# libsecret-1-dev, libglib2.0-dev: desktop native module dependencies
|
||||
# Remaining packages: Electron runtime dependencies
|
||||
sudo apt-get update && sudo apt-get install -y \
|
||||
libnss3-tools \
|
||||
build-essential \
|
||||
pkg-config \
|
||||
libsecret-1-dev \
|
||||
libglib2.0-dev \
|
||||
libdbus-1-3 \
|
||||
libgtk-3-0 \
|
||||
libnss3 \
|
||||
libatk-bridge2.0-0 \
|
||||
libatk1.0-0 \
|
||||
libx11-xcb1 \
|
||||
libxcb-dri3-0 \
|
||||
libxtst6 \
|
||||
libxss1 \
|
||||
libasound2 \
|
||||
libgbm1
|
||||
|
||||
if [ "$SETUP_DESKTOP_NATIVE" = "yes" ]; then
|
||||
# Install Rust nightly toolchain (required for desktop native module)
|
||||
echo "Installing Rust nightly toolchain..."
|
||||
rustup toolchain install nightly
|
||||
|
||||
# Install cargo tools for pre-commit hooks (optional but recommended)
|
||||
echo "Installing cargo tools for pre-commit hooks..."
|
||||
cargo install cargo-sort cargo-udeps cargo-deny
|
||||
fi
|
||||
|
||||
if [ "$SETUP_MKCERT" = "yes" ]; then
|
||||
# Install mkcert for SSL certificates (needed for WebAuthn)
|
||||
echo "Installing mkcert..."
|
||||
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
|
||||
chmod +x mkcert-v*-linux-amd64
|
||||
sudo mv mkcert-v*-linux-amd64 /usr/local/bin/mkcert
|
||||
|
||||
# Generate SSL certificates for localhost
|
||||
echo "Generating SSL certificates..."
|
||||
mkcert -install
|
||||
cd /workspace/apps/web
|
||||
mkcert -cert-file dev-server.local.pem -key-file dev-server.local.pem localhost bitwarden.test
|
||||
cd /workspace
|
||||
fi
|
||||
|
||||
if [ "$RUN_NPM_CI" = "yes" ]; then
|
||||
# Install npm dependencies
|
||||
echo "Running npm ci..."
|
||||
npm ci
|
||||
fi
|
||||
|
||||
echo "postCreateCommand.sh completed"
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Bitwarden Clients",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"name": "Bitwarden Clients (macOS XQuartz)",
|
||||
"dockerComposeFile": ["../common/docker-compose.yml", "docker-compose.override.yml"],
|
||||
"service": "bitwarden_clients",
|
||||
"workspaceFolder": "/workspace",
|
||||
"features": {
|
||||
@@ -8,7 +8,6 @@
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"settings": {},
|
||||
"extensions": [
|
||||
"angular.ng-template",
|
||||
"orta.vscode-jest",
|
||||
@@ -19,23 +18,12 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh",
|
||||
"postCreateCommand": "bash .devcontainer/common/postCreateCommand.sh",
|
||||
"forwardPorts": [8080, 8081, 6006],
|
||||
"portsAttributes": {
|
||||
"default": {
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"8080": {
|
||||
"label": "Web Vault",
|
||||
"onAutoForward": "notify"
|
||||
},
|
||||
"8081": {
|
||||
"label": "Web Vault (Self-hosted)",
|
||||
"onAutoForward": "notify"
|
||||
},
|
||||
"6006": {
|
||||
"label": "Storybook",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
"default": { "onAutoForward": "ignore" },
|
||||
"8080": { "label": "Web Vault", "onAutoForward": "notify" },
|
||||
"8081": { "label": "Web Vault (Self-hosted)", "onAutoForward": "notify" },
|
||||
"6006": { "label": "Storybook", "onAutoForward": "notify" }
|
||||
}
|
||||
}
|
||||
4
.devcontainer/macos-xquartz/docker-compose.override.yml
Normal file
4
.devcontainer/macos-xquartz/docker-compose.override.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
services:
|
||||
bitwarden_clients:
|
||||
environment:
|
||||
- DISPLAY=host.docker.internal:0
|
||||
30
.devcontainer/native-gui/devcontainer.json
Normal file
30
.devcontainer/native-gui/devcontainer.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "Bitwarden Clients (Windows / Linux)",
|
||||
"dockerComposeFile": ["../common/docker-compose.yml", "docker-compose.override.yml"],
|
||||
"service": "bitwarden_clients",
|
||||
"workspaceFolder": "/workspace",
|
||||
"initializeCommand": "bash .devcontainer/native-gui/setup-x11.sh",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/rust:1": {}
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"angular.ng-template",
|
||||
"orta.vscode-jest",
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"nrwl.angular-console",
|
||||
"bradlc.vscode-tailwindcss"
|
||||
]
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "bash .devcontainer/common/postCreateCommand.sh",
|
||||
"forwardPorts": [8080, 8081, 6006],
|
||||
"portsAttributes": {
|
||||
"default": { "onAutoForward": "ignore" },
|
||||
"8080": { "label": "Web Vault", "onAutoForward": "notify" },
|
||||
"8081": { "label": "Web Vault (Self-hosted)", "onAutoForward": "notify" },
|
||||
"6006": { "label": "Storybook", "onAutoForward": "notify" }
|
||||
}
|
||||
}
|
||||
32
.devcontainer/native-gui/setup-x11.sh
Executable file
32
.devcontainer/native-gui/setup-x11.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# Generates docker-compose.override.yml for X11 forwarding
|
||||
# Detects Windows (WSL2) vs native Linux
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
OVERRIDE_FILE="$SCRIPT_DIR/docker-compose.override.yml"
|
||||
|
||||
if grep -qi microsoft /proc/version 2>/dev/null; then
|
||||
echo "Detected Windows (WSL2) - configuring WSLg..."
|
||||
cat > "$OVERRIDE_FILE" << 'EOF'
|
||||
services:
|
||||
bitwarden_clients:
|
||||
volumes:
|
||||
- /tmp/.X11-unix:/tmp/.X11-unix
|
||||
- /mnt/wslg:/mnt/wslg
|
||||
environment:
|
||||
- DISPLAY=${DISPLAY:-:0}
|
||||
- WAYLAND_DISPLAY=${WAYLAND_DISPLAY:-wayland-0}
|
||||
- XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/mnt/wslg/runtime-dir}
|
||||
- PULSE_SERVER=${PULSE_SERVER:-/mnt/wslg/PulseServer}
|
||||
EOF
|
||||
else
|
||||
echo "Detected Linux - configuring X11..."
|
||||
cat > "$OVERRIDE_FILE" << 'EOF'
|
||||
services:
|
||||
bitwarden_clients:
|
||||
volumes:
|
||||
- /tmp/.X11-unix:/tmp/.X11-unix
|
||||
environment:
|
||||
- DISPLAY=${DISPLAY:-:0}
|
||||
EOF
|
||||
fi
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "Running postCreateCommand.sh"
|
||||
|
||||
# Configure git safe directory
|
||||
git config --global --add safe.directory /workspace
|
||||
|
||||
# Install mkcert for SSL certificates (needed for WebAuthn)
|
||||
echo "Installing mkcert..."
|
||||
sudo apt-get update && sudo apt-get install -y libnss3-tools
|
||||
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
|
||||
chmod +x mkcert-v*-linux-amd64
|
||||
sudo mv mkcert-v*-linux-amd64 /usr/local/bin/mkcert
|
||||
|
||||
# Generate SSL certificates for localhost
|
||||
echo "Generating SSL certificates..."
|
||||
mkcert -install
|
||||
cd /workspace/apps/web
|
||||
mkcert -cert-file dev-server.local.pem -key-file dev-server.local.pem localhost bitwarden.test
|
||||
cd /workspace
|
||||
|
||||
# Install npm dependencies
|
||||
echo "Running npm ci..."
|
||||
npm ci
|
||||
|
||||
echo "postCreateCommand.sh completed"
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -56,3 +56,7 @@ apps/**/config/local.json
|
||||
|
||||
# Nx
|
||||
.nx
|
||||
|
||||
# DevContainer generated files
|
||||
.devcontainer/native-gui/docker-compose.override.yml
|
||||
.devcontainer/common/.env
|
||||
|
||||
Reference in New Issue
Block a user