-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (42 loc) · 1.28 KB
/
Dockerfile
File metadata and controls
60 lines (42 loc) · 1.28 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# ===============================
# Stage 1: Build de la app
# ===============================
FROM node:20-alpine AS build
# Directorio de trabajo
WORKDIR /app
# Habilitar pnpm
RUN corepack enable && corepack prepare pnpm@10.29.3 --activate
ENV PNPM_HOME="/root/.local/share/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# Copiar dependencias
COPY package.json pnpm-lock.yaml ./
# Instalar dependencias
RUN pnpm install --frozen-lockfile
# Copiar el resto del código
COPY . .
# Compilar el proyecto
RUN pnpm run build
# ===============================
# Stage 2: Imagen final (serve)
# ===============================
FROM node:20-alpine
WORKDIR /app
# Definir entorno para PNPM global
ENV PNPM_HOME="/root/.local/share/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# Instalar corepack y pnpm
RUN corepack enable && corepack prepare pnpm@10.12.4 --activate
# Crear el directorio global si no existe (previene error)
RUN mkdir -p $PNPM_HOME && chmod -R 777 $PNPM_HOME
# Instalar `serve` globalmente
RUN pnpm add -g serve
# Copiar los archivos compilados desde el build stage
COPY --from=build /app/dist ./dist
# Copiar el entrypoint
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Exponer el puerto
EXPOSE 5173
# Usar el entrypoint
ENTRYPOINT ["/entrypoint.sh"]
CMD ["serve", "-s", "dist", "-l", "5173"]