NOT-OMEGA commited on
Commit
2bfe73a
Β·
verified Β·
1 Parent(s): 3a8b8aa

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -11
Dockerfile CHANGED
@@ -1,29 +1,41 @@
1
  # ── Stage 1: Builder ─────────────────────────────────────────
2
- FROM python:3.11-slim AS builder
 
 
 
 
 
 
3
 
4
  WORKDIR /app
5
 
6
- COPY requirements.txt .
7
- RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
 
 
 
 
 
8
 
9
  # ── Stage 2: Runtime ─────────────────────────────────────────
10
- FROM python:3.11-slim
11
 
12
- # HF Spaces runs as user 1000
13
  RUN useradd -m -u 1000 appuser
14
 
15
  WORKDIR /app
16
 
17
- # Copy dependencies
18
- COPY --from=builder /install /usr/local
 
19
 
20
- # Copy source
21
- COPY --chown=appuser:appuser . .
22
 
23
  USER appuser
24
 
25
  # HF Spaces exposes port 7860
26
  EXPOSE 7860
27
 
28
- # Start with uvicorn, binding to 0.0.0.0:7860
29
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--ws", "websockets"]
 
1
  # ── Stage 1: Builder ─────────────────────────────────────────
2
+ FROM ubuntu:22.04 AS builder
3
+
4
+ # Install C++ build tools and CMake
5
+ RUN apt-get update && apt-get install -y \
6
+ build-essential \
7
+ cmake \
8
+ && rm -rf /var/lib/apt/lists/*
9
 
10
  WORKDIR /app
11
 
12
+ # Copy all source files
13
+ COPY . .
14
+
15
+ # Configure and build the C++ project
16
+ # This assumes your CMakeLists.txt is set up correctly in the root
17
+ RUN cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
18
+ RUN cmake --build build -j$(nproc)
19
 
20
  # ── Stage 2: Runtime ─────────────────────────────────────────
21
+ FROM ubuntu:22.04
22
 
23
+ # HF Spaces requires the app to run as user 1000
24
  RUN useradd -m -u 1000 appuser
25
 
26
  WORKDIR /app
27
 
28
+ # Copy the compiled binary from the builder stage
29
+ # IMPORTANT: Replace "YOUR_EXECUTABLE_NAME" with the actual target name from your CMakeLists.txt
30
+ COPY --from=builder --chown=appuser:appuser /app/build/YOUR_EXECUTABLE_NAME ./app_server
31
 
32
+ # Copy your frontend file so the C++ server can serve it
33
+ COPY --chown=appuser:appuser index.html .
34
 
35
  USER appuser
36
 
37
  # HF Spaces exposes port 7860
38
  EXPOSE 7860
39
 
40
+ # Start the C++ executable
41
+ CMD ["./app_server"]