Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# Parse command line arguments
SKIP_EMBEDDINGS=false
SKIP_EMBEDDINGS=true
while [[ $# -gt 0 ]]; do
case $1 in
--skip-embeddings|-s)
Expand All @@ -22,27 +22,11 @@ GIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "nogit")
VERSION="1.0.0+${BUILD_DATE}.${GIT_HASH}"
echo "Building with version: $VERSION"

if [ "$SKIP_EMBEDDINGS" = false ]; then
# Build the embeddings generator CLI tool
echo "Building embeddings generator..."
dotnet build csla-embeddings-generator/csla-embeddings-generator.csproj -c Release

# Run the embeddings generator to create embeddings.json
echo "Generating embeddings..."
dotnet run --project csla-embeddings-generator/csla-embeddings-generator.csproj --configuration Release -- --examples-path ./csla-examples --output ./embeddings.json
else
echo "Skipping embeddings generation (--skip-embeddings)"
fi

# If embeddings.json doesn't exist (e.g., missing Azure credentials), create an empty array JSON file
# This allows the Docker build to succeed, but semantic search will be disabled at runtime
if [ ! -f ./embeddings.json ]; then
echo "Warning: embeddings.json not created, creating empty file for Docker build"
echo "[]" > ./embeddings.json
fi

# Build the Docker container with the embeddings.json file and version embedded in assembly
echo "Building Docker container..."
docker build -t csla-mcp-server:latest \
--build-arg VERSION=$VERSION \
--build-arg SKIP_EMBEDDINGS=$SKIP_EMBEDDINGS \
--build-arg AZURE_OPENAI_ENDPOINT=$AZURE_OPENAI_ENDPOINT \
--build-arg AZURE_OPENAI_API_KEY=$AZURE_OPENAI_API_KEY \
-f csla-mcp-server/Dockerfile .
Comment thread
vijaygill marked this conversation as resolved.
31 changes: 25 additions & 6 deletions csla-mcp-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ EXPOSE 8080
EXPOSE 8081


# This stage is used to build the service project
# This stage builds the csla-mcp-server project
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG BUILD_CONFIGURATION=Release
ARG VERSION=1.0.0
Expand All @@ -19,18 +19,37 @@ COPY . .
WORKDIR "/src/csla-mcp-server"
RUN dotnet build "./csla-mcp-server.csproj" -c $BUILD_CONFIGURATION -o /app/build /p:InformationalVersion=$VERSION

# This stage is used to publish the service project to be copied to the final stage

# This stage publishes the service project
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
ARG VERSION=1.0.0
RUN dotnet publish "./csla-mcp-server.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false /p:InformationalVersion=$VERSION

# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)

# This stage generates the embeddings file
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS embeddings-generator
ARG SKIP_EMBEDDINGS=true
ARG AZURE_OPENAI_ENDPOINT
ARG AZURE_OPENAI_API_KEY
ENV AZURE_OPENAI_ENDPOINT=$AZURE_OPENAI_ENDPOINT
ENV AZURE_OPENAI_API_KEY=$AZURE_OPENAI_API_KEY
WORKDIR /src
COPY csla-embeddings-generator/ ./csla-embeddings-generator/
COPY csla-examples/ ./csla-examples/
RUN if [ "$SKIP_EMBEDDINGS" = "false" ]; then \
dotnet restore "./csla-embeddings-generator/csla-embeddings-generator.csproj" && \
dotnet build "./csla-embeddings-generator/csla-embeddings-generator.csproj" -c Release -o /app/embeddings-build && \
dotnet run --project "./csla-embeddings-generator/csla-embeddings-generator.csproj" --configuration Release -- --examples-path /src/csla-examples --output /embeddings.json; \
fi
RUN if [ ! -f /embeddings.json ]; then echo "[]" > /embeddings.json; fi


# This stage is used in production or when running from VS in regular mode
FROM base AS final
WORKDIR /
COPY --from=build /src/csla-examples /csla-examples
WORKDIR /app
COPY --from=publish /app/publish .
# Copy pre-generated embeddings (created by build.sh script)
COPY embeddings.json ./embeddings.json
ENTRYPOINT ["dotnet", "csla-mcp-server.dll"]
COPY --from=embeddings-generator /embeddings.json ./embeddings.json
ENTRYPOINT ["dotnet", "csla-mcp-server.dll"]
Loading