fix: remove nginx, serve frontend from Express on port 3000, fix static path
This commit is contained in:
+4
-7
@@ -18,11 +18,11 @@ COPY backend/ ./
|
||||
RUN npx prisma generate --schema=src/prisma/schema.prisma
|
||||
RUN npm run build
|
||||
|
||||
# Stage 3: Production (Debian slim to match build stage, avoiding Alpine musl/OpenSSL issues)
|
||||
# Stage 3: Production (Debian slim — same glibc as build, no musl/OpenSSL issues)
|
||||
FROM node:20-slim
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y nginx openssl --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y openssl --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy backend
|
||||
COPY --from=backend-build /app/backend/dist ./dist
|
||||
@@ -30,15 +30,12 @@ COPY --from=backend-build /app/backend/node_modules ./node_modules
|
||||
COPY --from=backend-build /app/backend/src/prisma ./prisma
|
||||
COPY backend/package.json ./package.json
|
||||
|
||||
# Copy frontend build
|
||||
# Copy frontend build — served by Express at /app/public
|
||||
COPY --from=frontend-build /app/frontend/dist ./public
|
||||
|
||||
# Nginx config
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
COPY start.sh ./
|
||||
RUN chmod +x start.sh
|
||||
|
||||
EXPOSE 80
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["./start.sh"]
|
||||
|
||||
@@ -22,7 +22,7 @@ import settingsRouter from './routes/settings';
|
||||
import notificationsRouter from './routes/notifications';
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 5000;
|
||||
const PORT = parseInt(process.env.PORT || '3000', 10);
|
||||
|
||||
// Security
|
||||
app.use(helmet({ contentSecurityPolicy: false }));
|
||||
@@ -71,7 +71,8 @@ app.use('/api/v1/settings', settingsRouter);
|
||||
app.use('/api/v1/notifications', notificationsRouter);
|
||||
|
||||
// Serve frontend in production
|
||||
const frontendDist = path.join(__dirname, '../../public');
|
||||
// __dirname = /app/dist, frontend is at /app/public
|
||||
const frontendDist = path.join(__dirname, '../public');
|
||||
app.use(express.static(frontendDist));
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(frontendDist, 'index.html'));
|
||||
|
||||
@@ -179,8 +179,5 @@ async function seed() {
|
||||
seed();
|
||||
" 2>/dev/null || echo "[start] Seed warning (continuing)"
|
||||
|
||||
echo "[start] Starting nginx..."
|
||||
nginx
|
||||
|
||||
echo "[start] Starting Node.js backend on port 5000..."
|
||||
echo "[start] Starting Node.js backend on port 3000..."
|
||||
exec node dist/index.js
|
||||
|
||||
Reference in New Issue
Block a user