mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
DB migration compat / Check if migrations changed (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests (Local Emulator) / E2E Tests (Local Emulator, Node ${{ matrix.node-version }}) (22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E Fallback Tests / E2E Fallback Tests (Node ${{ matrix.node-version }}) (22.x) (push) Has been cancelled
Lint & build / lint_and_build (24) (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
DB migration compat / Back-compat — Current branch migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migration compat / Forward-compat — Current branch code with ${{ needs.check-migrations-changed.outputs.base_branch }} branch migrations (push) Has been cancelled
DB migration compat / No migration changes (skipped) (push) Has been cancelled
105 lines
3.0 KiB
Docker
105 lines
3.0 KiB
Docker
ARG NODE_VERSION=22.21.1
|
|
|
|
# Base
|
|
FROM node:${NODE_VERSION} AS base
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && \
|
|
apt-get upgrade -y && \
|
|
rm -rf /var/lib/apt/lists
|
|
|
|
ENV PNPM_HOME=/pnpm
|
|
ENV PATH=$PNPM_HOME:$PATH
|
|
|
|
RUN corepack enable
|
|
RUN corepack prepare pnpm@10.23.0 --activate
|
|
RUN pnpm add -g turbo
|
|
RUN pnpm add -g tsx
|
|
|
|
|
|
# Prune stage
|
|
FROM base AS pruner
|
|
|
|
COPY . .
|
|
|
|
RUN tsx ./scripts/generate-sdks.ts
|
|
|
|
# https://turbo.build/repo/docs/guides/tools/docker
|
|
RUN turbo prune --scope=@stackframe/backend --scope=@stackframe/dashboard --docker
|
|
|
|
|
|
|
|
# Build stage
|
|
FROM base AS builder
|
|
|
|
# copy over package.json files and install dependencies
|
|
COPY --from=pruner /app/out/json/ .
|
|
COPY --from=pruner /app/out/pnpm-lock.yaml .
|
|
COPY .gitignore .
|
|
COPY pnpm-workspace.yaml .
|
|
COPY turbo.json .
|
|
COPY configs ./configs
|
|
COPY --from=pruner /app/scripts/postinstall-patch-next-async-debug-info.mjs ./scripts/
|
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store STACK_SKIP_TEMPLATE_GENERATION=true pnpm install --frozen-lockfile
|
|
|
|
# copy over the rest of the code for the build
|
|
COPY --from=pruner /app/out/full/ .
|
|
|
|
# docs are currently required for the NextJS backend build, but won't exist in the final image
|
|
COPY docs ./docs
|
|
|
|
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
|
|
ENV NEXT_CONFIG_OUTPUT=standalone
|
|
|
|
# Build the backend NextJS app
|
|
RUN pnpm turbo run docker-build --filter=@stackframe/backend... --filter=@stackframe/dashboard...
|
|
|
|
# Build the self-host seed script
|
|
RUN cd apps/backend && pnpm build-self-host-migration-script
|
|
|
|
|
|
|
|
# Final image
|
|
FROM node:${NODE_VERSION}-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install packages needed for deployment
|
|
RUN apt-get update && \
|
|
apt-get upgrade -y && \
|
|
apt-get install -y openssl socat && \
|
|
rm -rf /var/lib/apt/lists
|
|
|
|
# Copy built backend
|
|
COPY --from=builder --chown=node:node /app/apps/backend/.next/standalone ./
|
|
COPY --from=builder --chown=node:node /app/apps/backend/.next/static ./apps/backend/.next/static
|
|
COPY --from=builder --chown=node:node /app/apps/backend/prisma ./apps/backend/prisma
|
|
COPY --from=builder --chown=node:node /app/apps/backend/dist ./apps/backend/dist
|
|
COPY --from=builder --chown=node:node /app/apps/backend/node_modules ./apps/backend/node_modules
|
|
|
|
# Copy built dashboard
|
|
COPY --from=builder --chown=node:node /app/apps/dashboard/.next/standalone ./
|
|
COPY --from=builder --chown=node:node /app/apps/dashboard/.next/static ./apps/dashboard/.next/static
|
|
COPY --from=builder --chown=node:node /app/apps/dashboard/public ./apps/dashboard/public
|
|
|
|
# Restore workspace node_modules needed by non-Next runtime scripts (e.g. migrations)
|
|
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
|
|
COPY --from=builder --chown=node:node /app/packages ./packages
|
|
|
|
# Add the entrypoint script
|
|
COPY ./docker/server/entrypoint.sh .
|
|
RUN chmod +x entrypoint.sh
|
|
|
|
WORKDIR /app
|
|
|
|
# Define environment variables for both services
|
|
ENV NODE_ENV=production
|
|
ENV BACKEND_PORT=8102
|
|
ENV DASHBOARD_PORT=8101
|
|
|
|
USER node
|
|
|
|
# Set entrypoint to run both backend and dashboard
|
|
ENTRYPOINT ["./entrypoint.sh"]
|