-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (58 loc) · 3.07 KB
/
Copy pathDockerfile
File metadata and controls
73 lines (58 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# ── task-loop Dockerfile ────────────────────────────────────────────────
# Multi-stage image for the task-loop harness (web UI + scheduler).
#
# Build:
# docker build -t taskloop:latest .
#
# Run (bare):
# docker run -p 8000:8000 \
# -e TASKLOOP_ENV=production \
# -e TASKLOOP_LLM_BASE_URL=http://host.docker.internal:11434/v1 \
# -v taskloop-data:/app/data \
# taskloop:latest
#
# Run (compose): see docker-compose.yml
#
# Production config comes from real env vars — a .env is NEVER loaded in the
# container (the TASKLOOP_ENV switch in config.py + .dockerignore keep both
# the loader and the file out of the image).
# ────────────────────────────────────────────────────────────────────────
# ── Stage 1: build ─────────────────────────────────────────────────────
FROM python:3.12-slim AS build
WORKDIR /src
# Install dependencies + the package itself. Copying the manifest and source
# before the RUN is required for `pip install .` to resolve the project.
COPY pyproject.toml ./
COPY taskloop/ ./taskloop/
RUN pip install --no-cache-dir .
# ── Stage 2: runtime ───────────────────────────────────────────────────
FROM python:3.12-slim AS runtime
# tini – proper PID-1 signal handling so the scheduler shuts down cleanly.
# curl – used by the HEALTHCHECK.
RUN apt-get update && apt-get install -y --no-install-recommends \
tini \
curl \
&& rm -rf /var/lib/apt/lists/*
# Non-root user (uid 1000) to run the harness as.
RUN groupadd --system --gid 1000 taskloop \
&& useradd --system --uid 1000 --gid taskloop \
--home-dir /app --shell /usr/sbin/nologin taskloop
WORKDIR /app
# Copy the installed Python environment (deps + the installed `taskloop`
# package + the `taskloop` console script) from the build stage.
COPY --from=build /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=build /usr/local/bin /usr/local/bin
# The shipped tool catalog. Overridable at runtime by mounting a copy.
COPY tools.yaml .
# Runtime data lives in /app/data: SQLite DB + state.json. Persist via a
# volume (or bind-mount) so a container restart keeps tasks/runs.
RUN mkdir -p /app/data && chown -R taskloop:taskloop /app/data
USER taskloop
EXPOSE 8000
# Health check: the web API /api/status answers when the scheduler is up.
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD curl -sf http://localhost:8000/api/status || exit 1
# tini as PID 1 for clean shutdown + signal forwarding.
ENTRYPOINT ["tini", "--"]
# Default command: scheduler + web UI. Set TASKLOOP_* env vars to configure.
CMD ["taskloop", "web", "--host", "0.0.0.0", "--port", "8000"]