diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..a5605fb --- /dev/null +++ b/.env.example @@ -0,0 +1,17 @@ +# Copy this file to .env and fill in values before running locally +# In Docker/Unraid, set these as container environment variables instead + +# Admin credentials +ADMIN_USERNAME=admin +ADMIN_PASSWORD_HASH= # Generate with: npx ts-node scripts/hashPassword.ts yourpassword + +# JWT +JWT_SECRET= # Min 32 random chars — generate with: openssl rand -hex 32 +JWT_EXPIRY=8h + +# Database (relative path inside container; bind-mounted to ./data/) +DATABASE_URL=file:./data/rackmapper.db + +# Server +PORT=3001 +NODE_ENV=development diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7d3bcb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Dependencies +node_modules/ +client/node_modules/ + +# Environment - never commit secrets +.env +.env.local +.env.*.local + +# Build output +dist/ +client/dist/ + +# Database - persisted via Docker volume +data/ +*.db +*.db-journal +*.db-wal +*.db-shm + +# Prisma generated client (regenerated on build) +node_modules/.prisma/ + +# Logs +logs/ +*.log +npm-debug.log* + +# OS +.DS_Store +Thumbs.db + +# Editor +.vscode/ +.idea/ +*.swp +*.swo + +# Test coverage +coverage/ + +# TypeScript incremental build info +*.tsbuildinfo diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..a95cb05 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "semi": true, + "singleQuote": true, + "trailingComma": "es5", + "printWidth": 100, + "tabWidth": 2 +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b94f7d0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM node:20-alpine + +WORKDIR /app + +# Install build tools needed for better-sqlite3 native bindings +RUN apk add --no-cache python3 make g++ + +# Copy package manifests +COPY package*.json ./ +COPY client/package*.json ./client/ + +# Install all dependencies (dev deps needed for prisma CLI + tsc build) +RUN npm install +RUN cd client && npm install + +# Copy source +COPY . . + +# Generate Prisma client for target platform (must happen before tsc) +RUN npx prisma generate + +# Build server (tsc) + client (vite) +RUN npm run build + +# Ensure data directory exists for SQLite bind mount +RUN mkdir -p /app/data + +EXPOSE 3001 + +# Apply pending migrations then start +CMD ["sh", "-c", "npx prisma migrate deploy && node dist/server/index.js"] diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..e7529c3 --- /dev/null +++ b/client/index.html @@ -0,0 +1,13 @@ + + +
+ + +Network infrastructure management
++ Credentials are set via Docker environment variables. +
+No map selected
++ Select a map from the toolbar or create a new one. +
+No racks yet
++ Click Add Rack in the toolbar to create your first rack. +
+{message}
+