-
Notifications
You must be signed in to change notification settings - Fork 0
Use docker compose locally to run azure functions
Gabriel Cobeña Cedeño edited this page Nov 22, 2021
·
3 revisions
Config Makefile, adding the following lines:
deploy:
sls package
docker compose up --build
install-docker:
@echo "=========================================Installing dependencies Time Tracker========================================="
pip install --upgrade pip
pip install -r requirements.txt
@echo "Completed! "
For environment variables you should contact some team partner and ask for variables of the .env
file.
After, you need to check docker-compose.yml
and validate you file looks like:
version: '3.9'
services:
api:
build:
context: .
dockerfile: ./Dockerfile
ports:
- 8080:80
env_file:
- .env
database:
image: postgres:14
ports:
- "5433:5432"
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASS}
- POSTGRES_DB=${DB_NAME}
To run azure functions on docker compose, you need to add the following lines to Dockerfile
:
FROM mcr.microsoft.com/azure-functions/python:3.0-python3.6
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
RUN apt install unzip && apt-get install make
COPY .serverless/azure-time-tracker.zip /home/site/wwwroot/
RUN cd /home/site/wwwroot/ && unzip azure-time-tracker.zip && rm azure-time-tracker.zip
RUN cd /home/site/wwwroot/ && make install-docker
When you have been terminated the config, you can run the command make deploy
to build the docker container with azure-functions and database.
If you have some changes in the project to deploy you need to execute, make deploy
to update the files on the container.
For test the app, go to your browser and type:
http://localhost:8080/api/activities
You’re going to see and empty list for the first time [].