diff --git a/1.0/Dockerfile b/1.0/Dockerfile index 8f5c9b9..de97828 100644 --- a/1.0/Dockerfile +++ b/1.0/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/oryx/dotnetcore:1.0-20190730.1 +FROM mcr.microsoft.com/oryx/dotnetcore:1.0-20191018.1 LABEL maintainer="Azure App Services Container Images " RUN apt-get update \ @@ -10,12 +10,16 @@ RUN apt-get update \ curl \ wget \ tcptraceroute \ + net-tools \ + dnsutils \ + tcpdump \ + iproute2 \ && rm -rf /var/lib/apt/lists/* RUN mkdir -p /defaulthome/hostingstart \ && mkdir -p /home/LogFiles/ \ && echo "root:Docker!" | chpasswd \ - && echo "cd /home" >> /etc/bash.bashrc + && echo "cd /home" >> /root/.bashrc COPY bin.zip /tmp RUN unzip -q -o /tmp/bin.zip -d /defaulthome/hostingstart \ @@ -45,6 +49,14 @@ ENV PATH ${PATH}:/home/site/wwwroot ENV ASPNETCORE_URLS= ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true +# Enable automatic creation of dumps when a process crashes +ENV COMPlus_DbgEnableMiniDump="1" +# Create a base directory for dumps under /home so that the +# dumps are accessible from the build container too (since a runtime container might have already crashed) +ENV DUMP_DIR="/home/logs/dumps" +RUN mkdir -p "$DUMP_DIR" +RUN chmod 777 "$DUMP_DIR" + WORKDIR /home/site/wwwroot ENTRYPOINT ["/bin/init_container.sh"] diff --git a/1.0/init_container.sh b/1.0/init_container.sh index dc7f093..e394ed4 100644 --- a/1.0/init_container.sh +++ b/1.0/init_container.sh @@ -22,6 +22,11 @@ eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/ sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config /usr/sbin/sshd +# Format : coredump.hostname.processid.time +# Example: coredump.7d77b4ff1fea.15.1571222166 +containerName=`hostname` +export COMPlus_DbgMiniDumpName="$DUMP_DIR/coredump.$containerName.%d.$(date +%s)" + appPath="/home/site/wwwroot" runFromPath="/tmp/webapp" startupCommandPath="/opt/startup/startup.sh" diff --git a/1.1/Dockerfile b/1.1/Dockerfile index 0ec5d6d..e58f5f2 100644 --- a/1.1/Dockerfile +++ b/1.1/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/oryx/dotnetcore:1.1-20190730.1 +FROM mcr.microsoft.com/oryx/dotnetcore:1.1-20191018.1 LABEL maintainer="Azure App Services Container Images " RUN apt-get update \ @@ -10,12 +10,16 @@ RUN apt-get update \ curl \ wget \ tcptraceroute \ + net-tools \ + dnsutils \ + tcpdump \ + iproute2 \ && rm -rf /var/lib/apt/lists/* RUN mkdir -p /defaulthome/hostingstart \ && mkdir -p /home/LogFiles/ \ && echo "root:Docker!" | chpasswd \ - && echo "cd /home" >> /etc/bash.bashrc + && echo "cd /home" >> /root/.bashrc COPY bin.zip /tmp RUN unzip -q -o /tmp/bin.zip -d /defaulthome/hostingstart \ @@ -45,6 +49,14 @@ ENV PATH ${PATH}:/home/site/wwwroot ENV ASPNETCORE_URLS= ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true +# Enable automatic creation of dumps when a process crashes +ENV COMPlus_DbgEnableMiniDump="1" +# Create a base directory for dumps under /home so that the +# dumps are accessible from the build container too (since a runtime container might have already crashed) +ENV DUMP_DIR="/home/logs/dumps" +RUN mkdir -p "$DUMP_DIR" +RUN chmod 777 "$DUMP_DIR" + WORKDIR /home/site/wwwroot ENTRYPOINT ["/bin/init_container.sh"] diff --git a/1.1/init_container.sh b/1.1/init_container.sh index dc7f093..e394ed4 100644 --- a/1.1/init_container.sh +++ b/1.1/init_container.sh @@ -22,6 +22,11 @@ eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/ sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config /usr/sbin/sshd +# Format : coredump.hostname.processid.time +# Example: coredump.7d77b4ff1fea.15.1571222166 +containerName=`hostname` +export COMPlus_DbgMiniDumpName="$DUMP_DIR/coredump.$containerName.%d.$(date +%s)" + appPath="/home/site/wwwroot" runFromPath="/tmp/webapp" startupCommandPath="/opt/startup/startup.sh" diff --git a/2.0/Dockerfile b/2.0/Dockerfile index 2036033..bb16ed3 100644 --- a/2.0/Dockerfile +++ b/2.0/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/oryx/dotnetcore:2.0-20190730.1 +FROM mcr.microsoft.com/oryx/dotnetcore:2.0-20191018.1 LABEL maintainer="Azure App Services Container Images " RUN apt-get update \ @@ -10,12 +10,16 @@ RUN apt-get update \ curl \ wget \ tcptraceroute \ + net-tools \ + dnsutils \ + tcpdump \ + iproute2 \ && rm -rf /var/lib/apt/lists/* RUN mkdir -p /defaulthome/hostingstart \ && mkdir -p /home/LogFiles/ \ && echo "root:Docker!" | chpasswd \ - && echo "cd /home" >> /etc/bash.bashrc + && echo "cd /home" >> /root/.bashrc COPY bin.zip /tmp RUN unzip -q -o /tmp/bin.zip -d /defaulthome/hostingstart \ @@ -45,6 +49,14 @@ ENV PATH ${PATH}:/home/site/wwwroot ENV ASPNETCORE_URLS= ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true +# Enable automatic creation of dumps when a process crashes +ENV COMPlus_DbgEnableMiniDump="1" +# Create a base directory for dumps under /home so that the +# dumps are accessible from the build container too (since a runtime container might have already crashed) +ENV DUMP_DIR="/home/logs/dumps" +RUN mkdir -p "$DUMP_DIR" +RUN chmod 777 "$DUMP_DIR" + WORKDIR /home/site/wwwroot ENTRYPOINT ["/bin/init_container.sh"] diff --git a/2.0/init_container.sh b/2.0/init_container.sh index dc7f093..e394ed4 100644 --- a/2.0/init_container.sh +++ b/2.0/init_container.sh @@ -22,6 +22,11 @@ eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/ sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config /usr/sbin/sshd +# Format : coredump.hostname.processid.time +# Example: coredump.7d77b4ff1fea.15.1571222166 +containerName=`hostname` +export COMPlus_DbgMiniDumpName="$DUMP_DIR/coredump.$containerName.%d.$(date +%s)" + appPath="/home/site/wwwroot" runFromPath="/tmp/webapp" startupCommandPath="/opt/startup/startup.sh" diff --git a/2.0/src/hostingstart.csproj b/2.0/src/hostingstart.csproj index abda657..4c4f12a 100644 --- a/2.0/src/hostingstart.csproj +++ b/2.0/src/hostingstart.csproj @@ -9,7 +9,7 @@ - + diff --git a/2.1/Dockerfile b/2.1/Dockerfile index cbaebe3..a54477b 100644 --- a/2.1/Dockerfile +++ b/2.1/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/oryx/dotnetcore:2.1-20190730.1 +FROM mcr.microsoft.com/oryx/dotnetcore:2.1-20191018.1 LABEL maintainer="Azure App Services Container Images " RUN apt-get update \ @@ -10,12 +10,16 @@ RUN apt-get update \ curl \ wget \ tcptraceroute \ + net-tools \ + dnsutils \ + tcpdump \ + iproute2 \ && rm -rf /var/lib/apt/lists/* RUN mkdir -p /defaulthome/hostingstart \ && mkdir -p /home/LogFiles/ \ && echo "root:Docker!" | chpasswd \ - && echo "cd /home" >> /etc/bash.bashrc + && echo "cd /home" >> /root/.bashrc COPY bin.zip /tmp RUN unzip -q -o /tmp/bin.zip -d /defaulthome/hostingstart \ @@ -45,6 +49,14 @@ ENV PATH ${PATH}:/home/site/wwwroot ENV ASPNETCORE_URLS= ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true +# Enable automatic creation of dumps when a process crashes +ENV COMPlus_DbgEnableMiniDump="1" +# Create a base directory for dumps under /home so that the +# dumps are accessible from the build container too (since a runtime container might have already crashed) +ENV DUMP_DIR="/home/logs/dumps" +RUN mkdir -p "$DUMP_DIR" +RUN chmod 777 "$DUMP_DIR" + WORKDIR /home/site/wwwroot ENTRYPOINT ["/bin/init_container.sh"] diff --git a/2.1/init_container.sh b/2.1/init_container.sh index dc7f093..e394ed4 100644 --- a/2.1/init_container.sh +++ b/2.1/init_container.sh @@ -22,6 +22,11 @@ eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/ sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config /usr/sbin/sshd +# Format : coredump.hostname.processid.time +# Example: coredump.7d77b4ff1fea.15.1571222166 +containerName=`hostname` +export COMPlus_DbgMiniDumpName="$DUMP_DIR/coredump.$containerName.%d.$(date +%s)" + appPath="/home/site/wwwroot" runFromPath="/tmp/webapp" startupCommandPath="/opt/startup/startup.sh" diff --git a/2.1/src/hostingstart.csproj b/2.1/src/hostingstart.csproj index f09851a..191d3bb 100644 --- a/2.1/src/hostingstart.csproj +++ b/2.1/src/hostingstart.csproj @@ -9,7 +9,7 @@ - + diff --git a/2.2/Dockerfile b/2.2/Dockerfile index 353867f..580ad59 100644 --- a/2.2/Dockerfile +++ b/2.2/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/oryx/dotnetcore:2.2-20190730.1 +FROM mcr.microsoft.com/oryx/dotnetcore:2.2-20191018.1 LABEL maintainer="Azure App Services Container Images " RUN apt-get update \ @@ -10,12 +10,16 @@ RUN apt-get update \ curl \ wget \ tcptraceroute \ + net-tools \ + dnsutils \ + tcpdump \ + iproute2 \ && rm -rf /var/lib/apt/lists/* RUN mkdir -p /defaulthome/hostingstart \ && mkdir -p /home/LogFiles/ \ && echo "root:Docker!" | chpasswd \ - && echo "cd /home" >> /etc/bash.bashrc + && echo "cd /home" >> /root/.bashrc COPY bin.zip /tmp RUN unzip -q -o /tmp/bin.zip -d /defaulthome/hostingstart \ @@ -45,6 +49,14 @@ ENV PATH ${PATH}:/home/site/wwwroot ENV ASPNETCORE_URLS= ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true +# Enable automatic creation of dumps when a process crashes +ENV COMPlus_DbgEnableMiniDump="1" +# Create a base directory for dumps under /home so that the +# dumps are accessible from the build container too (since a runtime container might have already crashed) +ENV DUMP_DIR="/home/logs/dumps" +RUN mkdir -p "$DUMP_DIR" +RUN chmod 777 "$DUMP_DIR" + WORKDIR /home/site/wwwroot ENTRYPOINT ["/bin/init_container.sh"] diff --git a/2.2/init_container.sh b/2.2/init_container.sh index dc7f093..e394ed4 100644 --- a/2.2/init_container.sh +++ b/2.2/init_container.sh @@ -22,6 +22,11 @@ eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/ sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config /usr/sbin/sshd +# Format : coredump.hostname.processid.time +# Example: coredump.7d77b4ff1fea.15.1571222166 +containerName=`hostname` +export COMPlus_DbgMiniDumpName="$DUMP_DIR/coredump.$containerName.%d.$(date +%s)" + appPath="/home/site/wwwroot" runFromPath="/tmp/webapp" startupCommandPath="/opt/startup/startup.sh" diff --git a/3.0/Dockerfile b/3.0/Dockerfile new file mode 100644 index 0000000..6ee1182 --- /dev/null +++ b/3.0/Dockerfile @@ -0,0 +1,62 @@ +FROM mcr.microsoft.com/oryx/dotnetcore:3.0-20191018.1 +LABEL maintainer="Azure App Services Container Images " + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + apt-utils \ + unzip \ + openssh-server \ + vim \ + curl \ + wget \ + tcptraceroute \ + net-tools \ + dnsutils \ + tcpdump \ + iproute2 \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /defaulthome/hostingstart \ + && mkdir -p /home/LogFiles/ \ + && echo "root:Docker!" | chpasswd \ + && echo "cd /home" >> /root/.bashrc + +COPY bin.zip /tmp +RUN unzip -q -o /tmp/bin.zip -d /defaulthome/hostingstart \ + && rm /tmp/bin.zip + +COPY init_container.sh /bin/ +RUN chmod 755 /bin/init_container.sh + +COPY hostingstart.html /defaulthome/hostingstart/wwwroot/ + +# configure startup +COPY sshd_config /etc/ssh/ +COPY ssh_setup.sh /tmp +RUN mkdir -p /opt/startup \ + && chmod -R +x /opt/startup \ + && chmod -R +x /tmp/ssh_setup.sh \ + && (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null) \ + && rm -rf /tmp/* + +ENV PORT 8080 +ENV SSH_PORT 2222 +EXPOSE 8080 2222 + +ENV WEBSITE_ROLE_INSTANCE_ID localRoleInstance +ENV WEBSITE_INSTANCE_ID localInstance +ENV PATH ${PATH}:/home/site/wwwroot +ENV ASPNETCORE_URLS= +ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true + +# Enable automatic creation of dumps when a process crashes +ENV COMPlus_DbgEnableMiniDump="1" +# Create a base directory for dumps under /home so that the +# dumps are accessible from the build container too (since a runtime container might have already crashed) +ENV DUMP_DIR="/home/logs/dumps" +RUN mkdir -p "$DUMP_DIR" +RUN chmod 777 "$DUMP_DIR" + +WORKDIR /home/site/wwwroot + +ENTRYPOINT ["/bin/init_container.sh"] diff --git a/3.0/bin.zip b/3.0/bin.zip new file mode 100644 index 0000000..e7d5156 Binary files /dev/null and b/3.0/bin.zip differ diff --git a/3.0/build.sh b/3.0/build.sh new file mode 100644 index 0000000..fe390bd --- /dev/null +++ b/3.0/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +cd src +sudo rm -rf bin obj publish +docker run --rm -v $(pwd):/src -w /src microsoft/dotnet:3.0-sdk /bin/bash -c "dotnet restore && dotnet publish -o publish" +cd publish +zip -r ../../bin.zip * +rm -rf ../publish ../out ../obj ../bin diff --git a/3.0/hostingstart.html b/3.0/hostingstart.html new file mode 100644 index 0000000..27ec948 --- /dev/null +++ b/3.0/hostingstart.html @@ -0,0 +1,51 @@ + + + + + + + Microsoft Azure App Service - Welcome + + + + + + + +
+
+
+
+
+
+
+
+
+

Hey, .NET Core developers!

+
+
+
+

Your app service is up and running.

+
+
+

Time to take the next step and deploy your code.

+
+
+

Have your code ready?
Use deployment center to get code published from your client or setup continuous deployment.

+

Don't have your code yet?
Follow our quickstart guide and you'll have a full app ready in 5 minutes or less.

+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/3.0/init_container.sh b/3.0/init_container.sh new file mode 100644 index 0000000..e394ed4 --- /dev/null +++ b/3.0/init_container.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +cat >/etc/motd < + \/ \/ \/ +A P P S E R V I C E O N L I N U X + +Documentation: http://aka.ms/webapp-linux +Dotnet quickstart: https://aka.ms/dotnet-qs +.NETCore runtime version: `ls -X /usr/share/dotnet/shared/Microsoft.NETCore.App | tail -n 1` + +EOL +cat /etc/motd + +# Get environment variables to show up in SSH session +eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile) + +# starting sshd process +sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config +/usr/sbin/sshd + +# Format : coredump.hostname.processid.time +# Example: coredump.7d77b4ff1fea.15.1571222166 +containerName=`hostname` +export COMPlus_DbgMiniDumpName="$DUMP_DIR/coredump.$containerName.%d.$(date +%s)" + +appPath="/home/site/wwwroot" +runFromPath="/tmp/webapp" +startupCommandPath="/opt/startup/startup.sh" +defaultAppPath="/defaulthome/hostingstart/hostingstart.dll" +userStartupCommand="$@" + +# When run from copy is enabled, Oryx tries to run the app from a different directory (local to the container), +# so sanitize any input arguments which still reference the wwwroot path. This is true for VS Publish scenarios. +# Even though VS Publish team might fix this on their end, end users might not have upgraded their extension, so +# this code needs to be present. +if [ "$APP_SVC_RUN_FROM_COPY" = true ]; then + # Trim the ending '/' + appPath=$(echo "${appPath%/}") + runFromPath=$(echo "${runFromPath%/}") + userStartupCommand=$(echo $userStartupCommand | sed "s!$appPath!$runFromPath!g") + runFromPathArg="-runFromPath $runFromPath" +fi + +oryxArgs="-appPath $appPath -output $startupCommandPath -defaultAppFilePath $defaultAppPath \ + -bindPort $PORT -userStartupCommand '$userStartupCommand' $runFromPathArg" + +echo "Running oryx $oryxArgs" +eval oryx $oryxArgs +$startupCommandPath \ No newline at end of file diff --git a/3.0/src/.gitignore b/3.0/src/.gitignore new file mode 100644 index 0000000..e7679db --- /dev/null +++ b/3.0/src/.gitignore @@ -0,0 +1,38 @@ + +*.swp +*.*~ +project.lock.json +.DS_Store +*.pyc +nupkg/ + +# Visual Studio Code +.vscode + +# Rider +.idea + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +msbuild.log +msbuild.err +msbuild.wrn + +# Visual Studio 2015 +.vs/ diff --git a/3.0/src/Program.cs b/3.0/src/Program.cs new file mode 100644 index 0000000..e218692 --- /dev/null +++ b/3.0/src/Program.cs @@ -0,0 +1,19 @@ +using System; +using Microsoft.AspNetCore.Hosting; + +namespace hostingstart +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseKestrel() + .UseStartup() + .UseWebRoot("/defaulthome/hostingstart/wwwroot") + .Build(); + + host.Run(); + } + } +} diff --git a/3.0/src/Startup.cs b/3.0/src/Startup.cs new file mode 100644 index 0000000..517d61c --- /dev/null +++ b/3.0/src/Startup.cs @@ -0,0 +1,21 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.FileProviders; +using Microsoft.AspNetCore.StaticFiles; + +namespace hostingstart +{ + public class Startup + { + public void Configure(IApplicationBuilder app) + { + var options = new DefaultFilesOptions(); + options.DefaultFileNames.Add("hostingstart.html"); + + app.UseDefaultFiles(options) + .UseStaticFiles(); + } + } +} diff --git a/3.0/src/hostingstart.csproj b/3.0/src/hostingstart.csproj new file mode 100644 index 0000000..340ad88 --- /dev/null +++ b/3.0/src/hostingstart.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp3.0 + + + + + + + + + + + diff --git a/3.0/ssh_setup.sh b/3.0/ssh_setup.sh new file mode 100644 index 0000000..8bc40cc --- /dev/null +++ b/3.0/ssh_setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ ! -f "/etc/ssh/ssh_host_rsa_key" ]; then + # generate fresh rsa key + ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa +fi + +if [ ! -f "/etc/ssh/ssh_host_dsa_key" ]; then + # generate fresh dsa key + ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa +fi + +if [ ! -f "/etc/ssh/ssh_host_ecdsa_key" ]; then + # generate fresh ecdsa key + ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t dsa +fi + +if [ ! -f "/etc/ssh/ssh_host_ed25519_key" ]; then + # generate fresh ecdsa key + ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t dsa +fi + +#prepare run dir +if [ ! -d "/var/run/sshd" ]; then + mkdir -p /var/run/sshd +fi diff --git a/3.0/sshd_config b/3.0/sshd_config new file mode 100644 index 0000000..aca8f95 --- /dev/null +++ b/3.0/sshd_config @@ -0,0 +1,16 @@ +# 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,aes128-ctr,aes192-ctr,aes256-ctr +MACs hmac-sha1,hmac-sha1-96 +StrictModes yes +SyslogFacility DAEMON +PasswordAuthentication yes +PermitEmptyPasswords no +PermitRootLogin yes +Subsystem sftp internal-sftp