I have a containerised Django Rest Framework
application along with a Celery
container for background task processing and Redis
container as a broker.
I want to deploy this application to the Azure Serverless
. I have been trying to look for the solutions but had no luck so far.
Here are the two question I have –
-
Is it possible to deploy multi-container group application to
Azure Serverless
? -
Is it possible to deploy the tech stack I have stated above to
Azure Serverless
? (please provide an example or a link to the documentation to guide me.)
Project’s Docker Configurations –
docker-compose
version: "3"
services:
redis:
container_name: redis-container
image: "redis:latest"
ports:
- "6379:6379"
restart: always
command: "redis-server"
snowflake-optimizer:
container_name: snowflake-optimizer
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/snowflake-backend
ports:
- "80:80"
expose:
- "80"
restart: always
command: "python manage.py runserver 0.0.0.0:80"
links:
- redis
celery:
container_name: celery-container
build:
context: .
dockerfile: Dockerfile.celery
command: "celery -A snowflake_optimizer worker -l INFO"
volumes:
- .:/snowflake-optimizer
restart: always
links:
- redis
depends_on:
- snowflake-optimizer
Dockerfile
(Django Rest Framework)
FROM python:3.7-slim
ENV PYTHONUNBUFFERED 1
RUN apt-get update &&
apt-get install python3-dev default-libmysqlclient-dev gcc -y &&
apt-get install -y libssl-dev libffi-dev &&
python -m pip install --upgrade pip &&
mkdir /snowflake-backend
WORKDIR /snowflake-backend
COPY ./requirements.txt /requirements.txt
COPY . /snowflake-backend
EXPOSE 80
RUN pip install -r /requirements.txt
RUN pip install -U "celery[redis]"
RUN python manage.py makemigrations &&
python manage.py migrate
CMD [ "python", "manage.py", "runserver", "0.0.0.0:80"]
Docker.celery
(Celery)
FROM python:3.7-slim
ENV PYTHONUNBUFFERED 1
RUN apt-get update &&
apt-get install python3-dev default-libmysqlclient-dev gcc -y &&
apt-get install -y libssl-dev libffi-dev &&
python -m pip install --upgrade pip &&
mkdir /snowflake-backend
WORKDIR /snowflake-backend
COPY ./requirements.txt /requirements.txt
COPY . /snowflake-backend
EXPOSE 80
RUN pip install -r /requirements.txt
RUN pip install -U "celery[redis]"
CMD [ "celery", "-A", "snowflake_optimizer", "worker", "-l ", "INFO"]
2
Answers
To deploy a multi-container app on Azure Containers Instances using a Docker Compose file using the Azure CLI:
Documentation
You can also use the docker-compose CLI directly.
Documentation
The questions is what do we mean here by
Azure Serverless
. Usually people associate serverless with serverless functions. As of 2020 November,Azure Functions
do not support Docker deployment, at least not in a way to be able to deploy a Django application.Understandably there are other options to be able to deploy containers into Azure: