Skip to content

Commit be6276d

Browse files
committed
fixed docker
1 parent cc0ea8d commit be6276d

12 files changed

+57
-31
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
SHELL := /bin/bash
2+
13
clean-all: clean-dataset clean-pred clean-ghz clean-model clean-checkpoints clean-history
24

35
clean-dataset:
@@ -22,4 +24,7 @@ pack:
2224
zip -r dataset-images.zip dataset/
2325

2426
lock:
25-
conda-lock -f environment.yml
27+
conda-lock -f environment.yml
28+
29+
airflow-up:
30+
source airflow-setup-test.sh && docker compose down && docker compose build && docker compose up -d

airflow-entrypoint.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
until pg_isready -h db; do
4+
echo "Not ready yet..."
5+
sleep 2
6+
done
7+
8+
echo "Migrating...."
9+
airflow db migrate
10+
11+
# USER, PASSWORD and EMAIl come from env variables
12+
echo "Creating Airflow user ${USER}..."
13+
airflow users create \
14+
--username $USER \
15+
--firstname user \
16+
--lastname user \
17+
--role Admin \
18+
--email ${EMAIL} \
19+
--password ${PASSWORD}
20+
21+
echo "Running scheduler...."
22+
airflow scheduler &
23+
24+
exec airflow "$@"

airflow.Dockerfile

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
FROM python:3.12.10-slim-bullseye AS setup
2-
2+
WORKDIR /
33
COPY requirements.txt .
44
RUN python -m venv /proj-venv
5-
65
ENV PIPENV="/proj-venv/bin/pip"
7-
86
RUN ${PIPENV} install -r requirements.txt
97

10-
FROM apache/airflow:slim-2.11.0-python3.12 AS serve
118

9+
10+
FROM busybox:1.37.0 AS entry
11+
WORKDIR /
12+
COPY airflow-entrypoint.sh entrypoint.sh
13+
RUN chmod +x entrypoint.sh
14+
15+
16+
FROM apache/airflow:slim-2.11.0-python3.12 AS serve
1217
COPY --from=setup /proj-venv/lib/python3.12/site-packages/ /home/airflow/.local/lib/python3.12/site-packages
1318

1419
WORKDIR /home/airflow/project
1520
COPY . .
1621

17-
ARG USER=default
18-
ARG PASSWORD=default
19-
20-
21-
RUN airflow db migrate
22-
RUN airflow users create --username $USER \
23-
--firstname user \
24-
--lastname user \
25-
--role Admin \
26-
--email ${EMAIL} \
27-
--password ${PASSWORD}
28-
29-
RUN airflow scheduler &
22+
WORKDIR /
23+
COPY --from=entry /entrypoint.sh .
3024

3125
EXPOSE 8080
32-
ENTRYPOINT [ "airflow", "webserver", "--port", "8080" ]
26+
ENTRYPOINT [ "/entrypoint.sh" ]
27+
CMD [ "webserver", "--port", "8080" ]
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
*
2-
!dags/
32
!ai/
43
!export/
54
!generate/
65
!utils/
6+
!args/
77
!Makefile
88
!requirements.txt
9+
!airflow-entrypoint.sh

compose.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ services:
2424
build:
2525
context: .
2626
dockerfile: airflow.Dockerfile
27-
args:
28-
- USER=${AIRFLOW_USERNAME}
29-
- PASSWORD=${AIRFLOW_PASSWORD}
30-
- EMAIL=${AIRFLOW_EMAIL}
3127
volumes:
3228
- ./data:/home/airflow/data
3329
- ./dags:/opt/airflow/dags
3430
environment:
31+
- USER=${AIRFLOW_USERNAME}
32+
- PASSWORD=${AIRFLOW_PASSWORD}
33+
- EMAIL=${AIRFLOW_EMAIL}
3534
- PYTHONPATH=/home/airflow/project
3635
- TARGET_FOLDER=/home/airflow/data
3736
- TZ=America/Sao_Paulo

database.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM postgres:17.2-alpine3.21
22

3-
COPY entrypoint.sh /docker-entrypoint-initdb.d/
3+
COPY db-entrypoint.sh /docker-entrypoint-initdb.d/entrypoint.sh
44

55
RUN chmod +x /docker-entrypoint-initdb.d/entrypoint.sh

database.Dockerfile.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
*
2-
!entrypoint.sh
2+
!db-entrypoint.sh

entrypoint.sh renamed to db-entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
echo "Waiting for PostgreSQL to start..."
24
until pg_isready -U $POSTGRES_USER; do
35
echo "Not ready yet..."

generate/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from utils.datatypes import FilePath, df_schema, Dimensions
2626
from utils.image import transform_image
2727
from utils.colors import Colors
28-
from utils.random_circuit import get_random_circuit
28+
from generate.random_circuit import get_random_circuit
2929
from utils.helpers import get_measurements
3030

3131
Schema = Dict[str, Any]

generate/ghz.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from PIL import Image
55
import torch
66

7-
from image import transform_image
7+
from utils.image import transform_image
88
from args.parser import parse_args
9-
from constants import ghz_image_file, ghz_file
9+
from utils.constants import ghz_image_file, ghz_file
1010
from utils.datatypes import FilePath, Dimensions
1111

1212

0 commit comments

Comments
 (0)