feat: Initialize NxMesh project with Docker, Nginx, PostgreSQL, and Rust backend
- Add Docker Compose configuration for development environment - Create Nginx configuration files for routing and health checks - Set up PostgreSQL database with health checks - Add .dockerignore and .gitignore files to exclude unnecessary files - Initialize Cargo.toml and Cargo.lock for Rust dependencies - Include GNU General Public License for project - Add README.md for project description - Create Justfile for development workflow commands
This commit is contained in:
10
.devcontainer/.env.example
Normal file
10
.devcontainer/.env.example
Normal file
@@ -0,0 +1,10 @@
|
||||
# Environment Configuration for NxMesh Development
|
||||
# Copy this file to .env and customize as needed
|
||||
|
||||
# Database
|
||||
DATABASE_URL=postgres://postgres:postgres@postgres:5432/nxmesh
|
||||
PGHOST=postgres
|
||||
PGPORT=5432
|
||||
PGUSER=postgres
|
||||
PGPASSWORD=postgres
|
||||
PGDATABASE=nxmesh
|
||||
1
.devcontainer/.gitignore
vendored
Normal file
1
.devcontainer/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.env
|
||||
19
.devcontainer/Dockerfile
Normal file
19
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04
|
||||
|
||||
# Avoid prompts from apt
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install system dependencies that don't have devcontainer features
|
||||
RUN apt-get update && apt-get install -y \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
postgresql-client \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /workspace
|
||||
|
||||
# Note: Rust, Bun, and just are installed via devcontainer features
|
||||
# cargo-binstall, cargo-watch, cargo-edit, and sea-orm-cli are installed via postCreateCommand
|
||||
|
||||
CMD [ "sleep", "infinity" ]
|
||||
80
.devcontainer/devcontainer.json
Normal file
80
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"name": "NxMesh Dev Environment",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"service": "app",
|
||||
"workspaceFolder": "/workspace",
|
||||
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {
|
||||
"version": "latest",
|
||||
"enableNonRootDocker": "true",
|
||||
"moby": "true"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/common-utils:2": {
|
||||
"installZsh": "true",
|
||||
"username": "vscode",
|
||||
"userUid": "1000",
|
||||
"userGid": "1000",
|
||||
"upgradePackages": "true"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/rust:1": {
|
||||
"version": "stable",
|
||||
"profile": "default",
|
||||
"cargoHome": "/usr/local/cargo"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "lts",
|
||||
"nodeGypDependencies": true,
|
||||
"nvmInstallPath": "/usr/local/share/nvm"
|
||||
},
|
||||
"ghcr.io/guiyomh/features/just:0": {},
|
||||
"ghcr.io/devcontainers-extra/features/bun": {
|
||||
"version": "latest"
|
||||
}
|
||||
},
|
||||
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"rust-lang.rust-analyzer",
|
||||
"vadimcn.vscode-lldb",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"ms-azuretools.vscode-docker",
|
||||
"nefrob.vscode-just-syntax"
|
||||
],
|
||||
"settings": {
|
||||
"rust-analyzer.cargo.features": "all",
|
||||
// both clippy and fmt
|
||||
"rust-analyzer.checkOnSave.command": "clippy"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"forwardPorts": [3000, 8080, 5432, 80, 443],
|
||||
"portsAttributes": {
|
||||
"3000": {
|
||||
"label": "Vite Dev Server",
|
||||
"onAutoForward": "notify"
|
||||
},
|
||||
"8080": {
|
||||
"label": "Rust Backend API",
|
||||
"onAutoForward": "notify"
|
||||
},
|
||||
"5432": {
|
||||
"label": "PostgreSQL",
|
||||
"onAutoForward": "silent"
|
||||
},
|
||||
"80": {
|
||||
"label": "Nginx",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
|
||||
"postCreateCommand": "just setup",
|
||||
"postStartCommand": "just start-services",
|
||||
|
||||
"remoteUser": "vscode",
|
||||
"updateRemoteUserUID": true
|
||||
}
|
||||
69
.devcontainer/docker-compose.yml
Normal file
69
.devcontainer/docker-compose.yml
Normal file
@@ -0,0 +1,69 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# Development environment - Control Plane (Rust backend + Vite frontend)
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- ..:/workspace:cached
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/nxmesh
|
||||
- RUST_LOG=debug
|
||||
- RUST_BACKTRACE=1
|
||||
- NODE_ENV=development
|
||||
ports:
|
||||
- "3000:3000" # Vite dev server
|
||||
- "8080:8080" # Rust backend (Control Plane)
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
command: sleep infinity
|
||||
networks:
|
||||
- nxmesh-network
|
||||
group_add:
|
||||
- docker
|
||||
pid: "service:nginx"
|
||||
|
||||
# Data Plane - Nginx (controlled by agent via Docker)
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: nxmesh-nginx
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./nginx/conf.d:/etc/nginx/conf.d:ro
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
networks:
|
||||
- nxmesh-network
|
||||
|
||||
# Database
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: nxmesh
|
||||
ports:
|
||||
- "5432:5432"
|
||||
healthcheck:
|
||||
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- nxmesh-network
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
|
||||
networks:
|
||||
nxmesh-network:
|
||||
20
.devcontainer/nginx/conf.d/default.conf
Normal file
20
.devcontainer/nginx/conf.d/default.conf
Normal file
@@ -0,0 +1,20 @@
|
||||
# Default nginx configuration
|
||||
# The agent can dynamically modify this to route traffic as needed
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
# Default health check
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "nginx ok\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
# Default stub - agent configures actual routing
|
||||
location / {
|
||||
return 200 "NxMesh Data Plane\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
38
.devcontainer/nginx/nginx.conf
Normal file
38
.devcontainer/nginx/nginx.conf
Normal file
@@ -0,0 +1,38 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Docker internal DNS resolver for dynamic upstreams
|
||||
resolver 127.0.0.11 valid=30s;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
client_max_body_size 100M;
|
||||
|
||||
# Gzip compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
|
||||
|
||||
# Include server configurations
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
Reference in New Issue
Block a user