Docker Deployment Spec for KwestKarz - wwestlake/KwestKarz GitHub Wiki

🐳 Docker Deployment Spec for KwestKarz

This specification outlines how to containerize and deploy the KwestKarz application using Docker and Docker Compose. The project consists of a .NET backend and a React frontend.


📁 Project Structure Assumption

/KwestKarz
│
├── backend/          # ASP.NET Core Web API
│   ├── KwestKarz.API/
│   └── ...
│
├── frontend/         # React App
│   ├── public/
│   ├── src/
│   └── ...
│
├── docker-compose.yml
└── nginx/
    └── default.conf

1️⃣ Dockerfile for .NET Backend

Path: backend/KwestKarz.API/Dockerfile

# Stage 1: Build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app

COPY backend/KwestKarz.API/*.csproj ./
RUN dotnet restore

COPY backend/KwestKarz.API/. ./
RUN dotnet publish -c Release -o out

# Stage 2: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/out .

ENTRYPOINT ["dotnet", "KwestKarz.API.dll"]

2️⃣ Dockerfile for React Frontend

Path: frontend/Dockerfile

# Build React app
FROM node:20-alpine AS build
WORKDIR /app

COPY frontend/package*.json ./
RUN npm install

COPY frontend/ ./
RUN npm run build

# Serve with Nginx
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx/default.conf /etc/nginx/conf.d/default.conf

3️⃣ Nginx Configuration

Path: nginx/default.conf

server {
    listen 80;
    server_name localhost;

    root /usr/share/nginx/html;
    index index.html;

    location / {
        try_files $uri /index.html;
    }
}

4️⃣ Docker Compose Setup

Path: docker-compose.yml

version: '3.8'

services:
  backend:
    build:
      context: .
      dockerfile: backend/KwestKarz.API/Dockerfile
    ports:
      - "5000:80"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
    depends_on:
      - db

  frontend:
    build:
      context: .
      dockerfile: frontend/Dockerfile
    ports:
      - "3000:80"
    depends_on:
      - backend

  db:
    image: mcr.microsoft.com/mssql/server:2022-latest
    environment:
      SA_PASSWORD: "YourStrong!Passw0rd"
      ACCEPT_EULA: "Y"
    ports:
      - "1433:1433"

✅ Deployment Commands

# Build and run
docker-compose up --build

# Run in detached mode
docker-compose up -d

# Stop containers
docker-compose down

📌 Notes

  • Update backend connection strings to use db instead of localhost.
  • You may wish to add volume mounts to persist database data.
  • Add HTTPS, CORS config, and secrets management for production environments as needed.

🔧 Optional Enhancements

  • .env file support for environment variables
  • CI/CD deployment pipeline (GitHub Actions, Azure DevOps, etc.)
  • Kubernetes manifests for cloud-native deployment