Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions infra/docker/agent.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ COPY apps/eval ./apps/eval
COPY apps/embedding ./apps/embedding
COPY apps/reranker ./apps/reranker

RUN uv sync --no-dev
# Scoped for the same reason as api.Dockerfile: the workspace contains two
# torch-dependent model sidecars this image does not run.
RUN uv sync --no-dev --package dcode-agent

EXPOSE 8001

CMD ["uv", "run", "--package", "dcode-agent", \
"uvicorn", "dcode_agent.main:app", \
"--host", "0.0.0.0", "--port", "8001"]
# The venv binary directly, not `uv run`.
#
# `uv run` re-syncs the environment at container start, and without --no-dev
# that means downloading mypy and ruff every single time. On the first Railway
# deploy it also could not find alembic at all, because the build-time sync had
# installed nothing (see the RUN above). apps/embedding already did it this way
# with a comment saying why; api, worker and agent had not caught up.
CMD ["sh", "-c", "exec /app/.venv/bin/uvicorn dcode_agent.main:app --host ${HOST:-::} --port ${PORT:-8001}"]
23 changes: 20 additions & 3 deletions infra/docker/api.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ COPY apps/embedding ./apps/embedding
COPY apps/reranker ./apps/reranker
COPY infra/migrations ./infra/migrations

RUN uv sync --no-dev
# --package, not the whole workspace.
#
# `uv sync --no-dev` at the workspace root installs EVERY member, and two of
# them — dcode-embedding and dcode-reranker — depend on torch, transformers and
# sentence-transformers. This image runs none of that, and it was pulling
# several GB to sit unused. It was invisible locally because the layer was
# cached; the first clean build took twelve minutes.
#
# The sources are still copied so uv can resolve the workspace; only the
# installation is scoped. alembic is a dcode-api dependency, so the migration
# this image runs before each deploy still has it.
RUN uv sync --no-dev --package dcode-api

EXPOSE 8000

Expand All @@ -28,5 +39,11 @@ EXPOSE 8000
# by nothing. The defaults are the previous literals, so compose is unchanged
# — `sh -c exec` keeps uvicorn as the container's main process rather than
# leaving a shell in front of it to swallow signals.
CMD ["sh", "-c", "exec uv run --package dcode-api uvicorn dcode_api.main:app \
--host ${HOST:-0.0.0.0} --port ${PORT:-8000}"]
# The venv binary directly, not `uv run`.
#
# `uv run` re-syncs the environment at container start, and without --no-dev
# that means downloading mypy and ruff every single time. On the first Railway
# deploy it also could not find alembic at all, because the build-time sync had
# installed nothing (see the RUN above). apps/embedding already did it this way
# with a comment saying why; api, worker and agent had not caught up.
CMD ["sh", "-c", "exec /app/.venv/bin/uvicorn dcode_api.main:app --host ${HOST:-0.0.0.0} --port ${PORT:-8000}"]
4 changes: 2 additions & 2 deletions infra/docker/railway-agent-worker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ term() {
trap term TERM INT

echo "[entrypoint] starting agent on :${PORT:-8001}"
uv run --package dcode-agent uvicorn dcode_agent.main:app \
/app/.venv/bin/uvicorn dcode_agent.main:app \
--host "${HOST:-::}" --port "${PORT:-8001}" &
agent_pid=$!

echo "[entrypoint] starting index worker"
uv run --package dcode-worker python -m dcode_worker.main &
/app/.venv/bin/python -m dcode_worker.main &
worker_pid=$!

# `wait -n` returns as soon as EITHER child exits. Waiting on both in sequence
Expand Down
4 changes: 3 additions & 1 deletion infra/docker/railway-agent-worker.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ COPY apps/eval ./apps/eval
COPY apps/embedding ./apps/embedding
COPY apps/reranker ./apps/reranker

RUN uv sync --no-dev
# Both packages, and only those two. The workspace also contains the torch-
# dependent model sidecars, which this image does not run — see api.Dockerfile.
RUN uv sync --no-dev --package dcode-agent --package dcode-worker

COPY infra/docker/railway-agent-worker-entrypoint.sh /usr/local/bin/dcode-entrypoint
RUN chmod +x /usr/local/bin/dcode-entrypoint
Expand Down
13 changes: 11 additions & 2 deletions infra/docker/worker.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ COPY apps/eval ./apps/eval
COPY apps/embedding ./apps/embedding
COPY apps/reranker ./apps/reranker

RUN uv sync --no-dev
# Scoped for the same reason as api.Dockerfile: the workspace contains two
# torch-dependent model sidecars this image does not run.
RUN uv sync --no-dev --package dcode-worker

CMD ["uv", "run", "--package", "dcode-worker", "python", "-m", "dcode_worker.main"]
# The venv binary directly, not `uv run`.
#
# `uv run` re-syncs the environment at container start, and without --no-dev
# that means downloading mypy and ruff every single time. On the first Railway
# deploy it also could not find alembic at all, because the build-time sync had
# installed nothing (see the RUN above). apps/embedding already did it this way
# with a comment saying why; api, worker and agent had not caught up.
CMD ["/app/.venv/bin/python", "-m", "dcode_worker.main"]
6 changes: 5 additions & 1 deletion infra/railway/api.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ watchPatterns = [
# *this* service (Deploy.md §6 PR 1). Running it anywhere else is how the column
# ends up at a dimension nothing else agrees with. `upgrade head` is idempotent,
# so running it on every deploy is safe.
preDeployCommand = ["uv run alembic -c infra/migrations/alembic.ini upgrade head"]
# The venv binary, not `uv run`. `uv run` re-syncs at start and, without
# --no-dev, downloads mypy and ruff before doing anything: the first deploy
# spent twelve minutes on that and then failed with "Failed to spawn: alembic",
# because the build-time sync had installed nothing at all.
preDeployCommand = ["/app/.venv/bin/alembic -c infra/migrations/alembic.ini upgrade head"]

# The deep probe, not /healthz. /healthz answers ok with Postgres, Redis and
# RabbitMQ all down; /readyz checks all three plus the embedding-dimension
Expand Down
Loading