Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Β | Β | |||
Β | Β | |||
Β | Β | |||
Β | Β | |||
Β | Β | |||
Β | Β | |||
Β | Β | |||
Repository files navigation
README.txt
==========
Project: Multistage Docker Setup for Vue.js Frontend + ASP.NET Core Backend on IIS
-----------------------------------------------------------------------------------
This project demonstrates a multistage Docker build that:
β’ Builds a Vue.js single-page application
β’ Builds an ASP.NET Core Web API
β’ Combines both into a final IIS-based Windows container
The result is a single Docker image that serves your front-end on port 80 and your back-end on port 81.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1. Prerequisites
----------------
β’ Windows host (Server Core) with Docker Desktop installed and set to βWindows containersβ
β’ Docker CLI (docker build, docker run) available in PATH
β’ Git (to clone this repo)
β’ Ports 80 and 81 free on your machine
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
2. Directory Structure
----------------------
/project-root
/front/ β Vue.js source (package.json, src/, public/)
/back/ β ASP.NET Core source ( .csproj, Controllers/, Program.cs, etc.)
Dockerfile β Multistage build instructions
applicationHost.config (optional) β Custom IIS config
README.txt
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
3. Dockerfile Explanation
--------------------------
The Dockerfile contains three stages:
Stage 1 β Node build
β’ Base image: Windows Server Core
β’ Installs Node.js
β’ Copies /front, runs `npm install` and `npm run build`
β’ Outputs static files to `C:\app\dist`
Stage 2 β .NET build
β’ Base image: mcr.microsoft.com/dotnet/sdk:6.0-windowsservercore
β’ Copies /back, runs `dotnet publish -c Release`
β’ Outputs binaries to `C:\publish`
Stage 3 β Final IIS image
β’ Base image: mcr.microsoft.com/windows/servercore/iis:ltsc2022
β’ Installs the .NET Hosting Bundle
β’ Copies `C:\app\dist` β `C:\inetpub\wwwroot\front`
β’ Copies `C:\publish` β `C:\inetpub\wwwroot\back`
β’ Uses PowerShell to create two IIS sites:
β βFrontAppβ on port 80
β βBackAppβ on port 81
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
4. Building the Docker Image
-----------------------------
From the project root, run:
docker build -t weinno/multistage-app:latest .
This will download all necessary base images, build both front and back ends, and produce a final IIS image.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
5. Running the Container
-------------------------
Run the container with:
docker run -d ^
-p 80:80 `
-p 81:81 `
--name multistage-app `
weinno/multistage-app:latest
β’ Your Vue.js app is now at http://localhost/
β’ Your ASPβ.NET Core API is at http://localhost:81/
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
6. Configuration Tips
---------------------
β’ If you need custom IIS settings, add an `applicationHost.config` next to the Dockerfile.
β’ Verify that your back-end `.dll` names match those in `web.config` if you use one.
β’ Do not enable IIS logging in `web.config` β it may prevent containers from starting.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
7. Pushing to Harbor
--------------------
After building, tag and push to your private registry:
docker tag weinno/multistage-app:latest harbor.weinno.ir/library/multistage-app:latest
docker push harbor.weinno.ir/library/multistage-app:latest
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
8. Cleanup
----------
To stop and remove the running container:
docker stop multistage-app
docker rm multistage-app
To remove the image:
docker rmi weinno/multistage-app:latest
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
9. Support
----------
For questions, see our Confluence page:
https://confluence.weinno.ir/display/DOCKER/Multistage+Docker+Setup
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
_Last updated: 20 May 2025_