Sign inSign up

alpine/func

Sponsored OSS

By alpine

Updated almost 2 years ago

Azure Functions Core Tools

Image
Integration & delivery
0

3.9K

alpine/func repository overview

Background

I’d like to deploy Azure Function Apps from a Docker container rather than a host. For instance, running func publish in a CI/CD pipeline.

What’s Azure Function Core Tools

Azure Functions Core Tools lets you develop and test your functions on your local computer. It can also public functions to Azure

The official document (https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local) shows how you can publish a function easily via command func

func azure functionapp publish <FunctionAppName>
The problems

The installation of the func command in Docker is quite huge, taking up approximately 1.5GB of space. Additionally, the func command relies on Azure CLI (command az), which is a Python package with a massive size of around 1GB.

If you also require the deployment of Node.js and .NET functions, it’s important to allocate extra space for their installation as well.

The Dockerfile

What does the Dockerfile look like?

# ref: https://stackoverflow.com/a/69764607/3671801
FROM mcr.microsoft.com/azure-functions/python:4-python3.10

# Install azure-cli
RUN pip3 install azure-cli

# Install azure-functions-core-tools
# ref: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local
RUN apt-get update && \
  apt-get install -y curl gpg && \
  apt install -y lsb-release && \
  curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg && \
  mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg && \
  echo "deb [arch=amd64] https://packages.microsoft.com/debian/$(lsb_release -rs | cut -d'.' -f 1)/prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list && \
  apt-get update && \
  apt-get install -y azure-functions-core-tools-4

# Install dotnet runtime 6.0
RUN wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
  dpkg -i packages-microsoft-prod.deb && \
  rm packages-microsoft-prod.deb && \
  rm /etc/apt/sources.list.d/mssql-release.list && \
  apt-get update && \
  apt-get install -y dotnet-sdk-6.0
After build, the image size is 3.43GB

Build it

$ docker build -t func . 

$ docker images |grep func

alpine/func    latest be8a74bbc495   About a minute ago   6.47GB

$ docker run -ti --rm -v $(pwd):/apps -w /apps alpine/func bash
root@debfbd8e29a5:/apps# az login
root@debfbd8e29a5:/apps# func azure functionapp publish <function_app_name>

# if you need debug
root@debfbd8e29a5:/apps# export CLI_DEBUG=1
root@debfbd8e29a5:/apps# func azure functionapp publish <function_app_name>
...

If you have any ideas to reduce the size, let me know

Tag summary

Content type

Image

Digest

sha256:be8a74bbc

Size

1.5 GB

Last updated

almost 2 years ago

docker pull alpine/func

This week's pulls

Pulls:

7

Last week