Skip to content

Commit 250b2f3

Browse files
committed
requirements update & fix
1 parent 31edc83 commit 250b2f3

5 files changed

Lines changed: 130 additions & 10 deletions

File tree

.dockerignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Dependencies
2+
node_modules
3+
npm-debug.log
4+
yarn-error.log
5+
6+
# Build files
7+
/dist
8+
/build
9+
.serverless/
10+
11+
# Environment variables
12+
.env
13+
.env.*
14+
!.env.example
15+
16+
# IDE and editor files
17+
.vscode/
18+
.idea/
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?
24+
25+
# OS generated files
26+
.DS_Store
27+
.DS_Store?
28+
._*
29+
.Spotlight-V100
30+
.Trashes
31+
ehthumbs.db
32+
Thumbs.db
33+
34+
# Debug logs
35+
npm-debug.log*
36+
yarn-debug.log*
37+
yarn-error.log*
38+
39+
# Local development
40+
coverage/
41+
.nyc_output/
42+
43+
# Server specific
44+
server/lynx.db
45+
server/lynx.db-journal
46+
47+
# Test files
48+
**/__tests__/**
49+
**/*.test.*
50+
**/*.spec.*
51+
52+
# Local development
53+
.cache/
54+
.temp/
55+
.tmp/

.env.example

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Required Environment Variables
2+
NODE_ENV=production
3+
PORT=8080
4+
5+
# Security
6+
COOKIE_SECRET=your-secure-cookie-secret-here
7+
JWT_SECRET=your-jwt-secret-here
8+
9+
# Frontend Configuration
10+
FRONTEND_URL=http://localhost:3000
11+
12+
# Database Configuration (SQLite is used by default)
13+
# DATABASE_URL=sqlite:./lynx.db
14+
15+
# Optional: Enable detailed logging
16+
# DEBUG=app:*,server:*
17+
18+
# Optional: Rate limiting configuration
19+
# RATE_LIMIT_WINDOW_MS=900000 # 15 minutes
20+
# RATE_LIMIT_MAX=300 # Max requests per window
21+
22+
# Optional: CORS configuration
23+
# CORS_ORIGIN=http://localhost:3000
24+
25+
# Optional: Session configuration
26+
# SESSION_SECURE=true
27+
# SAME_SITE=strict
28+
29+
# Note: Never commit actual secrets to version control!
30+
# Create a .env file with your actual values and add it to .gitignore

Dockerfile

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,44 @@
22
FROM node:18-slim AS builder
33
WORKDIR /app
44

5-
# Dev deps incluse per poter fare vite build
5+
# Install frontend dependencies and build
66
COPY package*.json ./
77
RUN npm ci
88

9-
# Copia sorgenti e builda il frontend (Vite)
9+
# Copy source and build frontend (Vite)
1010
COPY . .
1111
RUN npm run build
1212

13-
# Installa solo le prod deps del server
13+
# Set up server dependencies
1414
WORKDIR /app/server
15+
COPY server/package*.json ./
1516
RUN npm ci --omit=dev
1617

18+
# Copy built frontend to server's public directory
19+
RUN mkdir -p public
20+
RUN cp -r ../dist/* public/
21+
1722
# ---------- STAGE 2: runtime ----------
1823
FROM node:18-slim
1924
WORKDIR /app
25+
26+
# Set production environment
2027
ENV NODE_ENV=production
2128
ENV PORT=8080
2229

23-
# porta solo ciò che serve
24-
COPY --from=builder /app/dist /app/dist
25-
COPY --from=builder /app/server /app/server
30+
# Install production dependencies
31+
COPY --from=builder /app/server/package*.json ./
32+
COPY --from=builder /app/server/node_modules ./node_modules
33+
34+
# Copy built application
35+
COPY --from=builder /app/server .
2636

27-
# Il server ha già le sue dipendenze in /app/server/node_modules
37+
# Expose port
2838
EXPOSE 8080
2939

30-
# Avvia direttamente il server (che ascolta su 8080)
31-
WORKDIR /app/server
32-
CMD ["npm","start"]
40+
# Health check
41+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
42+
CMD curl -f http://localhost:8080/ || exit 1
43+
44+
# Start the server
45+
CMD ["node", "server.js"]

server/package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"express-rate-limit": "^7.2.0",
1919
"helmet": "^7.1.0",
2020
"jsonwebtoken": "^9.0.2",
21+
"lusca": "^1.7.0",
2122
"multer": "^1.4.5-lts.1",
2223
"sqlite3": "^5.1.6",
2324
"zod": "^3.23.8"

0 commit comments

Comments
 (0)