Skip to content

Commit d251410

Browse files
authored
Merge pull request #5 from michaelconan/feat/startup
feat: add config file, script adjustments, compose variables
2 parents dddbb0f + be1e8e3 commit d251410

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

.devcontainer/docker-compose.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ version: '3.8'
22

33
services:
44
app:
5+
env:
6+
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://postgres:postgres@db/postgres
7+
AIRFLOW__API__AUTH_BACKENDS: "airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session"
8+
AIRFLOW__CORE__FERNET_KEY: ""
9+
AIRFLOW__CORE__EXECUTOR: LocalExecutor
10+
AIRFLOW__CORE__LOAD_EXAMPLES: "true"
11+
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: "true"
512
build:
6-
# Use Airflow Dockerfile
7-
context: ..
13+
context: .
814
dockerfile: Dockerfile
915

1016
volumes:

.gitattributes

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
* text=auto
2-
*.py eol=lf
2+
*.py eol=lf
3+
script/* eol=lf

README.md

+22-3
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,40 @@ I have found a few resources covering deploying Airflow on Azure, none of which
2323
- DAGs should contain a number of related steps (e.g., extract-transform-load)
2424
- DAGs can be linked to one another via datasets to enable triggering and dependency graph
2525

26-
## Airflow Setup
26+
## Python Setup (Attempt #2)
27+
28+
As an alternative to Docker I tried a standard Python configuration for easier deployment to App Service.
29+
30+
### Airflow Setup
31+
32+
### Azure Setup
33+
34+
1. Create Web App + PostgreSQL with Python
35+
2. Turn on Application Insights, Logging
36+
37+
### Automated Deployment
38+
39+
1. Referenced [this workflow](https://learn.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel%2Cpython%2Cpythonn) to deploy Python app to App Service
40+
41+
## Docker Setup (Attempt #1)
42+
43+
This was working fine locally but deployment to App Service did not go as well. Goal to use a custom extended airflow Docker container
44+
45+
### Airflow Setup
2746

2847
1. Started with official [docker compose](https://airflow.apache.org/docs/apache-airflow/stable/howto/docker-compose/index.html)
2948
2. Decided to [extend the image](https://airflow.apache.org/docs/docker-stack/build.html#extending-the-image) starting with the slim version due to limited packaged requirements
3049
3. Switched to `LocalExecutor`
3150
4. Stripped down the Docker Compose to a single container to run webserver + scheduler and use for dev container
3251

33-
## Azure Setup
52+
### Azure Setup
3453

3554
From the resources above I determined I can run the webserver and scheduler together in a single container with `LocalExecutor`. `CeleryExecutor` shouldn't be necessary unless scale increases and multiple workers are required.
3655

3756
1. Create PostgreSQL flexible server for database
3857
2. Create App Service app with container (NOTE: I followed [this tutorial](https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?tabs=debian&pivots=container-linux#enable-ssh) to configure SSH access in app service)
3958

40-
# Automated Deployment
59+
### Automated Docker Deployment
4160

4261
1. Referenced [this workflow](https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images#publishing-images-to-github-packages) to build and publish to GitHub Container Registry
4362
2. Referenced [this workflow](https://learn.microsoft.com/en-us/azure/app-service/deploy-best-practices#use-github-actions) to deploy updated image to Azure Web App

script/setup

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ script/bootstrap
1313
echo "==> Setting up DB…"
1414

1515
# Reset Airflow database
16-
airflow db downgrade base
16+
airflow db reset --yes
1717
airflow db migrate

webserver_config.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""
2+
webserver_config.py
3+
4+
Configuration of Airflow webserver and definition of Flask app object,
5+
which may be beneficial for Azure app service custom startup.
6+
"""
7+
from flask import current_app as app

0 commit comments

Comments
 (0)