diff --git a/Dockerfile b/Dockerfile index 06ce7d17..755f52dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,56 +1,32 @@ -FROM mcr.microsoft.com/playwright:v1.44.1-jammy as dev +FROM node:20-slim AS base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable -RUN mkdir /src -WORKDIR /src -COPY app/package.json app/pnpm-lock.yaml app/lingui.config.ts ./ -RUN apt-get update && apt-get install -y --no-install-recommends openjdk-11-jre-headless curl build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev -RUN corepack use pnpm -RUN pnpm i --frozen-lockfile -ENV PATH=$PATH:/src/node_modules/.bin NEXT_TELEMETRY_DISABLED=1 -RUN pnpm compileI18n -RUN npm i -g firebase-tools -RUN firebase --version -RUN firebase setup:emulators:firestore -RUN firebase setup:emulators:storage -RUN firebase setup:emulators:ui -RUN firebase setup:emulators:pubsub -ARG COMMIT=dev -ENV NEXT_PUBLIC_COMMIT_HASH $COMMIT -FROM node:20-slim as builder -ENV PNPM_HOME="/pnpm" -ENV PATH="$PNPM_HOME:$PATH" -RUN corepack enable -RUN mkdir /src -WORKDIR /src -COPY app/package.json app/pnpm-lock.yaml ./ -RUN pnpm i --frozen-lockfile +FROM base AS builder +COPY . /usr/src +WORKDIR /usr/src +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile ENV PATH=$PATH:/src/node_modules/.bin NEXT_TELEMETRY_DISABLED=1 -COPY . . -WORKDIR /src/app +WORKDIR /usr/src/app RUN pnpm compileI18n RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates libuuid1 RUN pnpm predeploy -RUN rm -rf nextjs/cache -WORKDIR /src -RUN pnpm i --prod --ignore-scripts --offline --frozen-lockfile +RUN pnpm deploy --filter=web --prod /prod ARG COMMIT RUN test -n "$COMMIT" -FROM gcr.io/distroless/nodejs20-debian12 as prod +FROM gcr.io/distroless/nodejs20-debian12 AS prod ARG COMMIT ENV NEXT_PUBLIC_COMMIT_HASH=$COMMIT NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 -WORKDIR /app -COPY --from=builder /src/app/cluedb ./cluedb -COPY --from=builder /src/app/next.config.mjs ./ -COPY --from=builder /src/app/public ./public -COPY --from=builder /src/app/locales ./locales -COPY --from=builder /src/node_modules ./node_modules -COPY --from=builder /src/app/nextjs ./nextjs - # This is a runtime depency of node canvas COPY --from=builder /usr/lib/x86_64-linux-gnu/libuuid.so.1 /usr/lib/x86_64-linux-gnu/libuuid.so.1 +WORKDIR /app +COPY --from=builder /prod/cluedb ./cluedb +COPY --from=builder /prod/public ./public +COPY --from=builder /prod/next.config.mjs ./ +COPY --from=builder /prod/node_modules ./node_modules +COPY --from=builder /prod/locales ./locales +COPY --from=builder /prod/nextjs ./nextjs CMD ["./node_modules/next/dist/bin/next", "start", "-p", "8080"] \ No newline at end of file