2024-04-16 05:01:47 +08:00
FROM node:20-slim AS base
ENV PNPM_HOME = "/pnpm"
ENV PATH = " $PNPM_HOME : $PATH "
LABEL fly_launch_runtime = "Node.js"
RUN corepack enable
COPY . /app
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
RUN --mount= type = cache,id= pnpm,target= /pnpm/store pnpm install --frozen-lockfile
2024-08-22 01:08:03 +08:00
RUN apt-get update -qq && apt-get install -y ca-certificates && update-ca-certificates
2024-04-16 05:01:47 +08:00
RUN pnpm install
2024-08-22 01:08:03 +08:00
RUN --mount= type = secret,id= SENTRY_AUTH_TOKEN \
2024-08-22 02:40:42 +08:00
bash -c 'export SENTRY_AUTH_TOKEN="$(cat /run/secrets/SENTRY_AUTH_TOKEN)"; if [ -z $SENTRY_AUTH_TOKEN ]; then pnpm run build:nosentry; else pnpm run build; fi'
2024-04-16 05:01:47 +08:00
# 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"