Skip to content

Commit 4870c9b

Browse files
authored
2.0: make DOTNET_FRAMEWORK a runtime image envvar and document runtime envvars (#133)
1 parent ee23ced commit 4870c9b

File tree

7 files changed

+48
-14
lines changed

7 files changed

+48
-14
lines changed

2.0/build/s2i/bin/_devmode_run

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ DOTNET_CONFIGURATION="${DOTNET_CONFIGURATION:-Release}"
88
if [ -z ${DOTNET_STARTUP_PROJECT+x} ]; then
99
DOTNET_STARTUP_PROJECT="."
1010
fi
11-
DOTNET_FRAMEWORK="netcoreapp2.0"
1211

1312
# Build nuget sources list for when doing the restore
1413
RESTORE_OPTIONS=""

2.0/build/s2i/bin/assemble

-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ if [ "$DOTNET_ASPNET_STORE" != "false" ]; then
4242
DOTNET_ASPNET_STORE="true"
4343
fi
4444

45-
# Private environment
46-
DOTNET_FRAMEWORK="netcoreapp2.0"
47-
4845
# Ensure there is a project file and derive assembly name from project name.
4946
PROJFILES=(`find "${DOTNET_STARTUP_PROJECT}" -maxdepth 1 -name "*.??proj"`)
5047
if [ ${#PROJFILES[@]} -eq 1 ]; then

2.0/build/test/run

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414
#
1515
# Example usage: $ sudo ./test/run
1616

17-
IMAGE_NAME=${IMAGE_NAME:-dotnet/dotnet-20-rhel7}
18-
RUNTIME_IMAGE_NAME=${RUNTIME_IMAGE_NAME:-dotnet/dotnet-20-runtime-rhel7}
17+
if [ "$BUILD_CENTOS" = "true" ]; then
18+
IMAGE_NAME=${IMAGE_NAME:-centos/dotnet-20-centos7}
19+
RUNTIME_IMAGE_NAME=${RUNTIME_IMAGE_NAME:-centos/dotnet-20-runtime-centos7}
20+
else
21+
IMAGE_NAME=${IMAGE_NAME:-dotnet/dotnet-20-rhel7}
22+
RUNTIME_IMAGE_NAME=${RUNTIME_IMAGE_NAME:-dotnet/dotnet-20-runtime-rhel7}
23+
fi
1924
OPENSHIFT_ONLY=${OPENSHIFT_ONLY:-false}
2025

2126
test_dir="$(readlink -zf $(dirname "${BASH_SOURCE[0]}"))"

2.0/runtime/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ FROM centos:7
44

55
EXPOSE 8080
66

7-
ENV DOTNET_CORE_VERSION=2.0
8-
97
# Default to UTF-8 file.encoding
108
ENV LANG=C.UTF-8 \
119
HOME=/opt/app-root \
1210
PATH=/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
1311
DOTNET_APP_PATH=/opt/app-root/app \
14-
DOTNET_DEFAULT_CMD=default-cmd.sh
12+
DOTNET_DEFAULT_CMD=default-cmd.sh \
13+
DOTNET_CORE_VERSION=2.0 \
14+
DOTNET_FRAMEWORK=netcoreapp2.0
1515

1616
LABEL io.k8s.description="Platform for running .NET Core 2.0 applications" \
1717
io.k8s.display-name=".NET Core 2.0" \

2.0/runtime/Dockerfile.rhel7

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ FROM rhel7
44

55
EXPOSE 8080
66

7-
ENV DOTNET_CORE_VERSION=2.0
8-
97
# Default to UTF-8 file.encoding
108
ENV LANG=C.UTF-8 \
119
HOME=/opt/app-root \
1210
PATH=/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
1311
DOTNET_APP_PATH=/opt/app-root/app \
14-
DOTNET_DEFAULT_CMD=default-cmd.sh
12+
DOTNET_DEFAULT_CMD=default-cmd.sh \
13+
DOTNET_CORE_VERSION=2.0 \
14+
DOTNET_FRAMEWORK=netcoreapp2.0
1515

1616
LABEL io.k8s.description="Platform for running .NET Core 2.0 applications" \
1717
io.k8s.display-name=".NET Core 2.0" \

2.0/runtime/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,18 @@ Repository organization
6464
Environment variables
6565
---------------------
6666

67+
The following variables are set so they can be used from scripts.
68+
They must not to be overridden.
69+
6770
* **ASPNETCORE_URLS**
6871

6972
This variable is set to `http://*:8080` to configure ASP.NET Core to use the
7073
port exposed by the image.
74+
75+
* **DOTNET_APP_PATH,DOTNET_DEFAULT_CMD**
76+
77+
These variables contain the working directory (`/opt/app-root/app`) and default CMD of the runtime image (`default-cmd.sh`).
78+
79+
* **DOTNET_FRAMEWORK,DOTNET_CORE_VERSION**
80+
81+
These variables contain the framework (`netcoreapp2.0`) and .NET Core version (`2.0`) respectively.

2.0/runtime/test/run

+24-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@
1111
#
1212
# Example usage: $ sudo ./test/run
1313

14-
IMAGE_NAME=${IMAGE_NAME:-dotnet/dotnet-20-runtime-rhel7}
14+
if [ "$BUILD_CENTOS" = "true" ]; then
15+
IMAGE_NAME=${IMAGE_NAME:-centos/dotnet-20-runtime-centos7}
16+
else
17+
IMAGE_NAME=${IMAGE_NAME:-dotnet/dotnet-20-runtime-rhel7}
18+
fi
1519
OPENSHIFT_ONLY=${OPENSHIFT_ONLY:-false}
1620

1721
test_dir="$(readlink -zf $(dirname "${BASH_SOURCE[0]}"))"
1822
source ${test_dir}/testcommon
1923

24+
dotnet_version_series="2.0"
25+
dotnet_version_suffix="0"
26+
dotnet_version="${dotnet_version_series}.${dotnet_version_suffix}"
27+
2028
test_dotnet() {
2129
test_start
22-
local dotnet_version="2.0.0"
2330

2431
# ENTRYPOINT enables scl so dotnet is available
2532
assert_contains "$(docker_run $IMAGE_NAME "dotnet --info")" "Microsoft .NET Core Shared Framework Host"
@@ -28,6 +35,20 @@ test_dotnet() {
2835
assert_contains "$(docker_run $IMAGE_NAME "dotnet --info")" "Version : ${dotnet_version}"$'\r\n'
2936
}
3037

38+
test_envvars() {
39+
test_start
40+
41+
# DOTNET_APP_PATH
42+
assert_equal $(docker_get_env $IMAGE_NAME DOTNET_APP_PATH) "/opt/app-root/app"
43+
# DOTNET_DEFAULT_CMD
44+
assert_equal $(docker_get_env $IMAGE_NAME DOTNET_DEFAULT_CMD) "default-cmd.sh"
45+
46+
# DOTNET_CORE_VERSION
47+
assert_equal $(docker_get_env $IMAGE_NAME DOTNET_CORE_VERSION) "${dotnet_version_series}"
48+
# DOTNET_FRAMEWORK
49+
assert_equal $(docker_get_env $IMAGE_NAME DOTNET_FRAMEWORK) "netcoreapp${dotnet_version_series}"
50+
}
51+
3152
test_debuggable() {
3253
test_start
3354

@@ -99,6 +120,7 @@ info "Testing ${IMAGE_NAME}"
99120

100121
if [ ${OPENSHIFT_ONLY} != true ]; then
101122
test_dotnet
123+
test_envvars
102124
test_default_cmd
103125
test_debuggable
104126
test_user

0 commit comments

Comments
 (0)