-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge starting a database container via a task into dev
Fixes #18.
- Loading branch information
Showing
6 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM postgres:12 | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y postgresql-12-postgis-3 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from airflow.operators.python_operator import PythonOperator | ||
from airflow.utils.dates import days_ago | ||
import airflow | ||
|
||
from egon.data.airflow.tasks import initdb | ||
|
||
with airflow.DAG( | ||
"egon-data-processing-pipeline", | ||
description="The eGo^N data processing DAG.", | ||
default_args={"start_date": days_ago(1)}, | ||
) as example: | ||
setup = PythonOperator(task_id="initdb", python_callable=initdb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '3' | ||
services: | ||
egon-data-local-database: | ||
image: postgres:12-postgis | ||
container_name: egon-data-local-database | ||
restart: unless-stopped | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.postgis | ||
ports: | ||
- "127.0.0.1:54321:5432" | ||
environment: | ||
POSTGRES_DB: egon-data | ||
POSTGRES_USER: egon | ||
POSTGRES_PASSWORD: data | ||
volumes: | ||
- $HOME/docker/volumes/postgres/egon-data:/var/lib/postgresql/data | ||
- ./entrypoints:/docker-entrypoint-initdb.d/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE EXTENSION postgis; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import os.path | ||
import subprocess | ||
|
||
|
||
def initdb(): | ||
""" Initialize the local database used for data processing. """ | ||
subprocess.run( | ||
["docker-compose", "up", "-d", "--build"], | ||
cwd=os.path.dirname(__file__), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters