s2i-aspnet Example Projects
This repository contains an example project that can be built using the s2i-aspnet builder image, which can be used to create reproducible Docker images from your ASP.NET project’s source code. The resulting images can be run using Docker or deployed to OpenShift.
For more information about using these images with OpenShift, please see the official OpenShift Documentation.
Building and Running
The sample application can be built and run either within OpenShift or standalone by combining the application using s2i tool and running with existing image using Docker. The following sections describes these processes
OpenShift
After logging into an OpenShift environment and creating or using an existing project, create a new application which combines the ASP.NET S2I builder and the sample application from this repository
oc new-app registry.access.redhat.com/dotnet/dotnetcore-10-rhel7~https://github.com/openshift-s2i/s2i-aspnet-example --context-dir=app --name=aspnet-app
Create a new route so that the application is accessible outside the OpenShift environment
oc expose service aspnet-app
The application will now be available at http://aspnet-app-<project>.<default_subdomain>;
Use a template to build and deploy a sample application
A template has been provided to simplify the build and deployment of a ASP.NET application on OpenShift. The template is located in the templates
folder in a file called [aspnet-s2i-template.json](templates/aspnet-s2i-template.json).
After logging into an OpenShift environment and creating or using an existing project, add the template to the project
oc create -f templates/aspnet-s2i-template.json
Note
|
Alternately, the template can be added to the
|
Instantiate the template to build and deploy the sample application
oc new-app --template=aspnet-s2i -p GIT_URI=https://github.com/openshift-s2i/s2i-aspnet-example,GIT_CONTEXT_DIR=app
The template can also be instantiated using the OpenShift web console. Login to the console and navigate to the desired project. Click the Add to Project button. Search and select the aspnet-s2i
.
Set the following parameters:
-
Git URI - https://github.com/openshift-s2i/s2i-aspnet-example
-
Git Context Directory - app
Click Create to start a build and deploy the sample application.
Once the build has completed and the resulting container started, the application will be available at http://aspnet-app-<project>.<default_subdomain>;
Standalone
To build a new ASP.NET application using a previously existing S2I builder, execute the following command:
git clone https://github.com/openshift-s2i/s2i-aspnet-example.git
cd s2i-aspnet-example
s2i build app/ aspapp aspnet-app --loglevel=5
The resulting image can be executed using docker:
docker run -t -p 5000:5000 aspnet-app
Once the container is running, it should be accessible using:
curl 127.0.0.1:5000
Liveness and Readiness Application Health
The template has been configured with a liveness and readiness probe of which you can read more at https://docs.openshift.com/enterprise/latest/dev_guide/application_health.html. It checks if the container is healthy by doing a HTTP call to the root application. It checks if the application is ready by performing an HTTP call to /Home/About. If you’d like to see how the probe is working, just oc log -f <pod>
.
Contributing
Contributions to this project (in the form of bug reports, patches, or pull requests) are gratefully accepted by the maintainer. Please see the Contributing.adoc file contained in this package for details.
Copyright and License
Copyright 2016 by Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this package except in compliance with the License (see the LICENSE
file
included in this distribution). You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.