Skip to content

Commit 6ed0c31

Browse files
committed
chore: add Railpack configs for api, dashboard, and discord-bot and create Dokploy deployment guide
1 parent 2ae6dc9 commit 6ed0c31

7 files changed

Lines changed: 133 additions & 26 deletions

File tree

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22.16.0
1+
v24.14.0

DOKPLOY.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Dokploy Deployment (Railway Config)
2+
3+
This repo now includes a Railway-compatible `railpack.json` per deployable app:
4+
5+
- `apps/api/railpack.json`
6+
- `apps/dashboard/railpack.json`
7+
- `apps/discord-bot/railpack.json`
8+
9+
Each config is monorepo-safe and runs install/build/start from the repository root with pnpm filters.
10+
11+
## 1) Create Services In Dokploy
12+
13+
Create one Dokploy service per app from the same repository.
14+
15+
### API service
16+
17+
- Service type: Application
18+
- Build provider: Railway config (Railpack)
19+
- Root directory: `apps/api`
20+
- Config file: `railpack.json`
21+
22+
### Dashboard service
23+
24+
- Service type: Application
25+
- Build provider: Railway config (Railpack)
26+
- Root directory: `apps/dashboard`
27+
- Config file: `railpack.json`
28+
29+
### Discord bot service
30+
31+
- Service type: Application
32+
- Build provider: Railway config (Railpack)
33+
- Root directory: `apps/discord-bot`
34+
- Config file: `railpack.json`
35+
36+
## 2) Environment Variables
37+
38+
Set these variables in Dokploy per service.
39+
40+
### API
41+
42+
Required or strongly recommended:
43+
44+
- `NODE_ENV=prod`
45+
- `HOST=0.0.0.0`
46+
- `PORT=5001` (or Dokploy-provided port)
47+
- `DATABASE_URL=<postgres-connection-string>`
48+
- `DATABASE_URL_NON_POOLING=<postgres-nonpooling-connection-string>`
49+
- `REDIS_URL=<redis-connection-string>`
50+
- `ALLOWED_ORIGINS=<comma-separated-frontend-origins>`
51+
52+
Optional (feature dependent):
53+
54+
- `SECRET`
55+
- `PRIVATE`
56+
- `PUBLIC`
57+
- `GITHUB_APP_NAME`
58+
- `GITHUB_WEBHOOK_SECRET`
59+
60+
### Dashboard
61+
62+
- `PORT=4173` (optional if Dokploy injects a port)
63+
- `VITE_PROD_API_URL=<public-api-url>`
64+
- `VITE_DEV_API_URL=<dev-api-url-if-needed>`
65+
66+
### Discord bot
67+
68+
- `NODE_ENV=prod`
69+
- `DATABASE_URL=<postgres-connection-string>`
70+
- `REDIS_URL=<redis-connection-string>`
71+
- `DISCORD_TOKEN=<bot-token>`
72+
- Any other bot-specific env variables used in `apps/discord-bot/src/config`
73+
74+
## 3) Notes
75+
76+
- Use pnpm-compatible Node runtime (Node 22+, as required by this repo).
77+
- Railpack commands invoke pnpm directly through Corepack (`corepack pnpm@10.12.1 ...`) to avoid PATH/shim issues in some builders.
78+
- The dashboard service runs `vite preview` and binds to `0.0.0.0`.
79+
- If Dokploy sets `PORT`, the dashboard config uses it. Otherwise it falls back to `4173`.
80+
- API and bot builds rely on workspace package `@taskcord/database`, which is why install/build commands are executed from monorepo root.

Dockerfile.api

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
# syntax=docker/dockerfile:1.5
3-
FROM node:22-alpine AS builder
3+
FROM node:24-alpine
44
WORKDIR /app
55

66
# Install pnpm globally
@@ -14,31 +14,16 @@ COPY apps/discord-bot/package.json ./apps/discord-bot/
1414
COPY packages/ ./packages/
1515

1616
# Use BuildKit cache mount for pnpm store to speed up repeated installs
17-
# Note: We don't mount node_modules as cache because turbo needs it for the build step
17+
# Note: We don't mount node_modules as cache because workspace linking relies on real installs
1818
RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
1919
pnpm install --frozen-lockfile
2020

