feat: add worker loop and production Dockerfiles

This commit is contained in:
Jonathan
2026-07-10 17:16:24 +02:00
parent d441d0561f
commit 3e44de093e
7 changed files with 67 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
node_modules
.next
.env
+23
View File
@@ -0,0 +1,23 @@
FROM node:22-slim AS build
WORKDIR /app
RUN apt-get update && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json* ./
COPY prisma ./prisma
RUN npm install
COPY . .
RUN npx prisma generate && npm run build
FROM node:22-slim AS run
WORKDIR /app
RUN apt-get update && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
ENV NODE_ENV=production
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static
COPY --from=build /app/public ./public
COPY --from=build /app/prisma ./prisma
COPY --from=build /app/node_modules/prisma ./node_modules/prisma
COPY --from=build /app/node_modules/@prisma ./node_modules/@prisma
COPY --from=build /app/docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh
EXPOSE 3000
CMD ["./docker-entrypoint.sh"]
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
set -e
node node_modules/prisma/build/index.js migrate deploy
exec node server.js
View File
+3
View File
@@ -0,0 +1,3 @@
tests
__pycache__
*.pyc
+6
View File
@@ -0,0 +1,6 @@
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY lyra_worker ./lyra_worker
CMD ["python", "-m", "lyra_worker.main"]
+28
View File
@@ -0,0 +1,28 @@
import time
from lyra_worker.claim import claim_next
from lyra_worker.db import connect
from lyra_worker.pipeline import run_pipeline
IDLE_SLEEP = 2.0
STAGE_DELAY = 1.0 # visible progress in the UI
def run_forever() -> None:
conn = connect()
print("worker: waiting for jobs", flush=True)
try:
while True:
job_id = claim_next(conn)
if job_id is None:
time.sleep(IDLE_SLEEP)
continue
print(f"worker: claimed job {job_id}", flush=True)
run_pipeline(conn, job_id, stage_delay=STAGE_DELAY)
print(f"worker: imported job {job_id}", flush=True)
finally:
conn.close()
if __name__ == "__main__":
run_forever()