Files
balikci/Dockerfile

56 lines
1.3 KiB
Docker
Raw Normal View History

2025-11-11 07:31:43 +03:00
# Multi-stage build for Oltalama application
# Stage 1: Build frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package*.json ./
# Install frontend dependencies
2025-11-11 07:33:24 +03:00
RUN npm install
2025-11-11 07:31:43 +03:00
# Copy frontend source
COPY frontend/ ./
# Build frontend (output will be in dist/)
RUN npm run build
# Stage 2: Backend + Runtime
FROM node:20-alpine
WORKDIR /app
# Install system dependencies for sqlite3
RUN apk add --no-cache python3 make g++ sqlite
# Copy backend package files
COPY backend/package*.json ./
2025-11-11 07:33:24 +03:00
# Install backend dependencies (production only)
RUN npm install --only=production
2025-11-11 07:31:43 +03:00
# Copy backend source
COPY backend/ ./
# Copy frontend build from previous stage to backend public directory
COPY --from=frontend-builder /app/frontend/dist ./src/public/dist
# Create database directory
RUN mkdir -p database
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start script that runs migrations and seeds before starting the server
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "src/app.js"]