Seth0330 commited on
Commit
c019ed4
·
verified ·
1 Parent(s): 4d92953

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +77 -0
Dockerfile ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ---------- build frontend ----------
2
+ FROM node:20-bookworm AS frontend-build
3
+ WORKDIR /frontend
4
+ COPY frontend/package.json frontend/package-lock.json* ./
5
+ RUN npm install
6
+ COPY frontend/ .
7
+ RUN npm run build
8
+
9
+ # ---------- build runtime ----------
10
+ FROM python:3.11-slim AS runtime
11
+ WORKDIR /app
12
+
13
+ # Install Caddy (simple static + reverse proxy)
14
+ RUN apt-get update && apt-get install -y --no-install-recommends \
15
+ curl ca-certificates \
16
+ && rm -rf /var/lib/apt/lists/* \
17
+ && curl -1sLf "https://dl.cloudsmith.io/public/caddy/stable/gpg.key" | tee /etc/apt/trusted.gpg.d/caddy.asc >/dev/null \
18
+ && curl -1sLf "https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt" | tee /etc/apt/sources.list.d/caddy-stable.list \
19
+ && apt-get update && apt-get install -y --no-install-recommends caddy \
20
+ && rm -rf /var/lib/apt/lists/*
21
+
22
+ # Backend deps
23
+ COPY backend/requirements.txt /app/backend/requirements.txt
24
+ RUN pip install --no-cache-dir -r /app/backend/requirements.txt
25
+
26
+ # Copy backend code
27
+ COPY backend /app/backend
28
+
29
+ # Copy frontend build output from builder
30
+ COPY --from=frontend-build /frontend/dist /app/frontend/dist
31
+
32
+ # Copy Caddy config
33
+ COPY Caddyfile /app/Caddyfile
34
+
35
+ # Expose HF port
36
+ EXPOSE 7860
37
+
38
+ # Start both: FastAPI (8000) + Caddy (7860)
39
+ CMD sh -c "uvicorn backend.app.main:app --host 0.0.0.0 --port 8000 & caddy run --config /app/Caddyfile --adapter caddyfile"# ---------- build frontend ----------
40
+ FROM node:20-bookworm AS frontend-build
41
+ WORKDIR /frontend
42
+ COPY frontend/package.json frontend/package-lock.json* ./
43
+ RUN npm install
44
+ COPY frontend/ .
45
+ RUN npm run build
46
+
47
+ # ---------- build runtime ----------
48
+ FROM python:3.11-slim AS runtime
49
+ WORKDIR /app
50
+
51
+ # Install Caddy (simple static + reverse proxy)
52
+ RUN apt-get update && apt-get install -y --no-install-recommends \
53
+ curl ca-certificates \
54
+ && rm -rf /var/lib/apt/lists/* \
55
+ && curl -1sLf "https://dl.cloudsmith.io/public/caddy/stable/gpg.key" | tee /etc/apt/trusted.gpg.d/caddy.asc >/dev/null \
56
+ && curl -1sLf "https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt" | tee /etc/apt/sources.list.d/caddy-stable.list \
57
+ && apt-get update && apt-get install -y --no-install-recommends caddy \
58
+ && rm -rf /var/lib/apt/lists/*
59
+
60
+ # Backend deps
61
+ COPY backend/requirements.txt /app/backend/requirements.txt
62
+ RUN pip install --no-cache-dir -r /app/backend/requirements.txt
63
+
64
+ # Copy backend code
65
+ COPY backend /app/backend
66
+
67
+ # Copy frontend build output from builder
68
+ COPY --from=frontend-build /frontend/dist /app/frontend/dist
69
+
70
+ # Copy Caddy config
71
+ COPY Caddyfile /app/Caddyfile
72
+
73
+ # Expose HF port
74
+ EXPOSE 7860
75
+
76
+ # Start both: FastAPI (8000) + Caddy (7860)
77
+ CMD sh -c "uvicorn backend.app.main:app --host 0.0.0.0 --port 8000 & caddy run --config /app/Caddyfile --adapter caddyfile