-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathdocker-debug.sh
More file actions
90 lines (77 loc) · 2.94 KB
/
docker-debug.sh
File metadata and controls
90 lines (77 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
# Debug Docker Setup Script for Document Translation Web Application
# This script sets up Docker debugging with VS Code
set -e # Exit on any error
# Configuration
IMAGE_NAME="document-translation-web"
DEBUG_TAG="debug"
CONTAINER_NAME="document-translation-debug"
DEBUG_PORT="5000"
echo "🐛 Setting up Docker debugging for Document Translation Web Application"
echo "======================================================================"
# Ensure we're in the right directory
if [ ! -f "Dockerfile.debug" ]; then
echo "❌ Error: Dockerfile.debug not found. Make sure you're in the project root directory."
exit 1
fi
if [ ! -f "DocumentTranslation.Web/DocumentTranslation.Web.csproj" ]; then
echo "❌ Error: Web project not found. Make sure you're in the project root directory."
exit 1
fi
echo "📋 Debug Configuration:"
echo " - Image Name: ${IMAGE_NAME}:${DEBUG_TAG}"
echo " - Container Name: ${CONTAINER_NAME}"
echo " - Debug Port: ${DEBUG_PORT}"
echo " - .NET Version: 9.0"
echo ""
# Stop and remove existing debug container if it exists
if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
echo "🛑 Stopping existing debug container..."
docker stop "$CONTAINER_NAME" || true
echo "🗑️ Removing existing debug container..."
docker rm "$CONTAINER_NAME" || true
fi
# Build the debug Docker image
echo "🔨 Building debug Docker image..."
docker build \
--file Dockerfile.debug \
--build-arg BUILD_CONFIGURATION=Debug \
--tag "${IMAGE_NAME}:${DEBUG_TAG}" \
--progress=plain \
.
if [ $? -eq 0 ]; then
echo ""
echo "✅ Debug Docker image built successfully!"
echo ""
# Show image information
echo "📊 Debug Image Information:"
docker images "${IMAGE_NAME}" --filter "reference=${IMAGE_NAME}:${DEBUG_TAG}" --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
echo ""
echo "🚀 Debug container is ready!"
echo ""
echo "🔧 To debug in VS Code:"
echo " 1. Open VS Code in this workspace"
echo " 2. Press F5 or go to Run and Debug"
echo " 3. Select 'Docker .NET Launch' configuration"
echo " 4. Set breakpoints in your code"
echo " 5. Start debugging!"
echo ""
echo "🌐 Manual debug run:"
echo " docker run -d -p ${DEBUG_PORT}:80 --name ${CONTAINER_NAME} ${IMAGE_NAME}:${DEBUG_TAG}"
echo ""
echo "🔍 Debug endpoints:"
echo " - Application: http://localhost:${DEBUG_PORT}"
echo " - Health Check: http://localhost:${DEBUG_PORT}/health"
echo " - Swagger UI: http://localhost:${DEBUG_PORT}/swagger"
echo ""
echo "📋 VS Code debugging features:"
echo " - Set breakpoints in C# code"
echo " - Step through code execution"
echo " - Inspect variables and call stack"
echo " - Hot reload for code changes"
echo " - Debug console output"
else
echo ""
echo "❌ Debug Docker build failed!"
exit 1
fi