Skip to content

Commit b28dced

Browse files
committed
feat(DoutD): enable worker to spawn containers on host (ADAnalise-container)
1 parent 6bb5e61 commit b28dced

File tree

7 files changed

+359
-120
lines changed

7 files changed

+359
-120
lines changed

.github/workflows/build.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ jobs:
6464
with:
6565
convention-name: conventionalcommits
6666

67-
- name: Install Conda Dependencies
68-
uses: conda-incubator/setup-miniconda@v3
67+
- uses: conda-incubator/setup-miniconda@v3
6968
with:
70-
miniconda-version: "latest"
71-
mamba-version: "*"
69+
miniforge-version: latest
7270
environment-file: conda/env.yaml
7371
channels: conda-forge,nodefaults
7472
activate-environment: alertflow
75-
use-mamba: true
76-
miniforge-variant: Mambaforge
73+
auto-update-conda: true
74+
conda-solver: libmamba
7775

7876
- name: Create environment variables file
7977
run: |
@@ -93,11 +91,11 @@ jobs:
9391
9492
- name: Build Base Image
9593
run: |
96-
sugar build
94+
sugar compose build
9795
9896
- name: Start Airflow
9997
run: |
100-
sugar up --options -d
98+
sugar compose up --options -d
10199
102100
- name: Wait Containers
103101
run: |

.sugar.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
version: 1.0.0
2-
compose-app: docker-compose
1+
backend: compose
32
env-file: .env
43
defaults:
5-
group: {{ env.ENV }}
6-
4+
group: dev
75
groups:
86
dev:
97
project-name: alertflow
10-
compose-path:
8+
config-path:
119
- docker/compose.yaml
1210
- docker/compose-dev.yaml
1311
env-file: .env
@@ -21,7 +19,7 @@ groups:
2119

2220
prod:
2321
project-name: alertflow
24-
compose-path:
22+
config-path:
2523
- docker/compose.yaml
2624
- docker/compose-prod.yaml
2725
env-file: .env

alertflow/dags/satellite-weather/brasil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"""
1717

1818
import os
19-
from pathlib import Path
2019
from datetime import date, timedelta
2120
from itertools import chain
21+
from pathlib import Path
2222

2323
import pendulum
2424
from airflow import DAG
@@ -83,7 +83,7 @@ def fetch_ds(locale, dt, uri, api_key):
8383
locale=locale,
8484
) as ds:
8585
for geocode in geocodes:
86-
adm = ADM2.get(code=geocode):
86+
adm = ADM2.get(code=geocode)
8787
with engine.connect() as conn:
8888
ds.cope.to_sql(adm, conn, tablename, "weather")
8989
file = Path(f"{basename}.zip")

docker/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ RUN addgroup --gid ${HOST_GID} airflow \
4444
&& chmod 0440 /etc/sudoers.d/airflow \
4545
&& chown -R ${HOST_UID}:${HOST_GID} ${AIRFLOW_HOME}/ /opt/airflow/
4646

47+
RUN groupadd docker && usermod -aG docker airflow && newgrp docker
48+
4749
ENV PATH "$PATH:/home/airflow/.local/bin"
4850
ENV PATH "$PATH:/usr/bin/dirname"
4951

5052
COPY --chown=airflow alertflow/airflow.cfg ${AIRFLOW_HOME}/airflow.cfg
5153
COPY --chown=airflow docker/scripts/entrypoint.sh /entrypoint.sh
52-
COPY --chown=airflow pyproject.toml ${AIRFLOW_HOME}
54+
COPY --chown=airflow pyproject.toml README.md ${AIRFLOW_HOME}
5355
RUN chmod +x /entrypoint.sh
5456

5557
USER airflow
@@ -59,6 +61,6 @@ RUN curl -sSL https://install.python-poetry.org | python3
5961
WORKDIR ${AIRFLOW_HOME}
6062

6163
RUN poetry config virtualenvs.create false \
62-
&& poetry install --only main
64+
&& poetry install --only main --no-root
6365

6466
ENTRYPOINT [ "/entrypoint.sh" ]

docker/compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ services:
189189
condition: service_healthy
190190
startup:
191191
condition: service_completed_successfully
192+
volumes:
193+
- /var/run/docker.sock:/var/run/docker.sock
192194
networks:
193195
- alertflow
194196

poetry.lock

Lines changed: 340 additions & 100 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ sqlalchemy = "<2.0"
1515
flake8 = "^7.0.0"
1616
black = "^24.2.0"
1717
isort = "^5.13.2"
18-
containers-sugar = "1.11.1"
19-
compose-go = "^2.24.6"
18+
containers-sugar = "^1.16.1"
2019
apache-airflow = "^2.10.2"
2120

2221
[build-system]

0 commit comments

Comments
 (0)