Skip to content

Commit 7d1b05e

Browse files
committed
Refactor Dockerfile to simplify static file serving
1 parent 0f94dde commit 7d1b05e

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

app/Dockerfile

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,16 @@
1-
FROM node:20.9-slim AS base
2-
ENV PNPM_HOME="/pnpm"
3-
ENV PATH="$PNPM_HOME:$PATH"
4-
RUN corepack enable
1+
FROM node:20.9-slim
52

6-
FROM base AS build
7-
COPY . /usr/src/app
8-
WORKDIR /usr/src/app
9-
10-
RUN apt-get update && rm -rf /var/lib/apt/lists/*
11-
12-
# Install dependencies
13-
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
14-
15-
# Deploy only the dokploy app
16-
ENV NODE_ENV=production
17-
RUN pnpm build
18-
19-
FROM base AS dokploy
203
WORKDIR /app
214

22-
# Set production
23-
ENV NODE_ENV=production
24-
25-
# Copy only the necessary files
26-
COPY --from=build /usr/src/app/dist ./dist
27-
COPY --from=build /usr/src/app/package.json ./package.json
28-
COPY --from=build /usr/src/app/node_modules ./node_modules
5+
# Instalar serve globalmente
6+
RUN npm install -g serve
297

30-
# Copy templates folder
8+
# Copiar la carpeta templates
319
COPY ../templates ./public/templates
10+
COPY ../templates/index.html ./public/
3211

33-
# Expose port
12+
# Exponer el puerto
3413
EXPOSE 3000
3514

36-
CMD HOSTNAME=0.0.0.0 && pnpm start
15+
# Servir los archivos estáticos
16+
CMD ["serve", "-s", "public", "-l", "3000"]

0 commit comments

Comments
 (0)