Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Reorder the docker build process to not invalidate all the cache - Reduce image sizes by removing unused artifacts - Add alpine images for dotnet and powershell - Add tests for built images
- Loading branch information
1 parent
4fdc533
commit 9c480aa
Showing
32 changed files
with
1,014 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM microsoft/dotnet:2.2-sdk AS installer-env | ||
|
||
ENV PublishWithAspNetCoreTargetManifest=false \ | ||
HOST_VERSION=2.0.12275 \ | ||
HOST_COMMIT=e3cdda25a9c473f6c239ae2f48d454cfda4adb66 | ||
|
||
RUN BUILD_NUMBER=$(echo $HOST_VERSION | cut -d'.' -f 3) && \ | ||
# apk add --no-cache wget tar && \ | ||
wget https://github.com/Azure/azure-functions-host/archive/$HOST_COMMIT.tar.gz && \ | ||
tar xzf $HOST_COMMIT.tar.gz && \ | ||
cd azure-functions-host-* && \ | ||
dotnet publish -v q /p:BuildNumber=$BUILD_NUMBER /p:CommitHash=$HOST_COMMIT src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj --output /azure-functions-host && \ | ||
mv /azure-functions-host/workers /workers && mkdir /azure-functions-host/workers | ||
|
||
FROM microsoft/dotnet:2.2-aspnetcore-runtime-alpine | ||
|
||
RUN apk add --no-cache libc6-compat libnsl && \ | ||
# workaround for https://github.com/grpc/grpc/issues/17255 | ||
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 | ||
|
||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ | ||
HOME=/home \ | ||
FUNCTIONS_WORKER_RUNTIME=dotnet | ||
|
||
COPY --from=installer-env ["/azure-functions-host", "/azure-functions-host"] | ||
COPY --from=installer-env ["/workers", "/workers"] | ||
|
||
CMD [ "dotnet", "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
ARG BASE_IMAGE=mcr.microsoft.com/azure-functions/base:2.0-alpine | ||
FROM ${BASE_IMAGE} as runtime-image | ||
|
||
FROM microsoft/dotnet:2.2-aspnetcore-runtime-alpine | ||
|
||
RUN apk add --no-cache libc6-compat libnsl && \ | ||
# workaround for https://github.com/grpc/grpc/issues/17255 | ||
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 | ||
|
||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ | ||
HOME=/home \ | ||
FUNCTIONS_WORKER_RUNTIME=dotnet | ||
|
||
COPY --from=runtime-image [ "/azure-functions-host", "/azure-functions-host" ] | ||
|
||
CMD [ "dotnet", "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
ARG BASE_IMAGE=mcr.microsoft.com/azure-functions/base:2.0-alpine | ||
FROM ${BASE_IMAGE} as runtime-image | ||
|
||
FROM microsoft/dotnet:2.2-aspnetcore-runtime-alpine | ||
|
||
RUN apk add --no-cache libc6-compat libnsl nodejs=8.14.0-r0 nodejs-npm=8.14.0-r0 && \ | ||
# workaround for https://github.com/grpc/grpc/issues/17255 | ||
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 | ||
|
||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ | ||
HOME=/home \ | ||
FUNCTIONS_WORKER_RUNTIME=node | ||
|
||
COPY --from=runtime-image [ "/azure-functions-host", "/azure-functions-host" ] | ||
COPY --from=runtime-image [ "/workers/node", "/azure-functions-host/workers/node" ] | ||
|
||
CMD [ "dotnet", "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
ARG BASE_IMAGE=mcr.microsoft.com/azure-functions/base:2.0-alpine | ||
FROM ${BASE_IMAGE} as runtime-image | ||
FROM microsoft/dotnet:2.2-aspnetcore-runtime-alpine | ||
|
||
RUN apk add --no-cache libc6-compat libnsl && \ | ||
# workaround for https://github.com/grpc/grpc/issues/17255 | ||
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 | ||
|
||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ | ||
HOME=/home \ | ||
FUNCTIONS_WORKER_RUNTIME=powershell | ||
|
||
COPY --from=runtime-image ["/azure-functions-host", "/azure-functions-host"] | ||
COPY --from=runtime-image [ "/workers/powershell", "/azure-functions-host/workers/powershell" ] | ||
|
||
CMD [ "dotnet", "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#! /bin/bash | ||
|
||
# Directory name for start.sh | ||
DIR="$(dirname $0)" | ||
|
||
export PYTHONPATH=/root/.pyenv/versions/3.7.2/lib/python3.7/site-packages:$PYTHONPATH | ||
|
||
# If we're not in a virtual environment, check if either: | ||
# $AZURE_FUNCTIONS_VIRTUAL_ENVIRONMENT is set, use it for venv | ||
# if it's not set and there is a default venv, activate it | ||
# else use the container python | ||
if [ -z "$VIRTUAL_ENV"] | ||
then | ||
# Determining the virtual environment entry point | ||
if [ -z "$AZURE_FUNCTIONS_VIRTUAL_ENVIRONMENT" ] | ||
then | ||
echo "using system python" | ||
else | ||
echo "activating virtual environment" | ||
source $AZURE_FUNCTIONS_VIRTUAL_ENVIRONMENT | ||
fi | ||
fi | ||
if [ -z "$SKIP_PYTHONPATH_UPDATE" ] | ||
then | ||
CUSTOM_PACKAGES="$HOME/site/wwwroot/.python_packages/lib/python3.7/site-packages" | ||
if [ -d "$CUSTOM_PACKAGES" ] | ||
then | ||
echo "appending $CUSTOM_PACKAGES to PYTHONPATH" | ||
export PYTHONPATH=$PYTHONPATH:$CUSTOM_PACKAGES | ||
else | ||
echo "path $CUSTOM_PACKAGES doesn't exist" | ||
fi | ||
|
||
CUSTOM_VENV_PACKAGES="$HOME/site/wwwroot/worker_venv/lib/python3.7/site-packages" | ||
if [ -d "$CUSTOM_VENV_PACKAGES" ] | ||
then | ||
echo "appending $CUSTOM_VENV_PACKAGES to PYTHONPATH" | ||
export PYTHONPATH=$PYTHONPATH:$CUSTOM_VENV_PACKAGES | ||
else | ||
echo "path $CUSTOM_VENV_PACKAGES doesn't exist" | ||
fi | ||
|
||
CUSTOM_PACKAGES="$HOME/site/wwwroot/.python_packages/lib/python3.6/site-packages" | ||
if [ -d "$CUSTOM_PACKAGES" ] | ||
then | ||
echo "appending $CUSTOM_PACKAGES to PYTHONPATH" | ||
export PYTHONPATH=$PYTHONPATH:$CUSTOM_PACKAGES | ||
else | ||
echo "path $CUSTOM_PACKAGES doesn't exist" | ||
fi | ||
|
||
CUSTOM_VENV_PACKAGES="$HOME/site/wwwroot/worker_venv/lib/python3.6/site-packages" | ||
if [ -d "$CUSTOM_VENV_PACKAGES" ] | ||
then | ||
echo "appending $CUSTOM_VENV_PACKAGES to PYTHONPATH" | ||
export PYTHONPATH=$PYTHONPATH:$CUSTOM_VENV_PACKAGES | ||
else | ||
echo "path $CUSTOM_VENV_PACKAGES doesn't exist" | ||
fi | ||
else | ||
echo "SKIP_PYTHONPATH_UPDATE == $SKIP_PYTHONPATH_UPDATE" | ||
fi | ||
|
||
echo "python == $(which python)" | ||
echo "PYTHONPATH == $PYTHONPATH" | ||
|
||
echo "starting the python worker" | ||
if [ -f $HOME/site/wwwroot/worker-bundle/worker-bundle ] | ||
then | ||
chmod +x $HOME/site/wwwroot/worker-bundle/worker-bundle | ||
$HOME/site/wwwroot/worker-bundle/worker-bundle $@ | ||
else | ||
python $DIR/worker.py $@ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"description":{ | ||
"language":"python", | ||
"extensions":[".py"], | ||
"defaultExecutablePath":"bash", | ||
"defaultWorkerPath":"start.sh" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
ARG BASE_IMAGE=mcr.microsoft.com/azure-functions/base:2.0-alpine | ||
FROM ${BASE_IMAGE} as runtime-image | ||
|
||
FROM microsoft/dotnet:2.2-aspnetcore-runtime-alpine | ||
|
||
# Install Python dependencies | ||
RUN apk add --no-cache libc6-compat libnsl wget git curl bash libffi-dev openssl-dev bzip2-dev zlib-dev readline-dev sqlite-dev build-base && \ | ||
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash && \ | ||
# workaround for https://github.com/grpc/grpc/issues/17255 | ||
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1 | ||
|
||
ENV PYENV_ROOT=/root/.pyenv \ | ||
PATH=/root/.pyenv/shims:/root/.pyenv/bin:$PATH | ||
|
||
# Install Python | ||
RUN PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.2 && \ | ||
pyenv global 3.7.2 && \ | ||
pip install pip==18.0 | ||
|
||
RUN export WORKER_TAG=1.0.0a6 && \ | ||
export AZURE_FUNCTIONS_PACKAGE_VERSION=1.0.0a5 && \ | ||
wget --quiet https://github.com/Azure/azure-functions-python-worker/archive/$WORKER_TAG.tar.gz && \ | ||
tar xvzf $WORKER_TAG.tar.gz && \ | ||
mv azure-functions-python-worker-* azure-functions-python-worker && \ | ||
mv /azure-functions-python-worker/python /python && \ | ||
rm -rf $WORKER_TAG.tar.gz /azure-functions-python-worker | ||
|
||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ | ||
HOME=/home \ | ||
FUNCTIONS_WORKER_RUNTIME=python | ||
|
||
COPY --from=runtime-image ["/azure-functions-host", "/azure-functions-host"] | ||
RUN mv /python /azure-functions-host/workers | ||
|
||
# Add custom worker config | ||
COPY ./python-context/start.sh /azure-functions-host/workers/python/ | ||
COPY ./python-context/worker.config.json /azure-functions-host/workers/python/ | ||
RUN chmod +x /azure-functions-host/workers/python/start.sh | ||
|
||
CMD [ "dotnet", "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,23 @@ | ||
ARG HOST_COMMIT=dev | ||
ARG BUILD_NUMBER=00001 | ||
FROM microsoft/dotnet:2.1-sdk AS installer-env | ||
ARG HOST_COMMIT | ||
ARG BUILD_NUMBER | ||
FROM microsoft/dotnet:2.2-sdk AS installer-env | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
ENV PublishWithAspNetCoreTargetManifest=false \ | ||
HOST_VERSION=2.0.12275 \ | ||
HOST_COMMIT=e3cdda25a9c473f6c239ae2f48d454cfda4adb66 | ||
|
||
ENV PublishWithAspNetCoreTargetManifest false | ||
|
||
RUN export ARG_BUILD_NUMBER=${BUILD_NUMBER} && \ | ||
if [[ $ARG_BUILD_NUMBER == dev* ]]; \ | ||
then export SCRIPT_BUILD_NUMBER=00001; \ | ||
else export SCRIPT_BUILD_NUMBER=$(echo $ARG_BUILD_NUMBER | cut -d'.' -f 3 | cut -d'-' -f 1); \ | ||
fi && \ | ||
echo "Build Number == $SCRIPT_BUILD_NUMBER" &&\ | ||
wget https://github.com/Azure/azure-functions-host/archive/${HOST_COMMIT}.tar.gz && \ | ||
tar xzf ${HOST_COMMIT}.tar.gz && \ | ||
RUN BUILD_NUMBER=$(echo $HOST_VERSION | cut -d'.' -f 3) && \ | ||
wget https://github.com/Azure/azure-functions-host/archive/$HOST_COMMIT.tar.gz && \ | ||
tar xzf $HOST_COMMIT.tar.gz && \ | ||
cd azure-functions-host-* && \ | ||
dotnet publish -v q /p:BuildNumber="$SCRIPT_BUILD_NUMBER" /p:CommitHash=${HOST_COMMIT} src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj --output /azure-functions-host | ||
dotnet publish -v q /p:BuildNumber=$BUILD_NUMBER /p:CommitHash=$HOST_COMMIT src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj --output /azure-functions-host && \ | ||
mv /azure-functions-host/workers /workers && mkdir /azure-functions-host/workers | ||
|
||
# Runtime image | ||
FROM microsoft/dotnet:2.1-aspnetcore-runtime | ||
COPY --from=installer-env ["/azure-functions-host", "/azure-functions-host"] | ||
COPY ./run-host.sh /azure-functions-host/run-host.sh | ||
FROM microsoft/dotnet:2.2-aspnetcore-runtime | ||
|
||
RUN chmod +x /azure-functions-host/run-host.sh | ||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ | ||
HOME=/home \ | ||
FUNCTIONS_WORKER_RUNTIME=dotnet | ||
|
||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot | ||
ENV HOME=/home | ||
ENV ASPNETCORE_URLS=http://+:80 | ||
EXPOSE 80 | ||
COPY --from=installer-env ["/azure-functions-host", "/azure-functions-host"] | ||
COPY --from=installer-env ["/workers", "/workers"] | ||
|
||
CMD /azure-functions-host/run-host.sh | ||
CMD [ "dotnet", "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ARG BASE_IMAGE=mcr.microsoft.com/azure-functions/base:2.0 | ||
FROM ${BASE_IMAGE} as runtime-image | ||
|
||
FROM microsoft/dotnet:2.2-aspnetcore-runtime | ||
|
||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ | ||
HOME=/home \ | ||
FUNCTIONS_WORKER_RUNTIME=dotnet | ||
|
||
COPY --from=runtime-image [ "/azure-functions-host", "/azure-functions-host" ] | ||
|
||
CMD [ "dotnet", "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll" ] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
ARG BASE_IMAGE=mcr.microsoft.com/azure-functions/python | ||
ARG BASE_IMAGE_TAG=dev-seabreeze | ||
ARG BASE_IMAGE=mcr.microsoft.com/azure-functions/python:2.0 | ||
|
||
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG} | ||
FROM microsoft/dotnet:2.2-sdk AS installer-env | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y gnupg && \ | ||
ENV PublishWithAspNetCoreTargetManifest=false \ | ||
HOST_VERSION=2.0.12276 \ | ||
HOST_COMMIT=1c0920e4a3709e333aa71338fcec62a80bb6b4f7 | ||
|
||
RUN BUILD_NUMBER=$(echo $HOST_VERSION | cut -d'.' -f 3) && \ | ||
wget https://github.com/Azure/azure-functions-host/archive/$HOST_COMMIT.tar.gz && \ | ||
tar xzf $HOST_COMMIT.tar.gz && \ | ||
cd azure-functions-host-* && \ | ||
dotnet publish -v q /p:BuildNumber=$BUILD_NUMBER /p:CommitHash=$HOST_COMMIT src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj --runtime debian.9-x64 --output /azure-functions-host | ||
|
||
FROM ${BASE_IMAGE} | ||
|
||
ENV FUNCTIONS_WORKER_RUNTIME= | ||
|
||
# Install node | ||
RUN mv /azure-functions-host/workers/python /python && \ | ||
rm -rf /azure-functions-host && \ | ||
apt-get update && \ | ||
apt-get install -y gnupg wget unzip curl && \ | ||
curl -sL https://deb.nodesource.com/setup_8.x | bash - && \ | ||
apt-get update && \ | ||
apt-get install -y nodejs | ||
|
||
ADD https://www.myget.org/F/azure-appservice/api/v2/package/Microsoft.Azure.Functions.PowerShellWorker/0.1.35-alpha PowerShellWorker.nupkg | ||
# Add all workers | ||
COPY --from=installer-env ["/azure-functions-host", "/azure-functions-host"] | ||
RUN mv /python /azure-functions-host/workers/ | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y unzip && \ | ||
unzip -q PowerShellWorker.nupkg && \ | ||
mv contentFiles/any/any/workers/powershell azure-functions-host/workers/powershell | ||
CMD [ "dotnet", "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
ARG BASE_IMAGE=mcr.microsoft.com/azure-functions/base | ||
ARG BASE_IMAGE_TAG=2.0 | ||
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG} | ||
ARG BASE_IMAGE=mcr.microsoft.com/azure-functions/base:2.0 | ||
FROM ${BASE_IMAGE} as runtime-image | ||
|
||
FROM microsoft/dotnet:2.2-aspnetcore-runtime | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y gnupg && \ | ||
apt-get install -y curl gnupg && \ | ||
curl -sL https://deb.nodesource.com/setup_8.x | bash - && \ | ||
apt-get update && \ | ||
apt-get install -y nodejs | ||
apt-get install -y nodejs | ||
|
||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ | ||
HOME=/home \ | ||
FUNCTIONS_WORKER_RUNTIME=node | ||
|
||
COPY --from=runtime-image [ "/azure-functions-host", "/azure-functions-host" ] | ||
COPY --from=runtime-image [ "/workers/node", "/azure-functions-host/workers/node" ] | ||
|
||
CMD [ "dotnet", "/azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost.dll" ] |
Oops, something went wrong.