Skip to content

Commit 171b04e

Browse files
committed
Update Dockerfile and docker-compose.yml for Python 3.13, add graphviz installation, and modify main.py for RabbitMQ connection. Introduce GitHub Actions workflow for Docker image publishing.
1 parent f248ba7 commit 171b04e

File tree

5 files changed

+38
-72
lines changed

5 files changed

+38
-72
lines changed

.github/workflows/publish.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
main-workflow:
10+
uses: Evolutionary-Algorithms-On-Click/operations/.github/workflows/docker-publish.yml@main
11+
with:
12+
branch: ${{ github.ref }}
13+
image_name: ${{ github.repository }}
14+
event_name: ${{ github.event_name }}
15+
permissions:
16+
contents: read
17+
packages: write
18+
id-token: write

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Use an official Python runtime as a parent image
2-
FROM python:3.9
2+
FROM python:3.13
33

44
# Set the working directory in the container
55
WORKDIR /app
66

77
# Copy the current directory contents into the container
88
COPY . .
99

10+
# Install graphviz
11+
RUN apt-get update && apt-get install -y graphviz libgraphviz-dev pkg-config
12+
1013
# Install dependencies
1114
RUN pip install --no-cache-dir -r requirements.txt
12-
1315
# Run the application
14-
CMD ["python", "worker.py"]
16+
CMD ["python", "main.py"]

docker-compose.yml

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,11 @@
1-
version: '3.8'
21

32
services:
4-
rabbitmq:
5-
image: "rabbitmq:4.0-management"
6-
container_name: rabbitmq
7-
ports:
8-
- "5672:5672"
9-
- "15672:15672"
3+
auth:
4+
image: ghcr.io/evolutionary-algorithms-on-click/runner:main
105
environment:
11-
RABBITMQ_DEFAULT_USER: user
12-
RABBITMQ_DEFAULT_PASS: password
13-
14-
minio:
15-
image: "minio/minio"
16-
container_name: minio
17-
environment:
18-
MINIO_ACCESS_KEY: minioadmin
19-
MINIO_SECRET_KEY: minioadmin
20-
ports:
21-
- "9000:9000"
22-
- "9001:9001"
23-
command: server /data --console-address ":9001"
24-
volumes:
25-
- minio-data:/data
26-
27-
cockroachdb:
28-
image: cockroachdb/cockroach:v23.1.11
29-
container_name: cockroachdb
30-
command: start-single-node --insecure
31-
ports:
32-
- "26257:26257"
33-
- "8081:8080"
34-
volumes:
35-
- cockroach-data:/cockroach/cockroach-data
36-
37-
# postgresql://root@localhost:26257/defaultdb?sslmode=disable
38-
39-
# worker:
40-
# build: .
41-
# container_name: worker
42-
# depends_on:
43-
# - rabbitmq
44-
# - minio
45-
# - cockroachdb
46-
# environment:
47-
# RABBITMQ_HOST: rabbitmq
48-
# RABBITMQ_QUEUE: task_queue
49-
# MINIO_URL: minio:9000
50-
# MINIO_ACCESS_KEY: minioadmin
51-
# MINIO_SECRET_KEY: minioadmin
52-
# BUCKET_NAME: code-files
53-
# DB_HOST: cockroachdb
54-
# DB_NAME: mydatabase
55-
# DB_USER: root
56-
# DB_PASSWORD: ""
57-
58-
volumes:
59-
minio-data:
60-
cockroach-data:
6+
COCKROACHDB_URL : postgresql://[email protected]:26257/defaultdb?sslmode=disable
7+
MINIO_URL : host.docker.internal:9000
8+
MINIO_ACCESS_KEY : <minio-key>
9+
MINIO_SECRET_KEY : <minio-pass>
10+
RABBITMQ_URL : amqp://<user>:<password>@host.docker.internal:5672/
11+
RABBITMQ_QUEUE: <task_queue_name>

main.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,15 @@
77
import psycopg2
88

99
# Read environment variables
10-
RABBITMQ_URL = os.getenv(
11-
"RABBITMQ_URL", "amqp://guest:guest@localhost:5672/"
12-
) # Connection string
10+
RABBITMQ_URL = os.getenv("RABBITMQ_URL", "amqp://user:password@localhost:5672/") # Connection string
11+
1312
QUEUE_NAME = os.getenv("RABBITMQ_QUEUE", "task_queue")
1413

1514
MINIO_URL = os.getenv("MINIO_URL", "localhost:9000")
1615
MINIO_ACCESS_KEY = os.getenv("MINIO_ACCESS_KEY", "minioadmin")
17-
MINIO_SECRET_KEY = os.getenv(
18-
"MINIO_SECRET_KEY", "minioadmin"
19-
)
16+
MINIO_SECRET_KEY = os.getenv("MINIO_SECRET_KEY", "minioadmin")
2017

21-
COCKROACHDB_URL = os.getenv(
22-
"COCKROACHDB_URL", "postgresql://root@localhost:26257/defaultdb?sslmode=disable"
23-
)
18+
COCKROACHDB_URL = os.getenv("COCKROACHDB_URL", "postgresql://root@localhost:26257/defaultdb?sslmode=disable")
2419

2520

2621
def parse_json_string(json_string):
@@ -191,6 +186,8 @@ def process_message(ch, method, properties, body):
191186

192187
file_parent_dir = os.path.dirname(full_file_path)
193188

189+
ch.basic_ack(delivery_tag=method.delivery_tag)
190+
194191
if (runType == "ml"):
195192
print("Running python " + full_file_path)
196193
# Run the subprocess from the parent directory of the python script.
@@ -247,7 +244,6 @@ def process_message(ch, method, properties, body):
247244
except Exception as e:
248245
print(f"Error running {fileName}: {e}")
249246

250-
ch.basic_ack(delivery_tag=method.delivery_tag)
251247

252248

253249
# Connect to RabbitMQ using the connection string

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ scikit-learn
1010
pillow
1111
networkx
1212
pygraphviz
13-
pandas
14-
itertools
13+
pandas

0 commit comments

Comments
 (0)