Files
dokploy/Dockerfile.tanstack
Mauricio Siu 0a02b5f5d6 feat: Dokploy UI on TanStack Start
Adds apps/tanstack-start: every page of apps/dokploy/pages as a native
TanStack Start route (beforeLoad/loader/head instead of getServerSideProps),
sharing components, hooks and the tRPC client with apps/dokploy.

- Next-free HTTP server running the pages/api handlers, websockets, crons
  and the Start handler in one process
- Dashboard rendered with ssr: "data-only"; tRPC goes over loopback during SSR
- Fontsource fonts, route head() titles with whitelabel branding
- Dockerfile.tanstack (Node) and Dockerfile.tanstack-bun images
- Workflow publishing dokploy/dokploy:tanstack for amd64 and arm64
- Pin @codemirror/language, @codemirror/view and @lezer/highlight to a
  single copy so syntax highlighting works across both apps
2026-12-03 13:59:40 -06:00

69 lines
3.0 KiB
Docker

# syntax=docker/dockerfile:1
FROM node:24.22.1-bookworm-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable && corepack prepare pnpm@10.34.9 --activate
FROM base AS build
WORKDIR /usr/src/app
RUN apt-get update && apt-get install -y python3 make g++ git pkg-config libsecret-1-dev && rm -rf /var/lib/apt/lists/*
COPY . .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
ENV NODE_ENV=production
RUN pnpm --filter=./apps/tanstack-start run build
# Only the API server's externals are runtime dependencies; the UI and the SSR bundle are self-contained.
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
pnpm --filter=./apps/tanstack-start --prod deploy --legacy /prod/app
# Optional peers pnpm auto-installs for better-auth/drizzle adapters Dokploy never loads (Next, Prisma, SQLite, PGlite...).
RUN cd /prod/app/node_modules/.pnpm && rm -rf \
next@* @next+* prisma@* @prisma+* effect@* typescript@* @typescript+* \
@electric-sql+pglite@* better-sqlite3@* sharp@* @img+* rolldown@* @rolldown+* drizzle-kit@*
FROM base AS dokploy
WORKDIR /app
ENV NODE_ENV=production
RUN apt-get update && apt-get install -y tini curl unzip zip apache2-utils iproute2 rsync git-lfs && git lfs install && rm -rf /var/lib/apt/lists/*
# Dokploy drives the host's Docker through the mounted socket: the CLI and its plugins are enough, no engine.
RUN install -m 0755 -d /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" > /etc/apt/sources.list.d/docker.list \
&& apt-get update \
&& apt-get install -y docker-ce-cli=5:28.5.2-1~debian.12~bookworm docker-buildx-plugin docker-compose-plugin \
&& rm -rf /var/lib/apt/lists/* \
&& curl https://rclone.org/install.sh | bash
ARG NIXPACKS_VERSION=1.41.0
RUN curl -sSL https://nixpacks.com/install.sh -o install.sh \
&& chmod +x install.sh \
&& ./install.sh \
&& rm install.sh \
&& pnpm install -g tsx
ARG RAILPACK_VERSION=0.15.4
RUN curl -sSL https://railpack.com/install.sh | bash
COPY --from=buildpacksio/pack:0.40.11 /usr/local/bin/pack /usr/local/bin/pack
COPY --from=build /prod/app/node_modules ./node_modules
COPY --from=build /prod/app/package.json ./package.json
COPY --from=build /usr/src/app/apps/tanstack-start/dist ./dist
COPY --from=build /usr/src/app/apps/tanstack-start/dist-server ./dist-server
COPY --from=build /usr/src/app/apps/dokploy/drizzle ./drizzle
COPY apps/dokploy/.env.production.example ./.env
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=5 \
CMD curl -fs http://localhost:3000/api/trpc/settings.health || exit 1
# tini reaps HEALTHCHECK child processes that Node (as PID 1) leaves defunct.
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["sh", "-c", "node -r dotenv/config dist-server/wait-for-postgres.mjs && node -r dotenv/config dist-server/migration.mjs && exec node dist-server/server.mjs"]