21-
# Copy rest of source and build in the builder stage
21+
# Copy rest of source for dev runtime
2222
COPY . .
23-
RUN pnpm run build:api
2423

25-
26-
# Runtime image: smaller, only copy build artifacts
27-
FROM node:22-alpine AS runtime
28-
WORKDIR /app
29-
30-
# Optionally install pnpm or use node directly. If you need pnpm for starting, install it.
31-
RUN npm install -g pnpm
32-
RUN npm install -g tsdown
33-
34-
35-
# Copy built files and production node_modules from builder
36-
COPY --from=builder /app/apps/api/dist ./apps/api/dist
37-
COPY --from=builder /app/node_modules ./node_modules
38-
39-
ENV NODE_ENV=production
24+
ENV NODE_ENV=local \
25+
HOST=0.0.0.0 \
26+
PORT=4005
4027
EXPOSE 4005
4128

42-
# Replace with your production start command (adjust path/script)
43-
# CMD ["node", "apps/api/dist/index.js"]
4429
CMD ["pnpm", "--filter", "api", "dev"]

apps/api/railpack.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
"$schema": "https://schema.railpack.com",
33
"steps": {
44
"install": {
5-
"commands": ["pnpm install"]
5+
"commands": [
6+
"ROOT=\"$PWD\"; while [ \"$ROOT\" != \"/\" ] && [ ! -f \"$ROOT/pnpm-workspace.yaml\" ]; do ROOT=\"$(dirname \"$ROOT\")\"; done; echo \"[api][install] start pwd=$(pwd)\"; echo \"[api][install] workspace root=$ROOT\"; [ -f \"$ROOT/pnpm-workspace.yaml\" ] || { echo \"[api][install] workspace root not found\"; exit 1; }; cd \"$ROOT\" && echo \"[api][install] run pwd=$(pwd)\" && corepack enable && corepack pnpm@10.12.1 install --frozen-lockfile"
7+
]
68
},
79
"build": {
810
"inputs": [{ "step": "install" }],
9-
"commands": ["pnpm run build"]
11+
"commands": [
12+
"ROOT=\"$PWD\"; while [ \"$ROOT\" != \"/\" ] && [ ! -f \"$ROOT/pnpm-workspace.yaml\" ]; do ROOT=\"$(dirname \"$ROOT\")\"; done; echo \"[api][build] start pwd=$(pwd)\"; echo \"[api][build] workspace root=$ROOT\"; [ -f \"$ROOT/pnpm-workspace.yaml\" ] || { echo \"[api][build] workspace root not found\"; exit 1; }; cd \"$ROOT\" && echo \"[api][build] run pwd=$(pwd)\" && corepack enable && corepack pnpm@10.12.1 --filter api run build"
13+
]
1014
}
1115
},
1216
"deploy": {
13-
"startCommand": "node dist/index.js"
17+
"startCommand": "ROOT=\"$PWD\"; while [ \"$ROOT\" != \"/\" ] && [ ! -f \"$ROOT/pnpm-workspace.yaml\" ]; do ROOT=\"$(dirname \"$ROOT\")\"; done; echo \"[api][start] start pwd=$(pwd)\"; echo \"[api][start] workspace root=$ROOT\"; [ -f \"$ROOT/pnpm-workspace.yaml\" ] || { echo \"[api][start] workspace root not found\"; exit 1; }; cd \"$ROOT\" && echo \"[api][start] run pwd=$(pwd)\" && corepack enable && corepack pnpm@10.12.1 --filter api run start"
1418
}
1519
}

