Skip to content

Commit

Permalink
Revise Dockerfile/compose.yml for one function app with db
Browse files Browse the repository at this point in the history
  • Loading branch information
steventux committed Jan 8, 2025
1 parent 8c0695f commit a4a4cc6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 136 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/python:4-python3.11-appservice
FROM mcr.microsoft.com/azure-functions/python:4-python3.11

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
AzureWebJobsFeatureFlags=EnableWorkerIndexing \
AzureWebJobsStorage=UseDevelopmentStorage=true \
APPLICATION_ID=${APPLICATION_ID} \
DATABASE_HOST=${DATABASE_HOST} \
DATABASE_USER=${DATABASE_USER} \
DATABASE_PASSWORD=${DATABASE_PASSWORD} \
DATABASE_NAME=${DATABASE_NAME} \
FUNCTIONS_WORKER_RUNTIME=python \
NOTIFY_API_KEY=${NOTIFY_API_KEY} \
NOTIFY_API_URL=${NOTIFY_API_URL}

COPY --from=root_dir Pipfile /
COPY --from=root_dir Pipfile.lock /
RUN pip install pipenv
RUN pipenv install --system

COPY . /home/site/wwwroot
COPY ./database/schema.sql /home/site/wwwroot/database/schema.sql
141 changes: 5 additions & 136 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
name: communication-management

services:
# External Dependencies
azurite:
container_name: azurite
image: mcr.microsoft.com/azure-storage/azurite
command: "azurite --loose --blobHost 0.0.0.0 --blobPort 10000 --queueHost 0.0.0.0 --queuePort 10001"
ports:
- 10000:10000
- 10001:10001
- 10002:10002
profiles:
- test-end-to-end
- test-integration
- dev
networks:
- frontend

azurite-setup:
container_name: azurite-setup
build:
context: ./
dockerfile: ./dependencies/azurite/Dockerfile
network_mode: host
depends_on:
- azurite
environment:
- AZURITE_CONNECTION_STRING=${AZURITE_CONNECTION_STRING}
- BLOB_CONTAINER_NAME=${BLOB_CONTAINER_NAME}
profiles:
- test-end-to-end
- test-integration
- dev

db:
image: postgres
healthcheck:
Expand All @@ -52,130 +20,31 @@ services:
volumes:
- ./pgdata:/var/lib/postgresql/pgdata
profiles:
- test-end-to-end
- test-integration
- dev

end-to-end-tests:
container_name: end-to-end-tests
communication-management:
container_name: communication-management
network_mode: host
build:
context: ./tests/end_to_end/
additional_contexts:
root_dir: .
shared_dir: ./src/shared/
context: .
dockerfile: Dockerfile
environment:
- AZURITE_CONNECTION_STRING=${AZURITE_CONNECTION_STRING}
- BLOB_CONTAINER_NAME=${BLOB_CONTAINER_NAME}
- DATABASE_HOST=${DATABASE_HOST}
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
- DATABASE_SSLMODE=${DATABASE_SSLMODE}
- DATABASE_USER=${DATABASE_USER}
profiles:
- test-end-to-end
depends_on:
azurite-setup:
condition: service_completed_successfully
azurite:
condition: service_started
db:
condition: service_healthy
notify:
condition: service_started
process-pilot-data:
condition: service_started
volumes:
- ./log/functions/notify:/tests/end_to_end/log/functions/notify
- ./log/functions/process-pilot-data:/tests/end_to_end/log/functions/process-pilot-data

# Functions
message-status:
container_name: message-status
network_mode: host
build:
context: ./src/functions/message_status/
additional_contexts:
root_dir: .
dockerfile: Dockerfile
environment:
- AzureWebJobsStorage=UseDevelopmentStorage=true
- ASPNETCORE_URLS=http://*:7073
- APPLICATION_ID=${APPLICATION_ID}
- NOTIFY_API_KEY=${NOTIFY_API_KEY}
- DATABASE_HOST=${DATABASE_HOST}
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
- DATABASE_SSLMODE=${DATABASE_SSLMODE}
- DATABASE_USER=${DATABASE_USER}

notify:
container_name: notify
network_mode: host
build:
context: ./src/functions/notify/
additional_contexts:
root_dir: .
dockerfile: Dockerfile
environment:
- AzureWebJobsStorage=UseDevelopmentStorage=true
- ASPNETCORE_URLS=http://*:7072
- DATABASE_HOST=${DATABASE_HOST}
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
- DATABASE_SSLMODE=${DATABASE_SSLMODE}
- DATABASE_USER=${DATABASE_USER}
- NOTIFY_API_KEY=${NOTIFY_API_KEY}
- NOTIFY_API_URL=${NOTIFY_API_URL}
- OAUTH2_API_KEY=${OAUTH2_API_KEY}
- OAUTH2_API_KID=${OAUTH2_API_KID}
- OAUTH2_TOKEN_URL=${OAUTH2_TOKEN_URL}
- PRIVATE_KEY=${PRIVATE_KEY}
volumes:
- ./log/functions/notify:/tmp/Functions/Host

process-pilot-data:
container_name: process-pilot-data
network_mode: host
build:
context: ./src/functions/process_pilot_data/
additional_contexts:
root_dir: .
dockerfile: Dockerfile
environment:
- AzureWebJobsStorage=UseDevelopmentStorage=true
- ASPNETCORE_URLS=http://*:7071
- FUNCTIONS_WORKER_RUNTIME=python
- BLOB_CONTAINER_NAME=${BLOB_CONTAINER_NAME}
- NOTIFY_FUNCTION_URL=${NOTIFY_FUNCTION_URL}
volumes:
- ./log/functions/process-pilot-data:/tmp/Functions/Host

integration-tests:
container_name: integration-tests
network_mode: host
build:
context: ./tests/integration/
additional_contexts:
root_dir: .
shared_dir: ./src/shared/
dockerfile: Dockerfile
environment:
- DATABASE_HOST=${DATABASE_HOST}
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
- DATABASE_SSLMODE=${DATABASE_SSLMODE}
- DATABASE_USER=${DATABASE_USER}
- NOTIFY_API_URL=${NOTIFY_API_URL}
profiles:
- test-integration
depends_on:
db:
condition: service_healthy

networks:
frontend:
# Specify driver options
driver: bridge
driver_opts:
com.docker.network.bridge.host_binding_ipv4: "127.0.0.1"
- ./log/function/communication-management:/tmp/Functions/Host

0 comments on commit a4a4cc6

Please sign in to comment.