From 7d1b05ef3f7290b50cf3047489583c1fd08da51f Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 1 Mar 2025 02:45:31 -0600 Subject: [PATCH] Refactor Dockerfile to simplify static file serving --- app/Dockerfile | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/app/Dockerfile b/app/Dockerfile index 9ffe260..8baa23d 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,36 +1,16 @@ -FROM node:20.9-slim AS base -ENV PNPM_HOME="/pnpm" -ENV PATH="$PNPM_HOME:$PATH" -RUN corepack enable +FROM node:20.9-slim -FROM base AS build -COPY . /usr/src/app -WORKDIR /usr/src/app - -RUN apt-get update && rm -rf /var/lib/apt/lists/* - -# Install dependencies -RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile - -# Deploy only the dokploy app -ENV NODE_ENV=production -RUN pnpm build - -FROM base AS dokploy WORKDIR /app -# Set production -ENV NODE_ENV=production +# Instalar serve globalmente +RUN npm install -g serve -# Copy only the necessary files -COPY --from=build /usr/src/app/dist ./dist -COPY --from=build /usr/src/app/package.json ./package.json -COPY --from=build /usr/src/app/node_modules ./node_modules - -# Copy templates folder +# Copiar la carpeta templates COPY ../templates ./public/templates +COPY ../templates/index.html ./public/ -# Expose port +# Exponer el puerto EXPOSE 3000 -CMD HOSTNAME=0.0.0.0 && pnpm start \ No newline at end of file +# Servir los archivos estáticos +CMD ["serve", "-s", "public", "-l", "3000"] \ No newline at end of file