From fd3bcd1563e3f3402c090b899433ed7fbbaec6b6 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Thu, 24 Oct 2024 13:55:14 +0800 Subject: [PATCH] ci: updated dockerfile --- frontend/.dockerignore | 2 ++ frontend/Dockerfile | 25 ++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 frontend/.dockerignore diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 00000000..8b178651 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,2 @@ +# Ignore the .npmrc file +.npmrc \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 1f1cb0bd..cbb72d75 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,15 +1,26 @@ -FROM node:14 AS build +# Build stage +FROM node:20-alpine AS build -ADD . /app +# Set the working directory in the container WORKDIR /app -RUN rm /app/.npmrc -# install frontend -RUN npm i -g pnpm@7 -RUN pnpm install +# Install pnpm +RUN npm install -g pnpm + +# Copy package.json and pnpm-lock.yaml +COPY package.json pnpm-lock.yaml ./ + +# Install project dependencies +RUN pnpm install --frozen-lockfile + +# Copy the rest of the application code +COPY . . + +# Build the application RUN pnpm run build +# Production stage FROM alpine:3.14 -# copy files +# Copy only the built artifacts from the build stage COPY --from=build /app/dist /app/dist