Skip to content

Commit 13af1bf

Browse files
authored
.NET 8 in proc changes for dedicated linux images (#1069)
* initial changes * changes * pipelien changes * fixing file * fixing file * adding comment * trying again * trying again fr * test changes * trying to run test * trying something else * trying gain * change * adding host tag * trying again * changing to 5000 * trying again * for real changes * fixing pipeline * fixing app service * trying again * trying again * fixing tag and removing all bullseye images * fixing spacing * fixing spacing again * extra space * adding publish appservice changes * removing extra dotnet build * removing extension bundle changes to see if it works * addressing appservice file * changing publish script back * moving file back * forgot to add sshd_config * adding out directory * trying again * fixing it
1 parent 58d89e6 commit 13af1bf

11 files changed

+201
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Build the runtime from source
2+
ARG HOST_VERSION=4.834.0
3+
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim-amd64 AS runtime-image
4+
ARG HOST_VERSION
5+
6+
ENV PublishWithAspNetCoreTargetManifest=false
7+
8+
RUN BUILD_NUMBER=$(echo ${HOST_VERSION} | cut -d'.' -f 3) && \
9+
git clone --branch v${HOST_VERSION} https://github.com/Azure/azure-functions-host /src/azure-functions-host && \
10+
cd /src/azure-functions-host && \
11+
HOST_COMMIT=$(git rev-list -1 HEAD) && \
12+
dotnet publish -v q /p:BuildNumber=$BUILD_NUMBER /p:CommitHash=$HOST_COMMIT src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj -c Release --output /azure-functions-host --runtime linux-x64 --framework net8.0 --self-contained /p:MinorVersionPrefix=8 && \
13+
mv /azure-functions-host/workers /workers && mkdir /azure-functions-host/workers && \
14+
rm -rf /root/.local /root/.nuget /src
15+
16+
RUN apt-get update && \
17+
apt-get install -y gnupg wget unzip;
18+
19+
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-bookworm-slim-amd64
20+
ARG HOST_VERSION
21+
22+
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
23+
HOME=/home \
24+
FUNCTIONS_WORKER_RUNTIME=dotnet \
25+
DOTNET_USE_POLLING_FILE_WATCHER=true \
26+
HOST_VERSION=${HOST_VERSION} \
27+
ASPNETCORE_CONTENTROOT=/azure-functions-host \
28+
ASPNETCORE_URLS=http://+:80
29+
30+
COPY --from=runtime-image [ "/azure-functions-host", "/azure-functions-host" ]
31+
COPY sshd_config /etc/ssh/
32+
COPY start.sh /azure-functions-host/
33+
COPY install_ca_certificates.sh /opt/startup/
34+
35+
EXPOSE 2222 80
36+
37+
RUN apt-get update && \
38+
apt-get install -y --no-install-recommends openssh-server dialog && \
39+
echo "root:Docker!" | chpasswd && \
40+
chmod +x /azure-functions-host/start.sh && \
41+
chmod +x /opt/startup/install_ca_certificates.sh
42+
43+
CMD [ "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost" ]
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Build the runtime from source
2+
ARG HOST_VERSION=4.834.0
3+
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim-amd64 AS runtime-image
4+
ARG HOST_VERSION
5+
6+
ENV PublishWithAspNetCoreTargetManifest=false
7+
8+
RUN BUILD_NUMBER=$(echo ${HOST_VERSION} | cut -d'.' -f 3) && \
9+
git clone --branch v${HOST_VERSION} https://github.com/Azure/azure-functions-host /src/azure-functions-host && \
10+
cd /src/azure-functions-host && \
11+
HOST_COMMIT=$(git rev-list -1 HEAD) && \
12+
dotnet publish -v q /p:BuildNumber=$BUILD_NUMBER /p:CommitHash=$HOST_COMMIT src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj -c Release --output /azure-functions-host --runtime linux-x64 --framework net8.0 --self-contained /p:MinorVersionPrefix=8 && \
13+
mv /azure-functions-host/workers /workers && mkdir /azure-functions-host/workers && \
14+
rm -rf /root/.local /root/.nuget /src
15+
16+
RUN apt-get update && \
17+
apt-get install -y gnupg wget unzip;
18+
19+
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-bookworm-slim-amd64
20+
ARG HOST_VERSION
21+
22+
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
23+
HOME=/home \
24+
FUNCTIONS_WORKER_RUNTIME=dotnet \
25+
DOTNET_USE_POLLING_FILE_WATCHER=true \
26+
HOST_VERSION=${HOST_VERSION} \
27+
ASPNETCORE_CONTENTROOT=/azure-functions-host \
28+
ASPNETCORE_URLS=http://+:80
29+
30+
COPY --from=runtime-image [ "/azure-functions-host", "/azure-functions-host" ]
31+
32+
CMD [ "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost" ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# Source and destination directories
4+
source_dir="/var/ssl/root"
5+
destination_dir="/usr/local/share/ca-certificates"
6+
7+
# Check if the source directory has no files with the .crt extension
8+
if [ "$(ls "$source_dir"/*.crt 2>/dev/null)" ]; then
9+
10+
# Copy CA certificates
11+
cp "$source_dir"/*.crt "$destination_dir"
12+
13+
# Run update-ca-certificates command to update the CA certificate store
14+
update-ca-certificates
15+
16+
echo "CA certificates copied and updated successfully."
17+
fi

host/4/bookworm/dotnet/sshd_config

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This is ssh server systemwide configuration file.
2+
#
3+
# /etc/sshd_config
4+
5+
Port SSH_PORT
6+
ListenAddress 0.0.0.0
7+
LoginGraceTime 180
8+
X11Forwarding yes
9+
Ciphers aes128-cbc,3des-cbc,aes256-cbc
10+
MACs hmac-sha1,hmac-sha1-96
11+
StrictModes yes
12+
SyslogFacility DAEMON
13+
PasswordAuthentication yes
14+
PermitEmptyPasswords no
15+
PermitRootLogin yes

host/4/bookworm/dotnet/start.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
export DOTNET_USE_POLLING_FILE_WATCHER=true
4+
5+
if [ -z $PORT ]; then
6+
export ASPNETCORE_URLS=http://*:80
7+
else
8+
export ASPNETCORE_URLS=http://*:$PORT
9+
fi
10+
11+
# Install ca-certificates
12+
source /opt/startup/install_ca_certificates.sh
13+
14+
if [ -z $SSH_PORT ]; then
15+
export SSH_PORT=2222
16+
fi
17+
18+
if [ "$APPSVC_REMOTE_DEBUGGING" == "TRUE" ]; then
19+
export languageWorkers__node__arguments="--inspect=0.0.0.0:$APPSVC_TUNNEL_PORT"
20+
export languageWorkers__python__arguments="-m ptvsd --host localhost --port $APPSVC_TUNNEL_PORT"
21+
fi
22+
23+
sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config
24+
25+
service ssh start
26+
27+
if [ -f /azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost ]; then
28+
/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost
29+
else
30+
dotnet /azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll
31+
fi

host/4/dotnet-build.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,21 @@ jobs:
101101
dockerfilePath: "host/4/mariner/dotnet/dotnet-isolated/"
102102
dockerImagePath: "dotnet-isolated"
103103
dockerImageName: "-dotnet-isolated8.0-mariner"
104-
_bookwork-net-6:
104+
_bookworm-net-6:
105105
dotnetVersion: "dotnet6"
106106
dockerfilePath: "host/4/bookworm/dotnet/"
107107
dockerImagePath: "dotnet"
108108
dockerImageName: "-dotnet6-bookworm"
109+
_bookworm-net-8:
110+
dotnetVersion: "dotnet8"
111+
dockerfilePath: "host/4/bookworm/dotnet/"
112+
dockerImagePath: "dotnet"
113+
dockerImageName: "-dotnet8"
114+
_appservice-net-8:
115+
dotnetVersion: "dotnet8-appservice"
116+
dockerfilePath: "host/4/bookworm/dotnet/"
117+
dockerImagePath: "dotnet"
118+
dockerImageName: "-dotnet8-appservice"
109119

110120
steps:
111121
- bash: |

host/4/publish-appservice-stage-sovereign-clouds.yml

+12
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ steps:
9898
displayName: tag and push dotnet-isolated8 images for stage ${{stage}}
9999
continueOnError: false
100100
101+
- bash: |
102+
set -e
103+
docker pull $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8-appservice
104+
105+
docker tag $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8-appservice $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8-appservice-$(CloudName)-stage${{stage}}
106+
107+
docker push $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8-appservice-$(CloudName)-stage${{stage}}
108+
109+
docker system prune -a -f
110+
displayName: tag and push dotnet8 in proc images for stage ${{stage}}
111+
continueOnError: false
112+
101113
- bash: |
102114
set -e
103115
docker pull $SOURCE_REGISTRY/java:$(PrivateVersion)-java8-appservice

host/4/publish-appservice-stage.yml

+12
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ steps:
5151
displayName: tag and push dotnet images
5252
continueOnError: false
5353
54+
- bash: |
55+
set -e
56+
docker pull $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8-appservice
57+
58+
docker tag $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8-appservice $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8-appservice-stage$(StageNumber)
59+
60+
docker push $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8-appservice-stage$(StageNumber)
61+
62+
docker system prune -a -f
63+
displayName: tag and push dotnet images
64+
continueOnError: false
65+
5466
- bash: |
5567
set -e
5668
docker pull $SOURCE_REGISTRY/dotnet-isolated:$(PrivateVersion)-dotnet-isolated6.0-appservice

host/4/publish.yml

+10
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ steps:
7777
displayName: tag and push dotnet images
7878
continueOnError: false
7979
80+
- bash: |
81+
set -e
82+
docker pull $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8
83+
docker tag $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8 $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8
84+
docker push $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8
85+
86+
docker system prune -a -f
87+
displayName: tag and push dotnet images
88+
continueOnError: false
89+
8090
8191
- bash: |
8292
set -e

host/4/republish.yml

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ steps:
6262
displayName: tag and push dotnet images
6363
continueOnError: false
6464
65+
- bash: |
66+
set -e
67+
docker pull $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8
68+
docker tag $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8 $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8
69+
docker push $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8
70+
71+
docker system prune -a -f
72+
displayName: tag and push dotnet images
73+
continueOnError: false
74+
6575
- bash: |
6676
set -e
6777
docker pull $SOURCE_REGISTRY/dotnet-isolated:$(PrivateVersion)-dotnet-isolated6.0

test/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ const dotnetIsolated8 = {
3535
response: "Welcome to Azure Functions! .NET 8"
3636
}
3737

38+
const dotnetInProc8 = {
39+
package: `${storagePath}/dotnet8-inproc.zip`,
40+
invoke: "/api/CSharpHttpFunction?name=Test",
41+
response: "Hello, Test. This HTTP triggered function executed successfully."
42+
}
43+
3844
const map = {
3945
python: {
4046
package: `${storagePath}/python-functions.zip`,
@@ -64,6 +70,7 @@ const map = {
6470
};
6571

6672
const imageName = process.argv[process.argv.length - 1];
73+
console.log("Image name: " + imageName);
6774

6875
const testData = (function() {
6976
if (imageName.indexOf("java") !== -1) return map.java;
@@ -74,6 +81,7 @@ const testData = (function() {
7481
else if (imageName.indexOf("dotnet-isolated6.0") !== -1) return dotnetIsolated6;
7582
else if (imageName.indexOf("dotnet-isolated7.0") !== -1) return dotnetIsolated7;
7683
else if (imageName.indexOf("dotnet-isolated8.0") !== -1) return dotnetIsolated8;
84+
else if (imageName.indexOf("dotnet8") !== -1) return dotnetInProc8;
7785
else if (imageName.indexOf("mesh") !== -1) return map;
7886
else return map.dotnet;
7987
})();

0 commit comments

Comments
 (0)