Files
dokploy/Dockerfile
Mauricio Siu 37fc26f1ac refactor: move the TanStack app to apps/dokploy and Next to apps/dokploy-next
The TanStack app becomes the official dokploy app (image, cloud image and CI).
Next keeps building from apps/dokploy-next against the shared server code.
2026-12-03 22:55:01 -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/dokploy 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/dokploy --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/dokploy/dist ./dist
COPY --from=build /usr/src/app/apps/dokploy/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"]