feature updates
This commit is contained in:
57
server/Dockerfile
Normal file
57
server/Dockerfile
Normal file
@@ -0,0 +1,57 @@
|
||||
# Build stage
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
COPY tsconfig.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy source code
|
||||
COPY src/ ./src/
|
||||
|
||||
# Generate Prisma client
|
||||
RUN npx prisma generate --schema=src/db/schema.prisma
|
||||
|
||||
# Build TypeScript
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install curl for healthcheck
|
||||
RUN apk add --no-cache curl
|
||||
|
||||
# Copy package files and install production dependencies only
|
||||
COPY package*.json ./
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy Prisma schema for migrations
|
||||
COPY src/db/schema.prisma ./prisma/schema.prisma
|
||||
|
||||
# Generate Prisma client in production image
|
||||
RUN npx prisma generate --schema=prisma/schema.prisma
|
||||
|
||||
# Copy built files
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# Create startup script
|
||||
RUN echo '#!/bin/sh' > /app/start.sh && \
|
||||
echo 'npx prisma db push --schema=prisma/schema.prisma --accept-data-loss' >> /app/start.sh && \
|
||||
echo 'node dist/index.js' >> /app/start.sh && \
|
||||
chmod +x /app/start.sh
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 3000 3001
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:3000/health || exit 1
|
||||
|
||||
# Start server
|
||||
CMD ["/app/start.sh"]
|
||||
Reference in New Issue
Block a user