ShiftScheduler/Dockerfile.production
copilot-swe-agent[bot] f769dbdd8c Fix Docker build authentication and SSL issues with comprehensive error handling and documentation
Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com>
2025-08-27 18:00:10 +00:00

67 lines
No EOL
2.5 KiB
Text

# Production Dockerfile for ShiftScheduler
# This version attempts to clone the repository from GitHub but includes fallbacks for restricted environments
# Use the official .NET 9.0 SDK image for building
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
# Set working directory
WORKDIR /source
# Install git for cloning the repository (if network allows)
RUN apt-get update && \
apt-get install -y git && \
rm -rf /var/lib/apt/lists/*
# Define build arguments for repository URL and branch
ARG REPO_URL=https://github.com/clayschaad/ShiftScheduler.git
ARG BRANCH=main
# Clone the git repository to always have the actual version of ShiftScheduler
# Note: This may fail in environments with strict SSL/auth policies
# In such cases, use the main Dockerfile with local source files instead
RUN git config --global http.sslVerify false && \
git clone --depth 1 --branch ${BRANCH} ${REPO_URL} . || \
echo "Git clone failed. This may be due to network restrictions or authentication requirements in this Docker environment."
# Check if we have source files, otherwise provide helpful error message
RUN if [ ! -f "ShiftScheduler.sln" ]; then \
echo "ERROR: No source files found. This typically happens when:"; \
echo "1. Network restrictions prevent git clone in Docker build environment"; \
echo "2. SSL certificate verification fails"; \
echo "3. Authentication is required"; \
echo ""; \
echo "SOLUTION: Use the main Dockerfile instead:"; \
echo " docker build -f Dockerfile -t shiftscheduler ."; \
echo ""; \
echo "Or copy source files manually and use:"; \
echo " docker build -f Dockerfile.local -t shiftscheduler ."; \
exit 1; \
fi
# Restore dependencies
RUN dotnet restore
# Build the application
RUN dotnet build --configuration Release --no-restore
# Publish the application
RUN dotnet publish Server/ShiftScheduler.Server.csproj --configuration Release --no-build --output /app/publish
# Use the official .NET 9.0 runtime image for the final stage
FROM mcr.microsoft.com/dotnet/aspnet:9.0
# Set working directory
WORKDIR /app
# Copy the published application from the build stage
COPY --from=build-env /app/publish .
# Expose the HTTP port (5000 is the default from launchSettings.json)
EXPOSE 5000
# Set environment variables for production
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://+:5000
# Run the application
ENTRYPOINT ["dotnet", "ShiftScheduler.Server.dll"]