This commit is contained in:
Milo Schwartz 2024-09-28 22:50:20 -04:00
commit 30a3ceb2f3
No known key found for this signature in database
9 changed files with 164 additions and 13 deletions

25
.dockerignore Normal file
View file

@ -0,0 +1,25 @@
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
/coverage
/.next/
/out/
/build
.DS_Store
*.pem
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.env*.local
.env
.vercel
*.tsbuildinfo
next-env.d.ts
*.db
*.sqlite
*.sqlite3
*.log
.machinelogs*.json
*-audit.json
config

7
.env-docker Normal file
View file

@ -0,0 +1,7 @@
ENVIRONMENT=prod
LOG_LEVEL=debug
SAVE_LOGS=
PORT=3000
INTERNAL_PORT=3001
CONFIG_PATH=/config
API_VERSION=v1

38
Dockerfile Normal file
View file

@ -0,0 +1,38 @@
# Stage 1: Build the application
FROM node:18-alpine AS builder
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy the rest of the application code
COPY . .
# Build the Next.js application and compile TypeScript
RUN npm run build
# Stage 2: Run the application
FROM node:18-alpine AS runner
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install only production dependencies
RUN npm ci --only=production
# Copy built application from the builder stage
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/dist ./dist
# Expose the ports the app runs on
EXPOSE ${EXTERNAL_PORT}
EXPOSE ${INTERNAL_PORT}
# Start the application
CMD ["npm", "start"]

9
Makefile Normal file
View file

@ -0,0 +1,9 @@
all:
docker build -t pangolin .
test:
docker run -it -p 3000:3000 -p 3001:3001 --env-file=.env-docker -v ./config:/config pangolin
clean:
docker rmi pangolin

76
package-lock.json generated
View file

@ -35,6 +35,7 @@
"eslint-config-next": "14.2.13",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"tsc-alias": "1.8.10",
"tsx": "4.19.1",
"typescript": "^5"
}
@ -5968,8 +5969,7 @@
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"optional": true,
"peer": true,
"devOptional": true,
"engines": {
"node": ">=8"
}
@ -7452,8 +7452,7 @@
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
"optional": true,
"peer": true,
"devOptional": true,
"dependencies": {
"path-type": "^4.0.0"
},
@ -9498,8 +9497,7 @@
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
"optional": true,
"peer": true,
"devOptional": true,
"dependencies": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
@ -11439,6 +11437,19 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/mylas": {
"version": "2.1.13",
"resolved": "https://registry.npmjs.org/mylas/-/mylas-2.1.13.tgz",
"integrity": "sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg==",
"dev": true,
"engines": {
"node": ">=12.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/raouldeheer"
}
},
"node_modules/mz": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
@ -12259,8 +12270,7 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"optional": true,
"peer": true,
"devOptional": true,
"engines": {
"node": ">=8"
}
@ -12379,6 +12389,18 @@
"node": ">=4"
}
},
"node_modules/plimit-lit": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/plimit-lit/-/plimit-lit-1.6.1.tgz",
"integrity": "sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==",
"dev": true,
"dependencies": {
"queue-lit": "^1.5.1"
},
"engines": {
"node": ">=12"
}
},
"node_modules/plist": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/plist/-/plist-3.1.0.tgz",
@ -12818,6 +12840,15 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/queue-lit": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/queue-lit/-/queue-lit-1.5.2.tgz",
"integrity": "sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw==",
"dev": true,
"engines": {
"node": ">=12"
}
},
"node_modules/queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@ -13726,8 +13757,7 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"optional": true,
"peer": true,
"devOptional": true,
"engines": {
"node": ">=8"
}
@ -14618,6 +14648,32 @@
"integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==",
"devOptional": true
},
"node_modules/tsc-alias": {
"version": "1.8.10",
"resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.10.tgz",
"integrity": "sha512-Ibv4KAWfFkFdKJxnWfVtdOmB0Zi1RJVxcbPGiCDsFpCQSsmpWyuzHG3rQyI5YkobWwxFPEyQfu1hdo4qLG2zPw==",
"dev": true,
"dependencies": {
"chokidar": "^3.5.3",
"commander": "^9.0.0",
"globby": "^11.0.4",
"mylas": "^2.1.9",
"normalize-path": "^3.0.0",
"plimit-lit": "^1.2.6"
},
"bin": {
"tsc-alias": "dist/bin/index.js"
}
},
"node_modules/tsc-alias/node_modules/commander": {
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==",
"dev": true,
"engines": {
"node": "^12.20.0 || >=14"
}
},
"node_modules/tsconfig-paths": {
"version": "3.15.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz",

View file

@ -7,7 +7,9 @@
"db:generate": "drizzle-kit generate",
"db:push": "npx tsx scripts/migrate.ts",
"db:hydrate": "npx tsx scripts/hydrate.ts",
"db:studio": "drizzle-kit studio"
"db:studio": "drizzle-kit studio",
"build": "next build && tsc --project tsconfig.server.json && tsc-alias -p tsconfig.server.json",
"start": "NODE_ENV=production node dist/server/index.js"
},
"dependencies": {
"axios": "1.7.7",
@ -37,6 +39,7 @@
"eslint-config-next": "14.2.13",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"tsc-alias": "1.8.10",
"tsx": "4.19.1",
"typescript": "^5"
}

View file

@ -1,6 +1,5 @@
import { Request, Response, NextFunction } from 'express';
import { DrizzleError, eq } from 'drizzle-orm';
import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
import { sites, resources, targets, exitNodes } from '../../db/schema';
import db from '../../db';

View file

@ -7,7 +7,7 @@
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",

14
tsconfig.server.json Normal file
View file

@ -0,0 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"outDir": "./dist",
"noEmit": false,
"baseUrl": ".",
"paths": {
"@server/*": ["./server/*"]
}
},
"include": ["**/*.ts"]
}