Skip to content

Instantly share code, notes, and snippets.

@TanX-009
Created June 8, 2026 06:33
Show Gist options
  • Select an option

  • Save TanX-009/dca9f9829d0e92b6a9434362ccdaa7ad to your computer and use it in GitHub Desktop.

Select an option

Save TanX-009/dca9f9829d0e92b6a9434362ccdaa7ad to your computer and use it in GitHub Desktop.
Dockerfile for production deployment of a turborepo based svelte app (works on dokploy)
FROM oven/bun:latest AS base
WORKDIR /app
# Turbo prune stage for isolated deployment
FROM base AS prepare
RUN bun install -g turbo
COPY . .
ARG APP_NAME
RUN turbo prune $APP_NAME --docker
# Build
FROM base AS builder
ARG APP_NAME
# Copy and install package.json
# for using caching as deps don't change frequently
COPY --from=prepare /app/out/json/ .
RUN bun install --frozen-lockfile
# Copy full for building
COPY --from=prepare /app/out/full/ .
# having following in turbo.json at monorepo level
# ```json
# "futureFlags": {
# "pruneIncludesGlobalFiles": true
# },
# ```
# is important for turbo to keep the .env file present at app level
# Copy env as should be lost between stages
COPY --from=prepare /app/apps/$APP_NAME/.env ./apps/$APP_NAME/.env
# build
RUN bun run build
# Production deps installation
FROM base AS production-deps
ARG APP_NAME
# again for caching copy from json
COPY --from=prepare /app/out/json/ .
RUN bun install --production --frozen-lockfile
# ---
FROM oven/bun:slim AS runner
WORKDIR /app
ARG APP_NAME
# copy the installed production deps
COPY --from=production-deps /app/apps/$APP_NAME/node_modules .
# copy the build files
COPY --from=builder /app/apps/$APP_NAME/build ./build
COPY --from=builder /app/apps/$APP_NAME/svelte.config.js ./svelte.config.js
EXPOSE 3000
CMD ["bun", "./build/index.js"]
{
"$schema": "https://turborepo.dev/schema.json",
"ui": "tui",
"futureFlags": {
"pruneIncludesGlobalFiles": true
},
"tasks": {
"build": {
"dependsOn": ["^build"],
"inputs": ["$TURBO_DEFAULT$", ".env*"],
"outputs": [".svelte-kit/**", ".vercel/**", "dist/**"]
},
"lint": {
"dependsOn": ["^lint"]
},
"check-types": {
"dependsOn": ["^check-types"]
},
"dev": {
"cache": false,
"persistent": true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment