Skip to content

Commit

Permalink
.NET 8 in proc changes for dedicated linux images (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
CooperLink committed Jun 13, 2024
1 parent edf44c1 commit 729ca85
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 1 deletion.
40 changes: 40 additions & 0 deletions host/4/bookworm/dotnet/dotnet8-appservice.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Build the runtime from source
ARG HOST_VERSION=4.834.0
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim-amd64 AS runtime-image
ARG HOST_VERSION

ENV PublishWithAspNetCoreTargetManifest=false

RUN BUILD_NUMBER=$(echo ${HOST_VERSION} | cut -d'.' -f 3) && \
git clone --branch v${HOST_VERSION} https://github.com/Azure/azure-functions-host /src/azure-functions-host && \
cd /src/azure-functions-host && \
HOST_COMMIT=$(git rev-list -1 HEAD) && \
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 && \
mv /azure-functions-host/workers /workers && mkdir /azure-functions-host/workers && \
rm -rf /root/.local /root/.nuget /src

FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-bookworm-slim-amd64
ARG HOST_VERSION

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
HOME=/home \
FUNCTIONS_WORKER_RUNTIME=dotnet \
DOTNET_USE_POLLING_FILE_WATCHER=true \
HOST_VERSION=${HOST_VERSION} \
ASPNETCORE_CONTENTROOT=/azure-functions-host \
ASPNETCORE_URLS=http://+:80

COPY --from=runtime-image [ "/azure-functions-host", "/azure-functions-host" ]
COPY sshd_config /etc/ssh/
COPY start.sh /azure-functions-host/
COPY install_ca_certificates.sh /opt/startup/

EXPOSE 2222 80

RUN apt-get update && \
apt-get install -y --no-install-recommends openssh-server dialog && \
echo "root:Docker!" | chpasswd && \
chmod +x /azure-functions-host/start.sh && \
chmod +x /opt/startup/install_ca_certificates.sh

CMD [ "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost" ]
29 changes: 29 additions & 0 deletions host/4/bookworm/dotnet/dotnet8.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Build the runtime from source
ARG HOST_VERSION=4.834.0
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim-amd64 AS runtime-image
ARG HOST_VERSION

ENV PublishWithAspNetCoreTargetManifest=false

RUN BUILD_NUMBER=$(echo ${HOST_VERSION} | cut -d'.' -f 3) && \
git clone --branch v${HOST_VERSION} https://github.com/Azure/azure-functions-host /src/azure-functions-host && \
cd /src/azure-functions-host && \
HOST_COMMIT=$(git rev-list -1 HEAD) && \
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 && \
mv /azure-functions-host/workers /workers && mkdir /azure-functions-host/workers && \
rm -rf /root/.local /root/.nuget /src

FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-bookworm-slim-amd64
ARG HOST_VERSION

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
HOME=/home \
FUNCTIONS_WORKER_RUNTIME=dotnet \
DOTNET_USE_POLLING_FILE_WATCHER=true \
HOST_VERSION=${HOST_VERSION} \
ASPNETCORE_CONTENTROOT=/azure-functions-host \
ASPNETCORE_URLS=http://+:80

COPY --from=runtime-image [ "/azure-functions-host", "/azure-functions-host" ]

CMD [ "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost" ]
17 changes: 17 additions & 0 deletions host/4/bookworm/dotnet/install_ca_certificates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Source and destination directories
source_dir="/var/ssl/root"
destination_dir="/usr/local/share/ca-certificates"

# Check if the source directory has no files with the .crt extension
if [ "$(ls "$source_dir"/*.crt 2>/dev/null)" ]; then

# Copy CA certificates
cp "$source_dir"/*.crt "$destination_dir"

# Run update-ca-certificates command to update the CA certificate store
update-ca-certificates

echo "CA certificates copied and updated successfully."
fi
15 changes: 15 additions & 0 deletions host/4/bookworm/dotnet/sshd_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This is ssh server systemwide configuration file.
#
# /etc/sshd_config

Port SSH_PORT
ListenAddress 0.0.0.0
LoginGraceTime 180
X11Forwarding yes
Ciphers aes128-cbc,3des-cbc,aes256-cbc
MACs hmac-sha1,hmac-sha1-96
StrictModes yes
SyslogFacility DAEMON
PasswordAuthentication yes
PermitEmptyPasswords no
PermitRootLogin yes
31 changes: 31 additions & 0 deletions host/4/bookworm/dotnet/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

export DOTNET_USE_POLLING_FILE_WATCHER=true

if [ -z $PORT ]; then
export ASPNETCORE_URLS=http://*:80
else
export ASPNETCORE_URLS=http://*:$PORT
fi

# Install ca-certificates
source /opt/startup/install_ca_certificates.sh

if [ -z $SSH_PORT ]; then
export SSH_PORT=2222
fi

if [ "$APPSVC_REMOTE_DEBUGGING" == "TRUE" ]; then
export languageWorkers__node__arguments="--inspect=0.0.0.0:$APPSVC_TUNNEL_PORT"
export languageWorkers__python__arguments="-m ptvsd --host localhost --port $APPSVC_TUNNEL_PORT"
fi

sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config

service ssh start

if [ -f /azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost ]; then
/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost
else
dotnet /azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll
fi
12 changes: 11 additions & 1 deletion host/4/dotnet-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,21 @@ jobs:
dockerfilePath: "host/4/mariner/dotnet/dotnet-isolated/"
dockerImagePath: "dotnet-isolated"
dockerImageName: "-dotnet-isolated8.0-mariner"
_bookwork-net-6:
_bookworm-net-6:
dotnetVersion: "dotnet6"
dockerfilePath: "host/4/bookworm/dotnet/"
dockerImagePath: "dotnet"
dockerImageName: "-dotnet6-bookworm"
_bookworm-net-8:
dotnetVersion: "dotnet8"
dockerfilePath: "host/4/bookworm/dotnet/"
dockerImagePath: "dotnet"
dockerImageName: "-dotnet8.0"
_appservice-net-8:
dotnetVersion: "dotnet8-appservice"
dockerfilePath: "host/4/bookworm/dotnet/"
dockerImagePath: "dotnet"
dockerImageName: "-dotnet8.0appservice"

steps:
- bash: |
Expand Down
12 changes: 12 additions & 0 deletions host/4/publish-appservice-stage-sovereign-clouds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ steps:
displayName: tag and push dotnet-isolated8 images for stage ${{stage}}
continueOnError: false
- bash: |
set -e
docker pull $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0-appservice
docker tag $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0-appservice $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0-appservice-$(CloudName)-stage${{stage}}
docker push $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0-appservice-$(CloudName)-stage${{stage}}
docker system prune -a -f
displayName: tag and push dotnet8.0 in proc images for stage ${{stage}}
continueOnError: false
- bash: |
set -e
docker pull $SOURCE_REGISTRY/java:$(PrivateVersion)-java8-appservice
Expand Down
12 changes: 12 additions & 0 deletions host/4/publish-appservice-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ steps:
displayName: tag and push dotnet images
continueOnError: false
- bash: |
set -e
docker pull $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0-appservice
docker tag $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0-appservice $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0-appservice-stage$(StageNumber)
docker push $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0-appservice-stage$(StageNumber)
docker system prune -a -f
displayName: tag and push dotnet images
continueOnError: false
- bash: |
set -e
docker pull $SOURCE_REGISTRY/dotnet-isolated:$(PrivateVersion)-dotnet-isolated6.0-appservice
Expand Down
15 changes: 15 additions & 0 deletions host/4/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ steps:
displayName: tag and push dotnet images
continueOnError: false
- bash: |
set -e
docker pull $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0
docker pull $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0-appservice
docker tag $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0 $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0
docker tag $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0-appservice $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0-appservice
docker push $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0
docker push $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0-appservice
docker system prune -a -f
displayName: tag and push dotnet images
continueOnError: false
- bash: |
set -e
Expand Down
15 changes: 15 additions & 0 deletions host/4/republish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ steps:
displayName: tag and push dotnet images
continueOnError: false
- bash: |
set -e
docker pull $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0
docker pull $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0-appservice
docker tag $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0 $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0
docker tag $SOURCE_REGISTRY/dotnet:$(PrivateVersion)-dotnet8.0-appservice $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0-appservice
docker push $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0
docker push $TARGET_REGISTRY/dotnet:$(TargetVersion)-dotnet8.0-appservice
docker system prune -a -f
displayName: tag and push dotnet images
continueOnError: false
- bash: |
set -e
docker pull $SOURCE_REGISTRY/dotnet-isolated:$(PrivateVersion)-dotnet-isolated6.0
Expand Down
8 changes: 8 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const dotnetIsolated8 = {
response: "Welcome to Azure Functions! .NET 8"
}

const dotnetInProc8 = {
package: `${storagePath}/dotnet8-inproc.zip`,
invoke: "/api/CSharpHttpFunction?name=Test",
response: "Hello, Test. This HTTP triggered function executed successfully."
}

const map = {
python: {
package: `${storagePath}/python-functions.zip`,
Expand Down Expand Up @@ -64,6 +70,7 @@ const map = {
};

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

const testData = (function() {
if (imageName.indexOf("java") !== -1) return map.java;
Expand All @@ -74,6 +81,7 @@ const testData = (function() {
else if (imageName.indexOf("dotnet-isolated6.0") !== -1) return dotnetIsolated6;
else if (imageName.indexOf("dotnet-isolated7.0") !== -1) return dotnetIsolated7;
else if (imageName.indexOf("dotnet-isolated8.0") !== -1) return dotnetIsolated8;
else if (imageName.indexOf("dotnet8") !== -1) return dotnetInProc8;
else if (imageName.indexOf("mesh") !== -1) return map;
else return map.dotnet;
})();
Expand Down

0 comments on commit 729ca85

Please sign in to comment.