Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d2a4446
refactor(http): use IHttpClientFactory for ProductsService and fix …
Jul 5, 2026
7fdde6d
- Add get-by-id and create endpoints + unit tests
Jul 5, 2026
2ddccfe
chore: merge feat/extend-products into feat/create-categories
Jul 5, 2026
d178c88
- Add categories service, endpoints and unit tests
Jul 5, 2026
6b4ed2e
Add JWT token support for third-party API
Jul 5, 2026
e85d44d
Performance and logging Middleware :
Jul 5, 2026
07104f1
Mainly house keeping , moving code around
Jul 6, 2026
b78019e
chore(docker): add docker-compose, mock upstream json-server and API …
Jul 6, 2026
ad62066
chore(docker): remove compose version key
Jul 6, 2026
da353b8
chore(docker): move docker files to repo root
Jul 6, 2026
807bb75
chore(docker): use json-server:latest tag
Jul 6, 2026
aeeab1f
chore(docker): switch to clue/json-server image for mock upstream
Jul 6, 2026
7d50d1a
Add Docker support with multi-stage build and compose files
Jul 6, 2026
edf6ef1
Merge branch 'feat/-add-docker-support-to-solution' of https://github…
Jul 6, 2026
fef36ef
Implement CQRS (Command Query Responsibility Segregation) pattern acr…
Jul 6, 2026
aba3aa5
Move versioned endpoints to separate files and align tests with CQRS
Jul 7, 2026
93458d4
Refactor CQRS handlers to use IHttpClientFactory for proper HTTP clie…
Jul 7, 2026
282fed4
Small improvements: Docker warnings, test file naming, and nullable a…
Jul 7, 2026
9dd1e68
Implement MediatR pipeline validation with FluentValidation
Jul 7, 2026
94d6165
Clean up :
Jul 7, 2026
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
45 changes: 45 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Build results
**/bin/
**/obj/
**/out/
**/publish/

# Test results
**/*Tests/TestResults/
**/*.trx
**/*.coverage

# User-specific files
**/*.user
**/*.suo
**/*.userosscache
**/.vs/

# Build artifacts
**/.vscode/
**/.idea/
*.sln.DotSettings.user

# Git
.git/
.gitignore
.gitattributes

# Docker
**/.dockerignore
**/Dockerfile*
**/docker-compose*

# Documentation
**/*.md
!README.Docker.md

# NuGet
**/*.nupkg
**/.nuget/

# Misc
**/node_modules/
**/npm-debug.log
**/.DS_Store
**/Thumbs.db
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Build stage
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src

