docs: add comprehensive documentation
- Add README.md with project overview, features, quick start guide, project structure, environment variables, and scripts - Add docs/API.md with complete API reference for all endpoints - Add docs/DEPLOYMENT.md with production deployment guide covering PM2, Nginx, SSL, and Docker options - Add docker-compose.yml for containerized deployment - Add Dockerfile with multi-stage build for optimized production image - Add .dockerignore for efficient Docker builds Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
86
Dockerfile
Normal file
86
Dockerfile
Normal file
@@ -0,0 +1,86 @@
|
||||
# Dockerfile para Padel Pro
|
||||
# Multi-stage build para optimizar el tamano de la imagen
|
||||
|
||||
# ============================================
|
||||
# Stage 1: Dependencias
|
||||
# ============================================
|
||||
FROM node:20-alpine AS deps
|
||||
RUN apk add --no-cache libc6-compat
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Instalar pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@8.15.0 --activate
|
||||
|
||||
# Copiar archivos de configuracion de dependencias
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY apps/web/package.json ./apps/web/
|
||||
COPY packages/shared/package.json ./packages/shared/
|
||||
|
||||
# Instalar dependencias
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# ============================================
|
||||
# Stage 2: Builder
|
||||
# ============================================
|
||||
FROM node:20-alpine AS builder
|
||||
RUN apk add --no-cache libc6-compat
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Instalar pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@8.15.0 --activate
|
||||
|
||||
# Copiar dependencias instaladas
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY --from=deps /app/apps/web/node_modules ./apps/web/node_modules
|
||||
COPY --from=deps /app/packages/shared/node_modules ./packages/shared/node_modules
|
||||
|
||||
# Copiar codigo fuente
|
||||
COPY . .
|
||||
|
||||
# Generar cliente Prisma
|
||||
RUN cd apps/web && pnpm db:generate
|
||||
|
||||
# Construir la aplicacion
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
RUN pnpm build
|
||||
|
||||
# ============================================
|
||||
# Stage 3: Runner (Produccion)
|
||||
# ============================================
|
||||
FROM node:20-alpine AS runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Configurar entorno de produccion
|
||||
ENV NODE_ENV production
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
# Crear usuario no-root
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
|
||||
# Copiar archivos necesarios para produccion
|
||||
COPY --from=builder /app/apps/web/public ./apps/web/public
|
||||
|
||||
# Copiar archivos de Next.js standalone
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
|
||||
|
||||
# Copiar schema de Prisma para migraciones
|
||||
COPY --from=builder /app/apps/web/prisma ./apps/web/prisma
|
||||
COPY --from=builder /app/apps/web/node_modules/.prisma ./apps/web/node_modules/.prisma
|
||||
COPY --from=builder /app/apps/web/node_modules/@prisma ./apps/web/node_modules/@prisma
|
||||
|
||||
# Cambiar a usuario no-root
|
||||
USER nextjs
|
||||
|
||||
# Exponer puerto
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT 3000
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
|
||||
# Comando de inicio
|
||||
CMD ["node", "apps/web/server.js"]
|
||||
Reference in New Issue
Block a user