Skip to content

Commit 62be033

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 94cff12 commit 62be033

5 files changed

Lines changed: 213 additions & 818 deletions

File tree

dev_environment/start.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fi
2121
echo "==> Starting SQL-to-ARC with EXTERNAL API..."
2222
echo " - Local PostgreSQL will be started"
2323
echo " - Database will be initialized with Edaphobase dump"
24-
echo " - SQL-to-ARC will connect to the API configured in config-external.yaml"
24+
echo " - SQL-to-ARC will connect to the API configured in config.yaml"
2525
echo " - Using client certificates: client.crt, client.key"
2626
echo ""
2727

@@ -33,9 +33,9 @@ fi
3333
# Use sops exec-env to pass the decrypted key as an environment variable
3434
# without writing it to a physical disk file.
3535
sops exec-env "${script_dir}/client.key" \
36-
"docker compose -f compose-external.yaml up $BUILD_FLAG"
36+
"docker compose -f compose.yaml up $BUILD_FLAG"
3737

3838
echo ""
3939
echo "==> Services finished!"
40-
echo " - View logs: docker compose -f compose-external.yaml logs"
41-
echo " - Clean up: docker compose -f compose-external.yaml down"
40+
echo " - View logs: docker compose -f compose.yaml logs"
41+
echo " - Clean up: docker compose -f compose.yaml down"

docker/Dockerfile.sql_to_arc

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,40 @@
1-
# ---- Package Build Stage ----
2-
FROM python:3.12.12-alpine3.22 AS package-builder
3-
4-
WORKDIR /build
5-
6-
# Copy project files needed for package build
7-
COPY pyproject.toml uv.lock ./
8-
COPY middleware ./middleware
9-
10-
# Upgrade pip and install uv
11-
RUN pip install --no-cache-dir --upgrade pip==25.0.1 uv==0.9.10
12-
13-
# Build shared package first
14-
RUN uv build --package shared --wheel
15-
16-
# Build the api client package as wheel
17-
RUN uv build --package api_client --wheel
18-
19-
# Build the sql_to_arc package as wheel
20-
RUN uv build --package sql_to_arc --wheel
21-
221
# ---- Binary Build Stage ----
23-
FROM python:3.12.12-alpine3.22 AS binary-builder
2+
FROM python:3.12.12-alpine3.23 AS binary-builder
243

254
# Install build tools for PyInstaller
265
RUN apk add --no-cache \
276
build-base=0.5-r3 \
287
python3-dev=3.12.12-r0 \
29-
libffi-dev=3.4.8-r0 \
30-
openssl-dev=3.5.4-r0 \
31-
cargo=1.87.0-r0
8+
libffi-dev=3.5.2-r0 \
9+
openssl-dev=3.5.5-r0 \
10+
cargo=1.91.1-r0 \
11+
git=2.52.0-r0
3212

3313
WORKDIR /build
3414

3515
# Install uv and PyInstaller
36-
RUN pip install --no-cache-dir --upgrade pip==25.0.1 uv==0.9.10
37-
38-
# Copy built wheel from package-builder stage
39-
COPY --from=package-builder /build/dist/*.whl /tmp/wheels/
16+
RUN pip install --no-cache-dir --upgrade pip==25.3 uv==0.9.27
4017

41-
# Install the API package from wheel
42-
RUN uv pip install --system /tmp/wheels/*.whl
18+
# Copy project files needed for package build
19+
COPY pyproject.toml uv.lock ./
20+
COPY middleware ./middleware
4321

4422
# Install PyInstaller
4523
RUN uv pip install --system pyinstaller
4624

25+
# Install further dependencies for sql_to_arc
26+
RUN uv sync
27+
4728
# Build standalone binary with PyInstaller
4829
RUN pyinstaller --onedir \
4930
--name sql_to_arc \
50-
$(python -c "import middleware.sql_to_arc; print(middleware.sql_to_arc.__file__.replace('__init__.py', 'main.py'))")
31+
--paths .venv/lib/python3.12/site-packages \
32+
--paths /build/middleware/sql_to_arc/src \
33+
/build/middleware/sql_to_arc/src/middleware/sql_to_arc/main.py
5134

5235

5336
# ---- Runtime Stage ----
54-
FROM alpine:3.22.2
37+
FROM alpine:3.23.3
5538

5639
WORKDIR /middleware
5740

middleware/sql_to_arc/pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ dependencies = [
88
"arctrl>=3.0.0b15",
99
"psycopg[binary]>=3.3.2",
1010
"pydantic>=2.12.5",
11-
"shared",
12-
"api_client",
11+
"shared>=0.0.1",
12+
"api_client>=0.0.1",
13+
"opentelemetry-api>=1.39.1",
14+
"opentelemetry-sdk>=1.39.1"
1315
]
1416

1517
[tool.uv.sources]

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ dependencies = [
1010

1111
[dependency-groups]
1212
dev = [
13-
"fastapi[standard]>=0.124.0",
1413
"httpx>=0.28.1",
1514
"pylint>=4.0.4",
1615
"pytest>=9.0.2",

0 commit comments

Comments
 (0)