88# The build stage also includes a step to clean any old CMake cache to ensure a fresh build of the C++ library
99# The build stage compiles the C++ shared library using CMake and then publishes the .NET API to a specified output directory
1010
11+ # ==========================================
12+ # STAGE 1: Compilation Environment
13+ # ==========================================
1114FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
1215
16+ # Install C++ build tools
1317RUN apt-get update && apt-get install -y \
1418 build-essential \
15- cmake
19+ cmake \
20+ && rm -rf /var/lib/apt/lists/*
1621
1722WORKDIR /src
18- # Copy everything from the root context (which includes the 'backend' folder)
23+
24+ # Copy the entire monorepo context
25+ # This is necessary because your C++ tests might reference folders
26+ # outside the immediate CppLib directory.
1927COPY . .
2028
21- # 1. Clean old CMake cache (Updated path)
29+ # DEBUG STEP: This will print the file structure in your GitHub logs
30+ # so you can verify exactly where the files are if it fails again.
31+ RUN ls -R /src/backend/CaseConversionAPI
32+
33+ # 1. Clean old CMake cache
34+ # Using the full path from the root context (.)
2235RUN rm -rf backend/CaseConversionAPI/CppLib/build
2336
24- # 2. Build C++ shared library (Added 'backend/' prefix)
25- RUN cmake -S backend/CaseConversionAPI/CppLib -B backend/CaseConversionAPI/CppLib/build -DCMAKE_BUILD_TYPE=Release
37+ # 2. Build C++ shared library
38+ # Ensure the case matches your GitHub folders (e.g., CppLib vs cpplib)
39+ RUN cmake -S backend/CaseConversionAPI/CppLib \
40+ -B backend/CaseConversionAPI/CppLib/build \
41+ -DCMAKE_BUILD_TYPE=Release
42+
2643RUN cmake --build backend/CaseConversionAPI/CppLib/build --parallel
2744
28- # 3. Publish .NET API (Added 'backend/' prefix)
45+ # 3. Publish .NET API
46+ # This assumes your .csproj is inside the DotNetAPI folder
2947RUN dotnet publish backend/CaseConversionAPI/DotNetAPI -c Release -o /app/publish
3048
31- # 4. Copy shared library (Note: check if your CMake output goes to 'lib' or root of build)
49+ # 4. Copy shared library to the publish folder
50+ # On Linux, CMake produces a .so file.
51+ # We copy it so the .NET runtime can find it via P/Invoke.
3252RUN cp backend/CaseConversionAPI/CppLib/build/libProcessStringDLL.so /app/publish/
3353
34- # ---------- Runtime ----------
54+ # ==========================================
55+ # STAGE 2: Optimized Runtime Image
56+ # ==========================================
3557FROM mcr.microsoft.com/dotnet/aspnet:8.0
36-
3758WORKDIR /app
59+
60+ # Copy only the compiled artifacts from the build stage
3861COPY --from=build /app/publish .
3962
63+ # Expose the default ASP.NET port
4064EXPOSE 8080
4165
42- # Ensure this matches the actual .csproj name in your backend folder
43- ENTRYPOINT ["dotnet" , "CaseConversionAPI.dll" ]
66+ # Start the API
67+ # Ensure "DotNetAPI.dll" matches your actual assembly name
68+ ENTRYPOINT ["dotnet" , "DotNetAPI.dll" ]
0 commit comments