{"id":23459418,"url":"https://github.com/devkimchi/msbuild-for-containers","last_synced_at":"2026-01-25T17:02:13.401Z","repository":{"id":251490249,"uuid":"836311227","full_name":"devkimchi/msbuild-for-containers","owner":"devkimchi","description":"This provides sample .NET apps using container images with Dockerfile, with MSBuild, and with .NET Aspire support on Docker Desktop.","archived":false,"fork":false,"pushed_at":"2024-08-10T06:09:27.000Z","size":131,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T22:36:37.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devkimchi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-31T15:19:49.000Z","updated_at":"2024-08-18T18:12:58.000Z","dependencies_parsed_at":"2024-08-03T12:45:10.833Z","dependency_job_id":"d90a5c58-81ec-4981-b93f-b7f522935350","html_url":"https://github.com/devkimchi/msbuild-for-containers","commit_stats":null,"previous_names":["devkimchi/msbuild-for-containers"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devkimchi/msbuild-for-containers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devkimchi%2Fmsbuild-for-containers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devkimchi%2Fmsbuild-for-containers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devkimchi%2Fmsbuild-for-containers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devkimchi%2Fmsbuild-for-containers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devkimchi","download_url":"https://codeload.github.com/devkimchi/msbuild-for-containers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devkimchi%2Fmsbuild-for-containers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28755561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T16:32:25.380Z","status":"ssl_error","status_checked_at":"2026-01-25T16:32:09.189Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-24T06:14:29.734Z","updated_at":"2026-01-25T17:02:13.384Z","avatar_url":"https://github.com/devkimchi.png","language":"CSS","readme":"# MSBuild for Containers\r\n\r\nAs a .NET developer, when you build a container image for your app, you can use the `Dockerfile` to define the container image. However, you can also use the `dotnet publish` command to build and publish the container image without a `Dockerfile`. This repository provides sample .NET apps using container images with `Dockerfile` and with `dotnet publish`.\r\n\r\nIn addition to that, if you want to orchestrate containers Docker Compose is usually the first approach. However, you can also use the .NET Aspire to generate the Docker Compose file from the .NET Aspire manifest JSON file. This repository also provides a sample .NET app using the .NET Aspire to orchestrate containers.\r\n\r\n## Prerequisites\r\n\r\n- [.NET SDK 8.0+](https://dotnet.microsoft.com/download/dotnet/8.0?WT.mc_id=dotnet-144884-juyoo) with [.NET Aspire workload](https://learn.microsoft.com/dotnet/aspire/fundamentals/setup-tooling?WT.mc_id=dotnet-144884-juyoo)\r\n- [Visual Studio](https://visualstudio.microsoft.com/?WT.mc_id=dotnet-144884-juyoo) or [Visual Studio Code](https://code.visualstudio.com/?WT.mc_id=dotnet-144884-juyoo) + [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit)\r\n- [Aspirate](https://github.com/prom3theu5/aspirational-manifests)\r\n- [Docker Desktop](https://www.docker.com/products/docker-desktop)\r\n\r\n## Getting Started\r\n\r\n### Run with `Dockerfile`\r\n\r\n1. Run `docker init` to create a new Dockerfile for web app.\r\n\r\n    ```bash\r\n    pushd ./MSBuildForContainers.WebApp\r\n    \r\n    docker init\r\n    docker build . -t webapp:latest\r\n    docker run -d -p 3000:8080 webapp:latest\r\n    \r\n    popd\r\n    ```\r\n\r\n1. Run `docker init` to create a new Dockerfile for API app.\r\n\r\n    ```bash\r\n    pushd ./MSBuildForContainers.ApiApp\r\n    \r\n    docker init\r\n    docker build . -t apiapp:latest\r\n    docker run -d -p 5050:8080 apiapp:latest\r\n    \r\n    popd\r\n    ```\r\n\r\n1. Open the browser and navigate to `http://localhost:3000` to see the web app running and `http://localhost:5050` to see the API app running.\r\n\r\n### Run without `Dockerfile`\r\n\r\n1. Run the following `dotnet publish` command to build and publish the web app.\r\n\r\n    ```bash\r\n    dotnet publish ./MSBuildForContainers.WebApp \\\r\n        -t:PublishContainer \\\r\n        --os linux --arch x64\r\n\r\n    docker run -d -p 3000:8080 webapp:latest\r\n    ```\r\n\r\n1. Run the following `dotnet publish` command to build and publish the web app.\r\n\r\n    ```bash\r\n    dotnet publish ./MSBuildForContainers.ApiApp \\\r\n        -t:PublishContainer \\\r\n        --os linux --arch x64\r\n    \r\n    docker run -d -p 5050:8080 apiapp:latest\r\n    ```\r\n\r\n1. If you want to change the base image to Ubuntu Chiseled image, use the following command.\r\n\r\n    ```bash\r\n    dotnet publish ./MSBuildForContainers.ApiApp \\\r\n        -t:PublishContainer \\\r\n        --os linux --arch x64 \\\r\n        -p:ContainerBaseImage=mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled \\\r\n        -p:ContainerRepository=apiapp \\\r\n        -p:ContainerImageTag=latest\r\n    \r\n    dotnet publish ./MSBuildForContainers.WebApp \\\r\n        -t:PublishContainer \\\r\n        --os linux --arch x64 \\\r\n        -p:ContainerBaseImage=mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled \\\r\n        -p:ContainerRepository=webapp \\\r\n        -p:ContainerImageTag=latest\r\n\r\n    docker run -d -p 3000:8080 webapp:latest\r\n    docker run -d -p 5050:8080 apiapp:latest\r\n    ```\r\n\r\n1. Check Docker Desktop to see the container image size and compare it from the previous step.\r\n1. Open the browser and navigate to `http://localhost:3000` to see the web app running and `http://localhost:5050` to see the API app running.\r\n\r\n### Run with Docker Compose\r\n\r\n1. Update the web app to reference API app by commenting and uncommenting the `Program.cs` file in the `MSBuildForContainers.WebApp` project.\r\n1. Run the following command to rebuild the container image.\r\n\r\n    ```bash\r\n    dotnet publish ./MSBuildForContainers.WebApp \\\r\n        -t:PublishContainer \\\r\n        --os linux --arch x64 \\\r\n        -p:ContainerBaseImage=mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled \\\r\n        -p:ContainerRepository=webapp \\\r\n        -p:ContainerImageTag=latest\r\n    ```\r\n\r\n1. Run the following `docker compose` command to run both apps.\r\n\r\n    ```bash\r\n    docker compose -f ./docker-compose.yaml up\r\n    ```\r\n\r\n1. Open the browser and navigate to `http://localhost:3000` to see the web app running and `http://localhost:5050` to see the API app running.\r\n\r\n## Orchestrate with .NET Aspire\r\n\r\n1. Switch to the `aspire` branch.\r\n\r\n    ```bash\r\n    git switch aspire\r\n    ```\r\n\r\n1. Run the following command to see whether the .NET Aspire dashboard is running\r\n\r\n    ```bash\r\n    dotnet watch run --project ./MSBuildForContainers.AppHost\r\n    ```\r\n\r\n1. Generate .NET Aspire manifest JSON file.\r\n\r\n    ```bash\r\n    dotnet run --project ./MSBuildForContainers.AppHost \\\r\n        -- \\\r\n        --publisher manifest \\\r\n        --output-path ../aspire-manifest.json\r\n    ```\r\n\r\n1. Generate the Docker Compose file from the .NET Aspire manifest JSON file.\r\n\r\n    ```bash\r\n    aspirate generate \\\r\n        --project-path ./MSBuildForContainers.AppHost \\\r\n        --aspire-manifest ./aspire-manifest.json \\\r\n        --output-format compose \\\r\n        --disable-secrets --include-dashboard false\r\n    ```\r\n\r\n1. Run the Docker Compose file generated by the .NET Aspire.\r\n\r\n    ```bash\r\n    docker compose -f ./aspirate-output/docker-compose.yaml up\r\n    ```\r\n\r\n1. Open the browser and navigate to `http://localhost:10002` to see the web app running and `http://localhost:10000` to see the API app running.\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevkimchi%2Fmsbuild-for-containers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevkimchi%2Fmsbuild-for-containers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevkimchi%2Fmsbuild-for-containers/lists"}