Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +23 -11
Dockerfile
CHANGED
|
@@ -1,29 +1,41 @@
|
|
| 1 |
# ββ Stage 1: Builder βββββββββββββββββββββββββββββββββββββββββ
|
| 2 |
-
FROM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# ββ Stage 2: Runtime βββββββββββββββββββββββββββββββββββββββββ
|
| 10 |
-
FROM
|
| 11 |
|
| 12 |
-
# HF Spaces
|
| 13 |
RUN useradd -m -u 1000 appuser
|
| 14 |
|
| 15 |
WORKDIR /app
|
| 16 |
|
| 17 |
-
# Copy
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
# Copy
|
| 21 |
-
COPY --chown=appuser:appuser . .
|
| 22 |
|
| 23 |
USER appuser
|
| 24 |
|
| 25 |
# HF Spaces exposes port 7860
|
| 26 |
EXPOSE 7860
|
| 27 |
|
| 28 |
-
# Start
|
| 29 |
-
CMD ["
|
|
|
|
| 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"]
|