fp/d.next.dockerfile

55 lines
1.9 KiB
Docker

## Important! Build context is the ROOT of the project.
## this keeps the door open for future possibility of shared code between pnpm workspace packages
FROM node:20-slim AS base
FROM base AS deps
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
FROM deps AS install
ARG NEXT_PUBLIC_SITE_URL=https://futureporn.net
ARG NEXT_PUBLIC_STRAPI_URL=https://portal.futureporn.net
ARG NEXT_PUBLIC_UPPY_COMPANION_URL=https://uppy.futureporn.net
ENV NEXT_PUBLIC_SITE_URL ${NEXT_PUBLIC_SITE_URL}
ENV NEXT_PUBLIC_STRAPI_URL ${NEXT_PUBLIC_STRAPI_URL}
ENV NEXT_PUBLIC_UPPY_COMPANION_URL ${NEXT_PUBLIC_UPPY_COMPANION_URL}
ENV NEXT_TELEMETRY_DISABLED 1
ENV NODE_EXTRA_CA_CERTS ${NODE_EXTRA_CA_CERTS}
COPY pnpm-lock.yaml ./
RUN pnpm fetch
# COPY pnpm-lock.yaml .npmrc package.json .
COPY ./packages/next ./packages/next
COPY ./packages/types ./packages/types
# COPY ./packages/strapi ./packages/strapi
# COPY ./packages/scout ./packages/scout
# COPY ./packages/image ./packages/image
# COPY ./packages/utils ./packages/utils
# COPY ./packages/temporal-workflows ./packages/temporal-workflows
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store pnpm install --recursive --frozen-lockfile --prefer-offline
FROM install AS dev
CMD ["pnpm", "run", "dev"]
FROM install AS build
RUN pnpm run -r build
RUN pnpm --filter=next deploy --prod /prod/next
FROM deps AS next
RUN apt-get update && apt-get install -y -qq --no-install-recommends dumb-init
COPY --chown=node:node --from=build /prod/next/package.json /prod/next/pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
COPY --chown=node:node --from=build /prod/next/public ./public
COPY --chown=node:node --from=build /prod/next/.next/standalone ./
COPY --chown=node:node --from=build /prod/next/.next/static ./.next/static
ENV TZ=UTC
ENV NODE_ENV=production
ENV HOSTNAME="0.0.0.0"
CMD [ "dumb-init", "node", "server.js" ]