clients/.devcontainer/common/post-create-command.sh
Conner Turnbull c017802c92
Added devcontainer setup (devcontainer.json, docker-compose.yml, postCreateCommand.sh) (#18541)
* Added devcontainer setup (devcontainer.json, docker-compose.yml, postCreateCommand.sh)

* Restructure devcontainers with browser-gui, native-gui variants and shared config

* Rename postCreateCommand.sh to kebab-case

* Updated dev container name to appear under the `bitwarden_common` docker compose stack

* Exclude .devcontainer from Checkmarx KICS scans

* Add sca and containers filters for Checkmarx

* Remove sca and containers filters from Checkmarx config

* Revert "Remove sca and containers filters from Checkmarx config"

This reverts commit 4eb4c0c124.

* Mask node_modules and Rust target from host sync in devcontainer

* Fix ownership of anonymous volume mount points in devcontainer

* Build desktop native module in devcontainer post-create script

* Fix Checkmarx config filters to use glob pattern for .devcontainer

* Revert "Fix Checkmarx config filters to use glob pattern for .devcontainer"

This reverts commit ab1c70fcf6.

---------

Co-authored-by: Amy Galles <9685081+AmyLGalles@users.noreply.github.com>
2026-04-08 15:58:05 -04:00

80 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
echo "Running post-create-command.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_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
# Fix ownership of anonymous volume mount points (created as root by Docker)
sudo chown node:node /workspace/node_modules /workspace/apps/desktop/desktop_native/target
if [ "$RUN_NPM_CI" = "yes" ]; then
# Install npm dependencies
echo "Running npm ci..."
npm ci
fi
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
# Build the desktop native module
echo "Building desktop native module..."
cd /workspace/apps/desktop/desktop_native/napi
npm run build
cd /workspace
fi
echo "post-create-command.sh completed"