diff --git a/frontend/Dockerfile.dev b/frontend/Dockerfile.dev index 1bbcfad1..38117907 100644 --- a/frontend/Dockerfile.dev +++ b/frontend/Dockerfile.dev @@ -8,7 +8,7 @@ RUN corepack enable FROM base as build WORKDIR /usr/src/app COPY package.json pnpm-lock.yaml ./ -RUN pnpm install +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile # Debug Stage FROM base as debug diff --git a/frontend/Dockerfile.prod b/frontend/Dockerfile.prod index eace19cd..5bb5a767 100644 --- a/frontend/Dockerfile.prod +++ b/frontend/Dockerfile.prod @@ -1,16 +1,17 @@ -# Install pnpm -FROM node:18-alpine as base +# Stage 1: Build the React app +FROM node:18-slim as build ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable - -# Build the React app -FROM base as build +# Set the working directory WORKDIR /app + +# Copy package.json and yarn.lock files COPY package.json pnpm-lock.yaml ./ -RUN pnpm install -# Import ENVs to the builded app +# Install dependencies +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile + RUN npx pkg ./node_modules/@import-meta-env/cli/bin/import-meta-env.js \ -o import-meta-env -y @@ -18,7 +19,7 @@ RUN npx pkg ./node_modules/@import-meta-env/cli/bin/import-meta-env.js \ COPY . . # Build the app for production -RUN pnpm build +RUN pnpm run build # Stage 2: Create a minimal NGINX image FROM nginx:1.25.2