feat: agregar agente docker para containerización
Nuevo agente para generar Dockerfiles y docker-compose. Incluye templates para Go, React/Vite, y stacks fullstack. Soporta desarrollo con hot reload y producción optimizada.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
# === BUILD STAGE ===
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Habilitar pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
||||
# Dependencias primero (mejor cache)
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Código fuente
|
||||
COPY . .
|
||||
|
||||
# Variables de entorno para build (pueden ser sobreescritas)
|
||||
ARG VITE_API_URL=/api
|
||||
ENV VITE_API_URL=$VITE_API_URL
|
||||
|
||||
# Build de producción
|
||||
RUN pnpm build
|
||||
|
||||
# === RUNTIME STAGE ===
|
||||
FROM nginx:1.25-alpine
|
||||
|
||||
# Remover config por defecto
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Copiar configuración nginx
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Copiar archivos estáticos
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Permisos correctos
|
||||
RUN chown -R nginx:nginx /usr/share/nginx/html && \
|
||||
chown -R nginx:nginx /var/cache/nginx && \
|
||||
chown -R nginx:nginx /var/log/nginx && \
|
||||
touch /var/run/nginx.pid && \
|
||||
chown -R nginx:nginx /var/run/nginx.pid
|
||||
|
||||
# Usuario no-root
|
||||
USER nginx
|
||||
|
||||
# Puerto
|
||||
EXPOSE 80
|
||||
|
||||
# Healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:80 || exit 1
|
||||
|
||||
# Iniciar nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Reference in New Issue
Block a user