File size: 1,499 Bytes
c77fbef
2bfe73a
 
ae687b6
2bfe73a
 
 
1f2191b
 
 
4a6981e
fe232f1
2bfe73a
c77fbef
 
 
2bfe73a
 
 
 
 
 
c77fbef
 
2bfe73a
c77fbef
c05cb0f
 
 
 
 
 
 
 
2bfe73a
c77fbef
 
 
 
2bfe73a
ae687b6
 
2bfe73a
 
c77fbef
 
 
 
 
 
2bfe73a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# ── Stage 1: Builder ─────────────────────────────────────────
FROM ubuntu:22.04 AS builder

# Install all required C++ build tools and libraries
RUN apt-get update && apt-get install -y \
    build-essential \
    cmake \
    libboost-system-dev \
    libboost-coroutine-dev \
    libboost-context-dev \
    libssl-dev \
    nlohmann-json3-dev \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy all source files
COPY . .

# Configure and build the C++ project
RUN cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
RUN cmake --build build -j$(nproc)

# ── Stage 2: Runtime ─────────────────────────────────────────
FROM ubuntu:22.04

# FIX: Install runtime libraries for Boost and OpenSSL so the binary can run
RUN apt-get update && apt-get install -y \
    libboost-system1.74.0 \
    libboost-coroutine1.74.0 \
    libboost-context1.74.0 \
    libssl3 \
    && rm -rf /var/lib/apt/lists/*

# HF Spaces requires the app to run as user 1000
RUN useradd -m -u 1000 appuser

WORKDIR /app

# Copy the compiled binary from the builder stage
COPY --from=builder --chown=appuser:appuser /app/build/collabdocs ./app_server

# Copy your frontend file so the C++ server can serve it
COPY --chown=appuser:appuser index.html .

USER appuser

# HF Spaces exposes port 7860
EXPOSE 7860

# Start the C++ executable
CMD ["./app_server"]