Skip to content

Commit ec2e820

Browse files
vadim-a-yegorovVadym Yehorov
authored andcommitted
deploy: root AIO Dockerfile for Railway (supervisor + caddy, source-built web/admin/live/api)
1 parent effd0c5 commit ec2e820

5 files changed

Lines changed: 179 additions & 1 deletion

File tree

Dockerfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
FROM node:22-alpine AS jsbuild
2+
ENV PNPM_HOME=/pnpm
3+
ENV PATH=/pnpm:/pnpm/bin:$PATH
4+
ENV CI=1
5+
ENV TURBO_TELEMETRY_DISABLED=1
6+
RUN corepack enable
7+
RUN apk add --no-cache libc6-compat
8+
WORKDIR /app
9+
COPY . .
10+
RUN pnpm add -g turbo@2.9.18
11+
RUN pnpm install --frozen-lockfile
12+
RUN turbo run build --filter=web --filter=admin --filter=live
13+
14+
FROM python:3.12.10-alpine AS apibuild
15+
ENV PYTHONDONTWRITEBYTECODE=1
16+
ENV PYTHONUNBUFFERED=1
17+
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
18+
WORKDIR /code
19+
RUN apk add --no-cache libpq libxslt xmlsec ca-certificates openssl libffi-dev
20+
COPY apps/api/requirements.txt ./requirements.txt
21+
COPY apps/api/requirements ./requirements
22+
RUN apk add --no-cache --virtual .build-deps \
23+
"bash~=5.2" g++ gcc cargo git make postgresql-dev libc-dev linux-headers \
24+
&& pip install -r requirements.txt --compile --no-cache-dir \
25+
&& apk del .build-deps \
26+
&& rm -rf /var/cache/apk/*
27+
COPY apps/api/manage.py manage.py
28+
COPY apps/api/plane plane/
29+
COPY apps/api/templates templates/
30+
COPY apps/api/package.json package.json
31+
COPY apps/api/bin ./bin/
32+
RUN apk add --no-cache "bash~=5.2" && mkdir -p /code/plane/logs && chmod +x ./bin/*
33+
34+
FROM caddy:2.11.3-alpine AS caddyimg
35+
36+
FROM python:3.12.10-alpine AS runner
37+
WORKDIR /app
38+
RUN apk add --no-cache libpq libxslt xmlsec ca-certificates openssl nss-tools bash curl
39+
40+
COPY --from=jsbuild /usr/lib /usr/lib
41+
COPY --from=jsbuild /usr/local/lib /usr/local/lib
42+
COPY --from=jsbuild /usr/local/include /usr/local/include
43+
COPY --from=jsbuild /usr/local/bin /usr/local/bin
44+
COPY --from=apibuild /usr/local/lib/python3.12/site-packages/ /usr/local/lib/python3.12/site-packages/
45+
COPY --from=apibuild /usr/local/bin/ /usr/local/bin/
46+
47+
COPY --from=caddyimg /usr/bin/caddy /usr/bin/caddy
48+
49+
COPY --from=apibuild /code /app/backend
50+
COPY --from=jsbuild /app/apps/web/build/client /app/web
51+
COPY --from=jsbuild /app/apps/admin/build/client /app/admin
52+
53+
COPY --from=jsbuild /app/packages /app/live/packages
54+
COPY --from=jsbuild /app/node_modules /app/live/node_modules
55+
COPY --from=jsbuild /app/apps/live/dist /app/live/apps/live/dist
56+
COPY --from=jsbuild /app/apps/live/node_modules /app/live/apps/live/node_modules
57+
COPY --from=jsbuild /app/apps/live/package.json /app/live/apps/live/package.json
58+
59+
RUN pip install supervisor --no-cache-dir
60+
RUN mkdir -p /etc/supervisor/conf.d /app/logs /app/data /app/proxy
61+
62+
COPY deploy/railway/Caddyfile /app/proxy/Caddyfile
63+
COPY deploy/railway/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
64+
COPY deploy/railway/start.sh /app/start.sh
65+
RUN chmod +x /app/start.sh
66+
67+
CMD ["/app/start.sh"]

apps/live/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"scripts": {
1616
"build": "tsc --noEmit && tsdown",
1717
"dev": "tsdown --watch --no-clean --onSuccess \"node --env-file=.env .\"",
18-
"start": "node --env-file=.env .",
18+
"start": "node .",
1919
"test": "vitest run",
2020
"test:watch": "vitest",
2121
"test:coverage": "vitest run --coverage",

deploy/railway/Caddyfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
auto_https off
3+
servers {
4+
max_header_size 25MB
5+
client_ip_headers X-Forwarded-For X-Real-IP
6+
trusted_proxies static 0.0.0.0/0
7+
}
8+
}
9+
10+
:{$PORT} {
11+
request_body {
12+
max_size {$FILE_SIZE_LIMIT}
13+
}
14+
15+
handle /live/* {
16+
reverse_proxy localhost:3005
17+
}
18+
19+
handle /api/* {
20+
reverse_proxy localhost:3004
21+
}
22+
23+
handle /auth/* {
24+
reverse_proxy localhost:3004
25+
}
26+
27+
handle /static/* {
28+
reverse_proxy localhost:3004
29+
}
30+
31+
handle_path /god-mode* {
32+
root * /app/admin
33+
try_files {path} {path}/ /index.html
34+
file_server
35+
}
36+
37+
handle_path /* {
38+
root * /app/web
39+
try_files {path} {path}/ /index.html
40+
file_server
41+
}
42+
}

deploy/railway/start.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
export FILE_SIZE_LIMIT="${FILE_SIZE_LIMIT:-5242880}"
3+
exec /usr/local/bin/supervisord -c /etc/supervisor/conf.d/supervisor.conf

deploy/railway/supervisor.conf

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[supervisord]
2+
user=root
3+
nodaemon=true
4+
logfile=/app/logs/supervisord.log
5+
pidfile=/tmp/supervisord.pid
6+
7+
[program:migrator]
8+
directory=/app/backend
9+
command=sh -c "./bin/docker-entrypoint-migrator.sh"
10+
autostart=true
11+
autorestart=unexpected
12+
stdout_logfile=/dev/fd/1
13+
stdout_logfile_maxbytes=0
14+
redirect_stderr=true
15+
priority=10
16+
17+
[program:api]
18+
directory=/app/backend
19+
command=sh -c "./bin/docker-entrypoint-api.sh"
20+
autostart=true
21+
autorestart=true
22+
environment=PORT=3004,HOSTNAME=0.0.0.0
23+
stdout_logfile=/dev/fd/1
24+
stdout_logfile_maxbytes=0
25+
redirect_stderr=true
26+
priority=15
27+
28+
[program:worker]
29+
directory=/app/backend
30+
command=sh -c "./bin/docker-entrypoint-worker.sh"
31+
autostart=true
32+
autorestart=true
33+
stdout_logfile=/dev/fd/1
34+
stdout_logfile_maxbytes=0
35+
redirect_stderr=true
36+
priority=20
37+
38+
[program:beat]
39+
directory=/app/backend
40+
command=sh -c "./bin/docker-entrypoint-beat.sh"
41+
autostart=true
42+
autorestart=true
43+
stdout_logfile=/dev/fd/1
44+
stdout_logfile_maxbytes=0
45+
redirect_stderr=true
46+
priority=20
47+
48+
[program:live]
49+
command=sh -c "node /app/live/apps/live"
50+
autostart=true
51+
autorestart=true
52+
environment=PORT=3005,HOSTNAME=0.0.0.0,API_BASE_URL=http://localhost:3004
53+
stdout_logfile=/dev/fd/1
54+
stdout_logfile_maxbytes=0
55+
redirect_stderr=true
56+
priority=20
57+
58+
[program:proxy]
59+
directory=/app/proxy
60+
command=sh -c "caddy run --config /app/proxy/Caddyfile"
61+
autostart=true
62+
autorestart=true
63+
stdout_logfile=/dev/fd/1
64+
stdout_logfile_maxbytes=0
65+
redirect_stderr=true
66+
priority=30

0 commit comments

Comments
 (0)