# Copy solution and project files
COPY src/*.sln ./
COPY src/CSharpApp.Api/*.csproj ./CSharpApp.Api/
COPY src/CSharpApp.Application/*.csproj ./CSharpApp.Application/
COPY src/CSharpApp.Core/*.csproj ./CSharpApp.Core/
COPY src/CSharpApp.Infrastructure/*.csproj ./CSharpApp.Infrastructure/
COPY src/CSharpApp.Models/*.csproj ./CSharpApp.Models/
COPY src/test/CSharpApp.Tests/*.csproj ./test/CSharpApp.Tests/

# Restore dependencies
RUN dotnet restore

# Copy all source code
COPY src/ ./

# Build and publish
RUN dotnet publish CSharpApp.Api/CSharpApp.Api.csproj -c Release -o /app/publish /p:UseAppHost=false

# Runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
WORKDIR /app

# Create non-root user
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser

# Copy published app
COPY --from=build /app/publish .

# Expose port
EXPOSE 8080

# Set environment variables
ENV ASPNETCORE_URLS=http://+:8080
ENV ASPNETCORE_ENVIRONMENT=Production

ENTRYPOINT ["dotnet", "CSharpApp.Api.dll"]
199 changes: 199 additions & 0 deletions QUICKSTART.Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# Docker Quick Start Guide

## 🚀 Getting Started with Docker

All Docker files have been successfully added to your repository!

### 📁 Files Created:

1. **Dockerfile** - Multi-stage build configuration
2. **docker-compose.yml** - Production configuration
3. **docker-compose.override.yml** - Development overrides
4. **.dockerignore** - Build optimization
5. **README.Docker.md** - Complete documentation

---

## ⚡ Quick Commands

### Build and Run
```powershell
# Navigate to repository root
cd C:\Users\Boss\source\repos\novibet

# Build and start the application
docker-compose up --build

# Run in detached mode (background)
docker-compose up -d --build
```

### Access the API
- **API Base URL**: http://localhost:8080
- **Products Endpoint**: http://localhost:8080/api/v1/products
- **Categories Endpoint**: http://localhost:8080/api/v1/categories

### Test the API
```powershell
# Get all products
curl http://localhost:8080/api/v1/products

# Get product by ID
curl http://localhost:8080/api/v1/products/1

# Get all categories
curl http://localhost:8080/api/v1/categories
```

### View Logs
```powershell
# Follow logs in real-time
docker-compose logs -f

# View last 50 lines
docker-compose logs --tail=50
```

### Stop the Application
```powershell
# Stop containers
docker-compose down

# Stop and remove volumes
docker-compose down -v
```

---

## 🔧 Development Mode

For enhanced debugging and logging:

```powershell
docker-compose -f docker-compose.yml -f docker-compose.override.yml up --build
```

This enables:
- ✅ Development environment
- ✅ Debug-level logging
- ✅ Detailed HTTP client logs

---

## 📦 What's Included

### Dockerfile Features:
- ✅ .NET 9 SDK for build stage
- ✅ .NET 9 ASP.NET Core runtime for production
- ✅ Multi-stage build (optimized image size ~100MB)
- ✅ Non-root user for security
- ✅ Port 8080 exposed

### Docker Compose Features:
- ✅ Automatic health checks
- ✅ Environment variable configuration
- ✅ Network isolation
- ✅ Restart policy (unless-stopped)
- ✅ Development overrides

### Security Features:
- ✅ Non-root user (appuser)
- ✅ No build tools in production image
- ✅ Minimal attack surface
- ✅ Environment-based secrets

---

## 🐛 Troubleshooting

### Port 8080 Already in Use
Edit `docker-compose.yml` and change:
```yaml
ports:
- "8081:8080" # Use different host port
```

### View Container Details
```powershell
# List running containers
docker ps

# Inspect container
docker inspect csharpapp-api

# Enter container shell
docker exec -it csharpapp-api /bin/bash
```

### Rebuild from Scratch
```powershell
docker-compose down
docker-compose build --no-cache
docker-compose up
```

---

## 📚 Next Steps

1. **Test the build**: `docker-compose up --build`
2. **Verify endpoints**: Access http://localhost:8080/api/v1/products
3. **Review logs**: `docker-compose logs -f`
4. **Read full docs**: See `README.Docker.md` for complete documentation
5. **Commit changes**: Add Docker files to Git

---

## 🎯 Git Commands

```powershell
# Stage Docker files
git add Dockerfile docker-compose.yml docker-compose.override.yml .dockerignore README.Docker.md QUICKSTART.Docker.md

# Commit changes
git commit -m "feat: add Docker support to solution"

# Push to remote
git push origin feat/-add-docker-support-to-solution
```

---

## 📖 Full Documentation

For detailed information, see **README.Docker.md** which includes:
- Complete configuration options
- Security best practices
- CI/CD integration examples
- Production deployment guide
- Performance tuning tips
- Monitoring and logging setup

---

## ✅ Validation Checklist

Before pushing to production:

- [ ] Docker build completes successfully
- [ ] Application starts and responds to requests
- [ ] Health checks pass
- [ ] Logs show no errors
- [ ] API endpoints return expected responses
- [ ] Environment variables are configured correctly
- [ ] Security scan passes (optional: `docker scan csharpapp-api:latest`)

---

## 🆘 Support

For issues or questions:
1. Check logs: `docker-compose logs -f`
2. Review README.Docker.md troubleshooting section
3. Verify Docker Desktop is running
4. Ensure port 8080 is available
5. Check network connectivity

---

**Happy containerizing! 🐳**
Loading