Files
IGP-Fan-Reference/docs/AI Help Docs/containerize-and-run.md

1.7 KiB
Raw Permalink Blame History

Containerizing the IGP App with Docker

Steps Performed

1. Created a MultiStage Dockerfile (Dockerfile)

Two stages:

Stage Image Purpose
build mcr.microsoft.com/dotnet/sdk:10.0 Restores dependencies, builds, and publishes the Blazor WASM app
final nginx:alpine Copies the published wwwroot/ output and a custom nginx.conf that serves it

2. Created a Custom nginx Config (nginx.conf)

  • Listens on port 8887 (not the default 80) so it doesn't conflict with other containers.
  • Adds Blazorrequired MIME types: application/wasm (.wasm), application/octet-stream (.dll, .blat, .dat, .webcil).
  • Enables gzip_static so precompressed .gz variants are served automatically.
  • Implements SPA fallback: try_files $uri $uri/ /index.html for clientside routing.

3. Built the Image

docker build -t igp-app:latest -f Dockerfile .

Result: docker.io/library/igp-app:latest

4. Ran the Container

docker run -d --name igp-app -p 8887:8887 igp-app:latest

The container is now serving at http://localhost:8887.

5. Verified

  • docker ps shows the container Up and port mapping 0.0.0.0:8887->8887/tcp.
  • curl http://localhost:8887/ returns HTTP 200.

Files

File Purpose
Dockerfile Multistage build: .NET SDK → publish → nginx
nginx.conf nginx config with Blazor MIME types, gzip, SPA fallback, port 8887

How to Stop

docker stop igp-app
docker rm igp-app

How to Rebuild

docker build -t igp-app:latest -f Dockerfile .
docker rm -f igp-app
docker run -d --name igp-app -p 8887:8887 igp-app:latest