Files
api_builder/Dockerfile
eshmeshek 9a08396610 new file: .dockerignore
new file:   .env.example
	new file:   Dockerfile
	modified:   backend/.env.example
	modified:   backend/package.json
	renamed:    backend/src/migrations/run.ts -> backend/src/scripts/run.ts
	renamed:    backend/src/migrations/seed.ts -> backend/src/scripts/seed.ts
	new file:   docker-compose.external-db.yml
	new file:   docker-compose.yml
2025-12-18 13:01:25 +03:00

69 lines
1.5 KiB
Docker

# ============================================
# Stage 1: Build Frontend
# ============================================
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package*.json ./
# Install dependencies
RUN npm ci
# Copy frontend source
COPY frontend/ ./
# Build frontend
RUN npm run build
# ============================================
# Stage 2: Build Backend
# ============================================
FROM node:20-alpine AS backend-builder
WORKDIR /app/backend
# Copy backend package files
COPY backend/package*.json ./
# Install dependencies
RUN npm ci
# Copy backend source
COPY backend/ ./
# Build TypeScript
RUN npm run build
# ============================================
# Stage 3: Production
# ============================================
FROM node:20-alpine AS production
WORKDIR /app
# Copy backend package files and install production deps
COPY backend/package*.json ./
RUN npm ci --only=production && npm cache clean --force
# Copy built backend
COPY --from=backend-builder /app/backend/dist ./dist
# Copy built frontend to the location expected by backend
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# Set environment
ENV NODE_ENV=production
ENV PORT=3000
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
# Start the application
CMD ["node", "dist/server.js"]