-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (29 loc) · 882 Bytes
/
Dockerfile
File metadata and controls
41 lines (29 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 1️⃣ Etapa de compilación
FROM node:20-alpine AS builder
WORKDIR /app
# Instalar `pnpm` globalmente
RUN npm install -g pnpm
# Copiar archivos de dependencias
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile
# Copiar el código fuente
COPY . .
# Construir la aplicación Next.js
RUN pnpm build
# 2️⃣ Etapa de ejecución
FROM node:20-alpine AS runner
WORKDIR /app
# Instalar `pnpm` también en la imagen final
RUN npm install -g pnpm
# Copiar archivos compilados
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
# Asegurar que los archivos estén en la imagen
RUN ls -la /app
# Establecer variables de entorno
ENV PORT=3000
EXPOSE 3000
# Comando para iniciar la aplicación
CMD ["pnpm", "start"]