Created
May 2, 2019 14:32
-
-
Save leapingbytes/b046a1309ca8fa6c75e2b2bf6dc45720 to your computer and use it in GitHub Desktop.
Dockerizing simple c# app
This file contains 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
docker build -t xxx . |
This file contains 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
FROM microsoft/dotnet:2.2-sdk as sdk | |
# RUN dotnet tool install -g dotnet-warp | |
RUN curl -Lo /root/warp-packer https://github.com/dgiagio/warp/releases/download/v0.3.0/linux-x64.warp-packer | |
RUN chmod +x /root/warp-packer | |
RUN mkdir /build | |
COPY Program.cs MyApp.csproj /build/ | |
WORKDIR /build | |
RUN dotnet restore | |
# RUN /root/.dotnet/tools/dotnet-warp | |
RUN dotnet publish -c Release -r linux-musl-x64 --self-contained | |
RUN /root/warp-packer --arch linux-x64 --input_dir bin/Release/netcoreapp2.2/linux-musl-x64/publish --exec MyApp --output MyApp | |
FROM scratch | |
WORKDIR /root/ | |
COPY --from=sdk /build/MyApp . | |
CMD ["./MyApp"] | |
This file contains 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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp2.2</TargetFramework> | |
</PropertyGroup> | |
</Project> |
This file contains 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
using System; | |
using System.Collections.Generic; | |
namespace list_tutorial | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var names = new List<string> { "<name>", "Ana", "Felipe" }; | |
foreach (var name in names) | |
{ | |
Console.WriteLine($"Hello {name.ToUpper()}!"); | |
} | |
} | |
} | |
} |
This file contains 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
docker run xxx:latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment