Last active
December 6, 2025 12:27
-
-
Save Guiorgy/7c983ec949b7982470db82582dc654ea to your computer and use it in GitHub Desktop.
Publish a .NET AOT project for Linux on a Windows host using Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright © 2025 Guiorgy | |
| # | |
| # This program is free software: you can redistribute it and/or modify it under | |
| # the terms of the GNU General Public License as published by the Free Software | |
| # Foundation, either version 3 of the License, or (at your option) any later | |
| # version. | |
| # | |
| # This program is distributed in the hope that it will be useful, but WITHOUT | |
| # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| # FOR A PARTICULAR PURPOSE. | |
| # | |
| # You can see the full GNU General Public License at | |
| # <https://www.gnu.org/licenses/> for more details. | |
| services: | |
| builder: | |
| container_name: DotNet_Builder | |
| user: "${UID:-1000}" | |
| build: | |
| context: . | |
| dockerfile: Dockerfile.builder | |
| args: | |
| UID: "${UID:-1000}" | |
| working_dir: /build | |
| volumes: | |
| - .:/build:rw | |
| command: > | |
| /bin/sh -c ' | |
| dotnet publish MyApp.csproj /p:PublishProfile=Properties/PublishProfiles/Release.pubxml; | |
| ' | |
| # Usage: docker compose run --rm builder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright © 2025 Guiorgy | |
| # | |
| # This program is free software: you can redistribute it and/or modify it under | |
| # the terms of the GNU General Public License as published by the Free Software | |
| # Foundation, either version 3 of the License, or (at your option) any later | |
| # version. | |
| # | |
| # This program is distributed in the hope that it will be useful, but WITHOUT | |
| # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| # FOR A PARTICULAR PURPOSE. | |
| # | |
| # You can see the full GNU General Public License at | |
| # <https://www.gnu.org/licenses/> for more details. | |
| FROM mcr.microsoft.com/dotnet/sdk:10.0-aot | |
| RUN apt-get -qq update \ | |
| && apt-get -qq upgrade \ | |
| # Install dependencies, e.g. time zone data | |
| #&& apt-get -qq install \ | |
| # tzdata \ | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && dotnet workload update | |
| ARG UID=1000 | |
| RUN userdel ubuntu \ | |
| && useradd --non-unique --uid ${UID} --user-group --no-create-home --home /build --shell /sbin/nologin --comment Builder builder \ | |
| && mkdir /build \ | |
| && chown builder:builder /build | |
| USER builder:builder | |
| WORKDIR /build |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes
Modify
MyApp.csprojaccordingly.If you need to use a different SDK from
.NET 10.0, then change the base image tag frommcr.microsoft.com/dotnet/sdk:10.0-aot. You can find the full list of available .NET SDK tags here.