1.7 KiB
1.7 KiB
Containerizing the IGP App with Docker
Steps Performed
1. Created a Multi‑Stage 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 Blazor‑required MIME types:
application/wasm(.wasm),application/octet-stream(.dll,.blat,.dat,.webcil). - Enables
gzip_staticso pre‑compressed.gzvariants are served automatically. - Implements SPA fallback:
try_files $uri $uri/ /index.htmlfor client‑side 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 psshows the containerUpand port mapping0.0.0.0:8887->8887/tcp.curl http://localhost:8887/returns HTTP200.
Files
| File | Purpose |
|---|---|
Dockerfile |
Multi‑stage 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