Add comprehensive Docker support with multiple build options

Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-08-22 09:53:34 +00:00
parent 26a93c82fe
commit 6dc7d6cecd
6 changed files with 221 additions and 0 deletions

16
.dockerignore Normal file
View file

@ -0,0 +1,16 @@
bin/
obj/
.git/
.vs/
.vscode/
node_modules/
packages/
*.tmp
*.swp
*.swo
.env
.env.local
.dockerignore
Dockerfile*
docker-compose*
README.md

65
Docker-README.md Normal file
View file

@ -0,0 +1,65 @@
# ShiftScheduler Docker Setup
This directory contains Docker configuration files for running the ShiftScheduler application in containers.
## Files
- `Dockerfile` - Production dockerfile that clones the repository from GitHub
- `Dockerfile.local` - Development dockerfile that uses local source files
- `docker-compose.yml` - Docker Compose configuration for easy deployment
- `.dockerignore` - Files to exclude from Docker build context
## Usage
### Option 1: Using Local Source (Recommended for Development)
```bash
# Build using local source files
docker build -f Dockerfile.local -t shiftscheduler:local .
# Run the container
docker run -p 5000:5000 shiftscheduler:local
```
### Option 2: Using Git Repository Clone (Production)
```bash
# Build using git repository clone
docker build -t shiftscheduler:latest .
# Run the container
docker run -p 5000:5000 shiftscheduler:latest
```
### Option 3: Using Docker Compose (Easiest)
```bash
# Start the application
docker-compose up --build
# Run in background
docker-compose up -d --build
# Stop the application
docker-compose down
```
## Accessing the Application
Once running, the application will be available at:
- http://localhost:5000
## Notes
- The production Dockerfile clones the latest version from the GitHub repository
- The local Dockerfile uses the current source files for development
- The application runs on port 5000 inside the container
- Environment is set to Production by default in Docker containers
## Troubleshooting
If you encounter SSL certificate issues during build, you can:
1. Use the local Dockerfile instead: `docker build -f Dockerfile.local -t shiftscheduler .`
2. Build with network host mode: `docker build --network=host -t shiftscheduler .`
3. Configure Docker to use system certificates if needed

38
Dockerfile Normal file
View file

@ -0,0 +1,38 @@
# 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
# Copy the project files from current directory
# Note: In production, replace this with git clone or download from repository
# For example: RUN git clone https://github.com/clayschaad/ShiftScheduler.git .
COPY . .
# 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"]

37
Dockerfile.local Normal file
View file

@ -0,0 +1,37 @@
# 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
# Copy the project files from current directory (for local development)
# In production, you would clone the repository here instead
COPY . .
# 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"]

45
Dockerfile.production Normal file
View file

@ -0,0 +1,45 @@
# Production Dockerfile for ShiftScheduler
# This version clones the repository from GitHub to always get the latest version
# 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
RUN apt-get update && \
apt-get install -y git && \
rm -rf /var/lib/apt/lists/*
# Clone the git repository to always have the actual version of ShiftScheduler
RUN git clone https://github.com/clayschaad/ShiftScheduler.git . || \
git -c http.sslVerify=false clone https://github.com/clayschaad/ShiftScheduler.git .
# 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"]

20
docker-compose.yml Normal file
View file

@ -0,0 +1,20 @@
version: '3.8'
services:
shiftscheduler:
build:
context: .
dockerfile: Dockerfile
ports:
- "5000:5000"
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_URLS=http://+:5000
restart: unless-stopped
container_name: shiftscheduler-app
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/", "||", "exit", "1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s