From d877d0fae2e12665d05e6c6ceae348de3a10dbe1 Mon Sep 17 00:00:00 2001 From: "DESKTOP-2S5P7D1\\Windows 10" Date: Wed, 4 Dec 2024 13:03:16 +0700 Subject: [PATCH] build test --- .github/workflows/release.yml | 1 + Dockerfile => docker/Dockerfile | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) rename Dockerfile => docker/Dockerfile (71%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb51815..a80e6de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,6 +49,7 @@ jobs: with: context: . platforms: linux/amd64 + file: docker/Dockerfile push: true tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest - name: Remote Deployment diff --git a/Dockerfile b/docker/Dockerfile similarity index 71% rename from Dockerfile rename to docker/Dockerfile index 6767e59..6faa727 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -1,25 +1,30 @@ -FROM node:20-slim AS base - +# Base stage +FROM node:lts-alpine AS base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable - WORKDIR /app - COPY . . +# Dependencies stage FROM base AS deps RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile +# Build stage FROM base AS build RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile RUN pnpm run build -FROM base as prod +# Production stage +FROM node:lts-alpine AS prod ENV NODE_ENV="production" +WORKDIR /app + +# Copy necessary files from previous stages COPY --from=deps /app/node_modules /app/node_modules COPY --from=build /app/dist /app/dist COPY --from=base /app/static /app/static +# Start the application CMD ["pnpm", "run", "start"]