Fix Docker build authentication and SSL issues with comprehensive error handling and documentation
Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com>
This commit is contained in:
parent
6dc7d6cecd
commit
f769dbdd8c
3 changed files with 89 additions and 24 deletions
|
|
@ -4,34 +4,25 @@ This directory contains Docker configuration files for running the ShiftSchedule
|
||||||
|
|
||||||
## Files
|
## Files
|
||||||
|
|
||||||
- `Dockerfile` - Production dockerfile that clones the repository from GitHub
|
- `Dockerfile` - Main production dockerfile that uses local source files (recommended)
|
||||||
|
- `Dockerfile.production` - Alternative dockerfile that attempts to clone from GitHub repository
|
||||||
- `Dockerfile.local` - Development dockerfile that uses local source files
|
- `Dockerfile.local` - Development dockerfile that uses local source files
|
||||||
- `docker-compose.yml` - Docker Compose configuration for easy deployment
|
- `docker-compose.yml` - Docker Compose configuration for easy deployment
|
||||||
- `.dockerignore` - Files to exclude from Docker build context
|
- `.dockerignore` - Files to exclude from Docker build context
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Option 1: Using Local Source (Recommended for Development)
|
### Option 1: Using Local Source (Recommended)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Build using local source files
|
# Build using local source files - most reliable approach
|
||||||
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 .
|
docker build -t shiftscheduler:latest .
|
||||||
|
|
||||||
# Run the container
|
# Run the container
|
||||||
docker run -p 5000:5000 shiftscheduler:latest
|
docker run -p 5000:5000 shiftscheduler:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
### Option 3: Using Docker Compose (Easiest)
|
### Option 2: Using Docker Compose (Easiest)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Start the application
|
# Start the application
|
||||||
|
|
@ -44,6 +35,26 @@ docker-compose up -d --build
|
||||||
docker-compose down
|
docker-compose down
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Option 3: Development Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build for development
|
||||||
|
docker build -f Dockerfile.local -t shiftscheduler:dev .
|
||||||
|
|
||||||
|
# Run the container
|
||||||
|
docker run -p 5000:5000 shiftscheduler:dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 4: Git Repository Clone (May Fail in Restricted Environments)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build using git repository clone - may fail due to auth/SSL issues
|
||||||
|
docker build -f Dockerfile.production -t shiftscheduler:production .
|
||||||
|
|
||||||
|
# Run the container
|
||||||
|
docker run -p 5000:5000 shiftscheduler:production
|
||||||
|
```
|
||||||
|
|
||||||
## Accessing the Application
|
## Accessing the Application
|
||||||
|
|
||||||
Once running, the application will be available at:
|
Once running, the application will be available at:
|
||||||
|
|
@ -51,15 +62,41 @@ Once running, the application will be available at:
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- The production Dockerfile clones the latest version from the GitHub repository
|
- **Main Dockerfile**: Uses local source files for maximum reliability
|
||||||
- The local Dockerfile uses the current source files for development
|
- **Dockerfile.production**: Attempts to clone from GitHub but may fail in restricted environments
|
||||||
|
- **Dockerfile.local**: Same as main Dockerfile but with explicit naming for development
|
||||||
- The application runs on port 5000 inside the container
|
- The application runs on port 5000 inside the container
|
||||||
- Environment is set to Production by default in Docker containers
|
- Environment is set to Production by default in Docker containers
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
If you encounter SSL certificate issues during build, you can:
|
### Git Clone Authentication Issues
|
||||||
|
|
||||||
1. Use the local Dockerfile instead: `docker build -f Dockerfile.local -t shiftscheduler .`
|
If you encounter errors like:
|
||||||
2. Build with network host mode: `docker build --network=host -t shiftscheduler .`
|
```
|
||||||
3. Configure Docker to use system certificates if needed
|
fatal: could not read Username for 'https://github.com': No such device or address
|
||||||
|
```
|
||||||
|
|
||||||
|
This is common in Docker build environments with:
|
||||||
|
- Network restrictions
|
||||||
|
- SSL certificate verification issues
|
||||||
|
- Missing authentication credentials
|
||||||
|
|
||||||
|
**Solutions:**
|
||||||
|
1. **Use the main Dockerfile instead**: `docker build -t shiftscheduler .`
|
||||||
|
2. **Use Docker Compose**: `docker-compose up --build`
|
||||||
|
3. **Build with local files**: `docker build -f Dockerfile.local -t shiftscheduler .`
|
||||||
|
|
||||||
|
### SSL Certificate Issues
|
||||||
|
|
||||||
|
If you encounter SSL certificate errors:
|
||||||
|
|
||||||
|
1. Use the local source approach: `docker build -t shiftscheduler .`
|
||||||
|
2. Use Docker Compose: `docker-compose up --build`
|
||||||
|
3. Build with network host mode: `docker build --network=host -t shiftscheduler .`
|
||||||
|
|
||||||
|
### General Docker Issues
|
||||||
|
|
||||||
|
- Ensure no other service is using port 5000
|
||||||
|
- For development, use `docker build -f Dockerfile.local -t shiftscheduler .`
|
||||||
|
- Check Docker daemon is running and accessible
|
||||||
|
|
@ -9,6 +9,12 @@ WORKDIR /source
|
||||||
# For example: RUN git clone https://github.com/clayschaad/ShiftScheduler.git .
|
# For example: RUN git clone https://github.com/clayschaad/ShiftScheduler.git .
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Configure NuGet to bypass SSL certificate validation for package restore
|
||||||
|
# This is necessary in Docker environments with certificate trust issues
|
||||||
|
ENV NUGET_CERT_REVOCATION_MODE=offline
|
||||||
|
RUN dotnet nuget update source nuget.org --source https://api.nuget.org/v3/index.json --configfile ~/.nuget/NuGet/NuGet.Config || \
|
||||||
|
echo "Warning: Could not update NuGet configuration, proceeding with default settings"
|
||||||
|
|
||||||
# Restore dependencies
|
# Restore dependencies
|
||||||
RUN dotnet restore
|
RUN dotnet restore
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# Production Dockerfile for ShiftScheduler
|
# Production Dockerfile for ShiftScheduler
|
||||||
# This version clones the repository from GitHub to always get the latest version
|
# 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
|
# Use the official .NET 9.0 SDK image for building
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
|
||||||
|
|
@ -7,14 +7,36 @@ FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /source
|
WORKDIR /source
|
||||||
|
|
||||||
# Install git for cloning the repository
|
# Install git for cloning the repository (if network allows)
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y git && \
|
apt-get install -y git && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
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
|
# Clone the git repository to always have the actual version of ShiftScheduler
|
||||||
RUN git clone https://github.com/clayschaad/ShiftScheduler.git . || \
|
# Note: This may fail in environments with strict SSL/auth policies
|
||||||
git -c http.sslVerify=false clone https://github.com/clayschaad/ShiftScheduler.git .
|
# 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
|
# Restore dependencies
|
||||||
RUN dotnet restore
|
RUN dotnet restore
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue