Skip to content

Commit 48daf73

Browse files
Added new file location as per the log
1 parent 865d29c commit 48daf73

1 file changed

Lines changed: 36 additions & 11 deletions

File tree

backend/Dockerfile

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,61 @@
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+
# ==========================================
1114
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
1215

16+
# Install C++ build tools
1317
RUN apt-get update && apt-get install -y \
1418
build-essential \
15-
cmake
19+
cmake \
20+
&& rm -rf /var/lib/apt/lists/*
1621

1722
WORKDIR /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.
1927
COPY . .
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 (.)
2235
RUN 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+
2643
RUN 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
2947
RUN 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.
3252
RUN cp backend/CaseConversionAPI/CppLib/build/libProcessStringDLL.so /app/publish/
3353

34-
# ---------- Runtime ----------
54+
# ==========================================
55+
# STAGE 2: Optimized Runtime Image
56+
# ==========================================
3557
FROM mcr.microsoft.com/dotnet/aspnet:8.0
36-
3758
WORKDIR /app
59+
60+
# Copy only the compiled artifacts from the build stage
3861
COPY --from=build /app/publish .
3962

63+
# Expose the default ASP.NET port
4064
EXPOSE 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

Comments
 (0)