Skip to content

Commit 8d0cf6e

Browse files
committed
feat: add Dockerfile and devcontainer configuration for Node SQLite development environment
1 parent 478dded commit 8d0cf6e

File tree

3 files changed

+140
-0
lines changed

3 files changed

+140
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Use the official Node.js dev container base image
2+
FROM mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm
3+
4+
# Install additional dependencies for building native modules
5+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
6+
&& apt-get -y install --no-install-recommends \
7+
build-essential \
8+
python3 \
9+
python3-pip \
10+
python3-dev \
11+
cmake \
12+
ninja-build \
13+
ccache \
14+
clang-tidy \
15+
clang-format \
16+
valgrind \
17+
gdb \
18+
&& apt-get clean \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# Install node-gyp globally
22+
RUN npm install -g node-gyp@latest
23+
24+
# Set up ccache for faster C++ compilation
25+
ENV PATH="/usr/lib/ccache:${PATH}"
26+
ENV CCACHE_DIR="/workspaces/.ccache"
27+
28+
# Configure git to trust the workspace directory
29+
RUN git config --global --add safe.directory /workspaces/*
30+
31+
# Set the default shell to zsh
32+
ENV SHELL=/bin/zsh

.devcontainer/devcontainer.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"name": "Node SQLite Development Container",
3+
"dockerFile": "Dockerfile",
4+
5+
// Features to add to the dev container
6+
"features": {
7+
"ghcr.io/devcontainers/features/git:1": {},
8+
"ghcr.io/devcontainers/features/github-cli:1": {},
9+
"ghcr.io/devcontainers/features/common-utils:2": {
10+
"configureZshAsDefaultShell": true
11+
},
12+
"ghcr.io/devcontainers/features/python:1": {
13+
"version": "3.11"
14+
}
15+
},
16+
17+
// Configure tool-specific properties
18+
"customizations": {
19+
"vscode": {
20+
"extensions": [
21+
"dbaeumer.vscode-eslint",
22+
"esbenp.prettier-vscode",
23+
"ms-vscode.cpptools",
24+
"ms-vscode.cpptools-extension-pack",
25+
"streetsidesoftware.code-spell-checker",
26+
"wayou.vscode-todo-highlight",
27+
"gruntfuggly.todo-tree",
28+
"yzhang.markdown-all-in-one",
29+
"bierner.markdown-mermaid",
30+
"usernamehw.errorlens"
31+
],
32+
"settings": {
33+
"terminal.integrated.defaultProfile.linux": "zsh",
34+
"editor.formatOnSave": true,
35+
"editor.codeActionsOnSave": {
36+
"source.fixAll.eslint": "explicit"
37+
},
38+
"eslint.validate": [
39+
"javascript",
40+
41+
"javascriptreact",
42+
"typescript",
43+
"typescriptreact"
44+
],
45+
"files.associations": {
46+
"*.gyp": "python",
47+
"*.gypi": "python"
48+
},
49+
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
50+
}
51+
}
52+
},
53+
54+
// Use 'forwardPorts' to make a list of ports inside the container available locally
55+
"forwardPorts": [],
56+
57+
// Use 'postCreateCommand' to run commands after the container is created
58+
"postCreateCommand": "bash .devcontainer/post-create.sh",
59+
60+
// Set environment variables
61+
"containerEnv": {
62+
"NODE_ENV": "development"
63+
},
64+
65+
// Configure mounts
66+
"mounts": [
67+
// Mount npm cache for faster rebuilds
68+
"source=${localEnv:HOME}/.npm,target=/home/vscode/.npm,type=bind,consistency=cached"
69+
],
70+
71+
// Run as non-root user
72+
"remoteUser": "vscode"
73+
}

.devcontainer/post-create.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "🚀 Setting up Node SQLite development environment..."
5+
6+
# Install npm dependencies
7+
echo "📦 Installing npm dependencies..."
8+
npm install
9+
10+
# Build the native module
11+
echo "🔨 Building native module..."
12+
npm run build:native
13+
14+
# Run initial build
15+
echo "🏗️ Running TypeScript build..."
16+
npm run build
17+
18+
# Set up git hooks if available
19+
if [ -f "scripts/precommit.ts" ]; then
20+
echo "🪝 Setting up git hooks..."
21+
npx husky install 2>/dev/null || true
22+
fi
23+
24+
# Create ccache directory if it doesn't exist
25+
mkdir -p /workspaces/.ccache
26+
27+
echo "✅ Development environment setup complete!"
28+
echo ""
29+
echo "Available npm scripts:"
30+
echo " npm test - Run tests"
31+
echo " npm run build - Build TypeScript and native code"
32+
echo " npm run lint - Run linter"
33+
echo " npm run docs - Generate documentation"
34+
echo ""
35+
echo "For more information, see README.md"

0 commit comments

Comments
 (0)