From 073e439cda7a75f0c13c716475d7c7f91aaa9117 Mon Sep 17 00:00:00 2001 From: "Nikolai X. Shadeuxs" Date: Wed, 19 Jun 2024 04:36:10 -0400 Subject: [PATCH] Update apps/api/Dockerfile --- apps/api/Dockerfile | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 02d2367..1871a52 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -3,30 +3,33 @@ ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" LABEL fly_launch_runtime="Node.js" RUN corepack enable +COPY . /app WORKDIR /app -# Copy only the package files first -COPY apps/api/package.json apps/api/pnpm-lock.yaml ./ - FROM base AS prod-deps -RUN pnpm install --prod --frozen-lockfile +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile FROM base AS build -COPY apps/api/package.json apps/api/pnpm-lock.yaml ./ -RUN pnpm install --frozen-lockfile -COPY apps/api . +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile + +RUN pnpm install RUN pnpm run build -FROM node:20-slim -WORKDIR /app +# Install packages needed for deployment + + +FROM base RUN apt-get update -qq && \ apt-get install --no-install-recommends -y chromium chromium-sandbox && \ rm -rf /var/lib/apt/lists /var/cache/apt/archives COPY --from=prod-deps /app/node_modules /app/node_modules COPY --from=build /app /app + + + # Start the server by default, this can be overwritten at runtime EXPOSE 8080 ENV PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium" -CMD ["pnpm", "run", "start:production"] -CMD ["pnpm", "run", "worker:production"] +CMD [ "pnpm", "run", "start:production" ] +CMD [ "pnpm", "run", "worker:production" ]