apps/dashboard/railpack.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://schema.railpack.com",
3+
"steps": {
4+
"install": {
5+
"commands": [
6+
"ROOT=\"$PWD\"; while [ \"$ROOT\" != \"/\" ] && [ ! -f \"$ROOT/pnpm-workspace.yaml\" ]; do ROOT=\"$(dirname \"$ROOT\")\"; done; echo \"[dashboard][install] start pwd=$(pwd)\"; echo \"[dashboard][install] workspace root=$ROOT\"; [ -f \"$ROOT/pnpm-workspace.yaml\" ] || { echo \"[dashboard][install] workspace root not found\"; exit 1; }; cd \"$ROOT\" && echo \"[dashboard][install] run pwd=$(pwd)\" && corepack enable && corepack pnpm@10.12.1 install --frozen-lockfile"
7+
]
8+
},
9+
"build": {
10+
"inputs": [{ "step": "install" }],
11+
"commands": [
12+
"ROOT=\"$PWD\"; while [ \"$ROOT\" != \"/\" ] && [ ! -f \"$ROOT/pnpm-workspace.yaml\" ]; do ROOT=\"$(dirname \"$ROOT\")\"; done; echo \"[dashboard][build] start pwd=$(pwd)\"; echo \"[dashboard][build] workspace root=$ROOT\"; [ -f \"$ROOT/pnpm-workspace.yaml\" ] || { echo \"[dashboard][build] workspace root not found\"; exit 1; }; cd \"$ROOT\" && echo \"[dashboard][build] run pwd=$(pwd)\" && corepack enable && corepack pnpm@10.12.1 --filter dashboard run build"
13+
]
14+
}
15+
},
16+
"deploy": {
17+
"startCommand": "ROOT=\"$PWD\"; while [ \"$ROOT\" != \"/\" ] && [ ! -f \"$ROOT/pnpm-workspace.yaml\" ]; do ROOT=\"$(dirname \"$ROOT\")\"; done; echo \"[dashboard][start] start pwd=$(pwd)\"; echo \"[dashboard][start] workspace root=$ROOT\"; [ -f \"$ROOT/pnpm-workspace.yaml\" ] || { echo \"[dashboard][start] workspace root not found\"; exit 1; }; cd \"$ROOT\" && echo \"[dashboard][start] run pwd=$(pwd)\" && corepack enable && corepack pnpm@10.12.1 --filter dashboard run preview -- --host 0.0.0.0 --port ${PORT:-4173}"
18+
}
19+
}

apps/discord-bot/railpack.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://schema.railpack.com",
3+
"steps": {
4+
"install": {
5+
"commands": [
6+
"ROOT=\"$PWD\"; while [ \"$ROOT\" != \"/\" ] && [ ! -f \"$ROOT/pnpm-workspace.yaml\" ]; do ROOT=\"$(dirname \"$ROOT\")\"; done; echo \"[bot][install] start pwd=$(pwd)\"; echo \"[bot][install] workspace root=$ROOT\"; [ -f \"$ROOT/pnpm-workspace.yaml\" ] || { echo \"[bot][install] workspace root not found\"; exit 1; }; cd \"$ROOT\" && echo \"[bot][install] run pwd=$(pwd)\" && corepack enable && corepack pnpm@10.12.1 install --frozen-lockfile"
7+
]
8+
},
9+
"build": {
10+
"inputs": [{ "step": "install" }],
11+
"commands": [
12+
"ROOT=\"$PWD\"; while [ \"$ROOT\" != \"/\" ] && [ ! -f \"$ROOT/pnpm-workspace.yaml\" ]; do ROOT=\"$(dirname \"$ROOT\")\"; done; echo \"[bot][build] start pwd=$(pwd)\"; echo \"[bot][build] workspace root=$ROOT\"; [ -f \"$ROOT/pnpm-workspace.yaml\" ] || { echo \"[bot][build] workspace root not found\"; exit 1; }; cd \"$ROOT\" && echo \"[bot][build] run pwd=$(pwd)\" && corepack enable && corepack pnpm@10.12.1 --filter bot run build"
13+
]
14+
}
15+
},
16+
"deploy": {
17+
"startCommand": "ROOT=\"$PWD\"; while [ \"$ROOT\" != \"/\" ] && [ ! -f \"$ROOT/pnpm-workspace.yaml\" ]; do ROOT=\"$(dirname \"$ROOT\")\"; done; echo \"[bot][start] start pwd=$(pwd)\"; echo \"[bot][start] workspace root=$ROOT\"; [ -f \"$ROOT/pnpm-workspace.yaml\" ] || { echo \"[bot][start] workspace root not found\"; exit 1; }; cd \"$ROOT\" && echo \"[bot][start] run pwd=$(pwd)\" && corepack enable && corepack pnpm@10.12.1 --filter bot run start"
18+
}
19+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"packageManager": "pnpm@10.12.1",
3232
"engines": {
33-
"node": ">=22"
33+
"node": ">=24"
3434
},
3535
"name": "taskcord-bot-server",
3636
"workspaces": [

0 commit comments

Comments
 (0)