-
Notifications
You must be signed in to change notification settings - Fork 0
Reconcile Dockerfile & compose for dev/prod targets #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f6f83cc
initial tweaks to Dockerfile & dev compose
mbarlow12 412596f
feat(docker): reconcile Dockerfile & compose for dev/prod targets
mbarlow12 d61aaea
fix(docker): tighten Dockerfile and compose config
mbarlow12 8d5b19a
refactor(docker): split compose into base and local dev override
mbarlow12 d985079
docs(readme): add Make Targets section
mbarlow12 4bb97ee
refactor(docker): use volume mounts instead of develop.watch
mbarlow12 689b916
refactor(docker): collapse to 2-stage build (base + runtime)
mbarlow12 25d3a62
refactor(compose): widen volume mounts with scoped reload dirs
mbarlow12 0b4bb67
chore: whitespace
mbarlow12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,5 +7,6 @@ | |
| **/.pytest_cache | ||
| **/.mypy_cache | ||
| **/.ruff_cache | ||
| **/tests | ||
| build | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,38 @@ | ||
| FROM python:3.12.12-slim-trixie AS builder | ||
| # ── base: Python + uv + third-party deps ───────────────────────────── | ||
| FROM python:3.12-slim-trixie AS base | ||
|
|
||
| # better console streaming for docker logs | ||
| ENV PYTHONUNBUFFERED=1 \ | ||
| UV_COMPILE_BYTECODE=1 \ | ||
| UV_LINK_MODE=copy | ||
| UV_LINK_MODE=copy \ | ||
| UV_PYTHON_DOWNLOADS=0 \ | ||
| UV_NO_DEV=1 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Install uv | ||
| # Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv | ||
| COPY --from=ghcr.io/astral-sh/uv:0.9.25 /uv /uvx /bin/ | ||
|
|
||
| # --- Copy workspace metadata | ||
| COPY pyproject.toml uv.lock ./ | ||
|
|
||
| # Copy the member pyprojects (and/or whole packages) that are needed to resolve deps | ||
| COPY deployments/api/pyproject.toml deployments/api/pyproject.toml | ||
| COPY deployments/api/src /app/src | ||
|
|
||
| COPY packages/stitch-core/pyproject.toml packages/stitch-core/pyproject.toml | ||
| COPY packages/stitch-core/src packages/stitch-core/src | ||
| WORKDIR /app | ||
|
|
||
| # Install deps for the api project (important: target the subproject) | ||
| # Create venv and sync using the lock for the API project | ||
| # Third-party deps only — cached until uv.lock changes. | ||
| # All metadata via bind mounts (not copied into the layer). | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
AlexAxthelm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| uv sync --locked --project deployments/api --no-install-workspace | ||
| --mount=type=bind,source=uv.lock,target=uv.lock \ | ||
| --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
| uv sync --frozen --no-install-workspace --package stitch-api | ||
|
|
||
| # ------------------------------------------------------- | ||
| # ── runtime target ──────────────────────────────────────────────────── | ||
| FROM base AS runtime | ||
mbarlow12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| FROM python:3.12.12-slim-trixie AS runtime | ||
| RUN groupadd --system --gid 999 stitch-app \ | ||
| && useradd --system --gid 999 --uid 999 --create-home stitch-app | ||
|
|
||
| ENV PYTHONUNBUFFERED=1 | ||
| WORKDIR /app | ||
| COPY ./deployments/api /app/deployments/api | ||
| COPY ./packages /app/packages | ||
|
|
||
| # Copy the ready-to-run virtualenv | ||
| COPY --from=builder /app/.venv /app/.venv | ||
| ENV PATH="/app/.venv/bin:$PATH" | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| --mount=type=bind,source=uv.lock,target=uv.lock \ | ||
| --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
| uv sync --locked --package stitch-api | ||
|
|
||
| # Copy only the API source (runtime code) | ||
| COPY deployments/api/src /app/src | ||
| ENV PYTHONPATH=/app/src | ||
| ENV PATH="/app/.venv/bin:$PATH" | ||
| USER stitch-app | ||
|
|
||
| CMD ["uvicorn", "stitch.api.main:app", "--host", "0.0.0.0", "--port", "8000"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| services: | ||
| api: | ||
| environment: | ||
| LOG_LEVEL: debug | ||
| volumes: | ||
| - ./deployments/api/src:/app/deployments/api/src | ||
| - ./packages:/app/packages | ||
| command: | ||
| - uvicorn | ||
| - stitch.api.main:app | ||
| - --host | ||
| - "0.0.0.0" | ||
| - --port | ||
| - "8000" | ||
| - --reload | ||
| - --reload-dir | ||
| - /app/deployments/api/src | ||
| - --reload-dir | ||
| - /app/packages | ||
| - --reload-exclude | ||
| - "*/tests/*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.