Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e8bec949b | |||
| 888834c8f0 | |||
| ae8f6d696e |
+2
-1
@@ -36,8 +36,9 @@ COPY package*.json ./
|
||||
# Install production dependencies only
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy prisma schema and migrations
|
||||
# Copy prisma schema and migrations for runtime and hydration template
|
||||
COPY prisma ./prisma/
|
||||
COPY prisma ./prisma_template/
|
||||
|
||||
# Copy built application from builder
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Auto-hydrate prisma directory when bind-mounted volume is empty
|
||||
if [ ! -f "/app/prisma/schema.prisma" ]; then
|
||||
echo "Mount is empty. Hydrating /app/prisma from /app/prisma_template..."
|
||||
cp -R /app/prisma_template/. /app/prisma/
|
||||
fi
|
||||
|
||||
# Run migrations
|
||||
npx prisma migrate deploy
|
||||
|
||||
|
||||
+23
-1
@@ -77,7 +77,13 @@ const prisma = new PrismaClient();
|
||||
const PORT = process.env.PORT || 8000;
|
||||
|
||||
// Multer setup for file uploads
|
||||
const upload = multer({ dest: uploadDir });
|
||||
const upload = multer({
|
||||
dest: uploadDir,
|
||||
limits: {
|
||||
fileSize: 50 * 1024 * 1024, // 50MB in bytes
|
||||
files: 1, // Only one file per upload
|
||||
},
|
||||
});
|
||||
|
||||
app.use(
|
||||
cors({
|
||||
@@ -88,6 +94,22 @@ app.use(
|
||||
app.use(express.json({ limit: "50mb" }));
|
||||
app.use(express.urlencoded({ extended: true, limit: "50mb" }));
|
||||
|
||||
// Log large requests for monitoring and debugging
|
||||
app.use((req, res, next) => {
|
||||
const contentLength = req.headers["content-length"];
|
||||
if (contentLength) {
|
||||
const sizeInMB = parseInt(contentLength) / 1024 / 1024;
|
||||
if (sizeInMB > 10) {
|
||||
console.log(
|
||||
`[LARGE REQUEST] ${req.method} ${req.path} - ${sizeInMB.toFixed(
|
||||
2
|
||||
)}MB - Content-Length: ${contentLength} bytes`
|
||||
);
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
const elementsSchema = z.array(z.object({}).passthrough());
|
||||
|
||||
const appStateSchema = z.object({}).passthrough();
|
||||
|
||||
@@ -12,6 +12,9 @@ http {
|
||||
gzip_vary on;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
# Set maximum request body size to 50MB to handle large drawings with embedded images
|
||||
client_max_body_size 50M;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
@@ -29,6 +32,18 @@ http {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Buffer and timeout settings for large payloads
|
||||
proxy_buffering on;
|
||||
proxy_buffer_size 4k;
|
||||
proxy_buffers 8 4k;
|
||||
proxy_busy_buffers_size 8k;
|
||||
client_body_buffer_size 128k;
|
||||
|
||||
# Timeouts for large uploads (300 seconds)
|
||||
proxy_connect_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
|
||||
# WebSocket proxy for Socket.IO
|
||||
|
||||
Reference in New Issue
Block a user