Use layers more effectively, add OT dep

This commit is contained in:
Jade Ellis 2024-08-25 04:32:21 +01:00
parent cfad9861df
commit f967b8c0c6
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2

View file

@ -9,20 +9,23 @@ WORKDIR /app
# FROM base AS prod-deps
# RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
FROM base AS build
FROM base AS deps
ENV CI=1
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN mkdir ../node_modules
RUN cp -Lr node_modules/.pnpm/@resvg+resvg-*@*/node_modules/* ../node_modules/
RUN cp -Lr node_modules/.pnpm/@sentry+sveltekit@*/node_modules/* ../node_modules/
RUN cp -Lr node_modules/.pnpm/@opentelemetry+instrumentation-http@*/node_modules/* ../node_modules/
RUN cp -Lr node_modules/.pnpm/@opentelemetry+instrumentation@*/node_modules/* ../node_modules/
# RUN cd packages/website; --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
FROM deps as build
RUN cd packages/website; pnpm run build
RUN cd packages/website; pnpm exec rollup -c server-rollup.config.mjs
# copy node_modules/ and other build files over
FROM deps as deploy-deps
RUN mkdir ../node_modules
RUN cp -Lr node_modules/.pnpm/@resvg+resvg-*@*/node_modules/* ../node_modules/
RUN cp -Lr node_modules/.pnpm/@sentry+sveltekit@*/node_modules/* ../node_modules/
RUN cp -Lr node_modules/.pnpm/@opentelemetry+instrumentation-http@*/node_modules/* ../node_modules/
RUN cp -Lr node_modules/.pnpm/@opentelemetry+instrumentation-http@*/node_modules/* ../node_modules/
RUN cp -Lr node_modules/.pnpm/@opentelemetry+api-logs@*/node_modules/* ../node_modules/
FROM node:alpine
WORKDIR /app
@ -31,7 +34,7 @@ COPY --from=build /app/packages/website/output .
COPY --from=build /app/packages/website/build/client ./client/
COPY --from=build /app/packages/website/build/prerendered ./prerendered/
COPY --from=build /app/packages/website/package.json ./package.json
COPY --from=build /node_modules ./node_modules/
COPY --from=deploy-deps /node_modules ./node_modules/
ENV NODE_ENV production
EXPOSE 3000