This repository contains the source for building a container image that can be used as a base in which to run already built .NET Core applications.
The container image can be used as a base image using docker/podman.
Or you can build an application image using s2i.
The image can be run using docker
/podman
.
The distributale binaries of an application should be copied to this image and a new docker image should be created using this image as the base.
For example to create an image for s2i-dotnetcore-ex
Publish the application:
$ git clone -b dotnetcore-2.2 https://github.com/redhat-developer/s2i-dotnetcore-ex.git
$ cd s2i-dotnetcore-ex/app
$ dotnet publish -c Release /p:MicrosoftNETPlatformLibrary=Microsoft.NETCore.App
To create an image using s2i
:
$ s2i build bin/Release/netcoreapp2.2/publish dotnet/dotnet-22-runtime-rhel7 s2i-dotnetcore-ex
To create an image using docker
/podman
:
$ cat > Dockerfile <<EOF
FROM dotnet/dotnet-22-runtime-rhel7
ADD bin/Release/netcoreapp2.2/publish/. .
CMD [ "dotnet", "app.dll" ]
EOF
$ docker build -t s2i-dotnetcore-ex .
Start a container:
$ docker run --rm -p 8080:8080 s2i-dotnetcore-ex
Visit the web application that is running in the container with a browser at [http://localhost:8080].
-
Dockerfile.rhel7
RHEL based Dockerfile. In order to perform build or test actions on this Dockerfile you need to run the action on a properly subscribed RHEL machine.
-
Dockerfile
CentOS based Dockerfile.
-
test/
This folder contains binary archives of S2I dotnet sample applications.
-
asp-net-hello-world/
ASP .Net hello world example app used for testing purposes. Sources are precompiled in
app.tar.gz
. See build-project.sh for as to how to produce the binary.
-
The following variables are set so they can be used from scripts. They must not to be overridden.
-
ASPNETCORE_URLS
This variable is set to
http://*:8080
to configure ASP.NET Core to use the port exposed by the image. -
DOTNET_APP_PATH,DOTNET_DEFAULT_CMD,DOTNET_DATA_PATH
These variables contain the working directory (
/opt/app-root/app
), the default CMD of the runtime image (default-cmd.sh
) and an empty folder you can use to store your application data (/opt/app-root/data
) and make persistent with a volume mount. -
DOTNET_SSL_DIRS
Used to specify a list of folders/files with additional certificates to trust. The certificates are trusted by each process that runs during the build and all processes that run in the image after the build (including the application that was built). The items can be absolute paths (starting with
/
) or paths in the source repository (e.g.certificates
). Defaults to ``. -
DOTNET_FRAMEWORK,DOTNET_CORE_VERSION
These variables contain the framework (
netcoreapp2.2
) and .NET Core version (2.2
) respectively. -
DOTNET_RUNNING_IN_CONTAINER
Like Microsoft images, this is set to
true
and can be used to detect the application is built/running in a container.