Skip to content

Instantly share code, notes, and snippets.

@ninjarobot
Created June 19, 2017 17:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninjarobot/dcbfecc1616d42537ef354f908bb6c93 to your computer and use it in GitHub Desktop.
Save ninjarobot/dcbfecc1616d42537ef354f908bb6c93 to your computer and use it in GitHub Desktop.
A minimal Alpine image using a self-contained .NET executable built with mkbundle.
FROM alpine
RUN echo 'using System; \
namespace Program { \
public class MyClass { \
public static void Main(string[] args) { \
Console.WriteLine ("Hello from C#"); \
} \
} \
}' >> Program.cs
RUN apk add --virtual build-dependencies --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing --no-cache mono mono-dev musl-dev binutils gcc && \
csc Program.cs && \
mkbundle --deps --static --config /etc/mono/config -L /usr/lib/mono/4.5 -o program Program.exe /usr/lib/mono/4.5/mscorlib.dll /usr/lib/mono/4.5/System.dll && \
apk del build-dependencies && \
apk add --no-cache libgcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment