Skip to content

Comments

Fix CMD path in FastAPI Dockerfile#16701

Merged
zanieb merged 1 commit intoastral-sh:mainfrom
jspablo:main
Nov 12, 2025
Merged

Fix CMD path in FastAPI Dockerfile#16701
zanieb merged 1 commit intoastral-sh:mainfrom
jspablo:main

Conversation

@jspablo
Copy link
Contributor

@jspablo jspablo commented Nov 12, 2025

Summary

Fix suggestion for uv when used with FastAPI and Docker.

Test Plan

The Dockerfile sets /app as workdir, later the CMD command points again to app/main.py instead of only main.py, causing the following error:

Path does not exist app/main.py

@zanieb zanieb added the documentation Improvements or additions to documentation label Nov 12, 2025
@zanieb zanieb merged commit 92230ba into astral-sh:main Nov 12, 2025
86 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Nov 14, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.9.8` -> `0.9.9` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.9.9`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#099)

[Compare Source](astral-sh/uv@0.9.8...0.9.9)

Released on 2025-11-12.

##### Deprecations

- Deprecate use of `--project` in `uv init` ([#&#8203;16674](astral-sh/uv#16674))

##### Enhancements

- Add iOS support to Python interpreter discovery ([#&#8203;16686](astral-sh/uv#16686))
- Reject ambiguously parsed URLs ([#&#8203;16622](astral-sh/uv#16622))
- Allow explicit values in `uv version --bump` ([#&#8203;16555](astral-sh/uv#16555))
- Warn on use of managed pre-release Python versions when a stable version is available ([#&#8203;16619](astral-sh/uv#16619))
- Allow signing trampolines on Windows by using `.rcdata` to store metadata ([#&#8203;15068](astral-sh/uv#15068))
- Add `--only-emit-workspace` and similar variants to `uv export` ([#&#8203;16681](astral-sh/uv#16681))

##### Preview features

- Add `uv workspace dir` command ([#&#8203;16678](astral-sh/uv#16678))
- Add `uv workspace metadata` command ([#&#8203;16516](astral-sh/uv#16516))

##### Configuration

- Add `UV_NO_DEFAULT_GROUPS` environment variable ([#&#8203;16645](astral-sh/uv#16645))

##### Bug fixes

- Remove `torch-model-archiver` and `torch-tb-profiler` from PyTorch backend ([#&#8203;16655](astral-sh/uv#16655))
- Fix Pixi environment detection ([#&#8203;16585](astral-sh/uv#16585))

##### Documentation

- Fix `CMD` path in FastAPI Dockerfile ([#&#8203;16701](astral-sh/uv#16701))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNzMuMSIsInVwZGF0ZWRJblZlciI6IjQxLjE3My4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
@Vminoz
Copy link

Vminoz commented Nov 16, 2025

@jspablo sorry, this change was incorrect, please see https://github.com/astral-sh/uv-fastapi-example

It may be somewhat confusing though that the project structure uses app/ as main module and copies files to /app as per docker conventions.

In short main.py is in fact at /app/app/main.py at runtime and this change is invalid.

Example

$ git clone https://github.com/astral-sh/uv-fastapi-example && cd uv-fastapi-example
Cloning into 'uv-fastapi-example'...
remote: Enumerating objects: 33, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 33 (delta 8), reused 6 (delta 6), pack-reused 14 (from 1)
Receiving objects: 100% (33/33), 26.33 KiB | 4.39 MiB/s, done.
Resolving deltas: 100% (9/9), done.
$ git rev-parse HEAD
a1e313147b9be055167fe500d457d7c0b2f51318
$ grep -e 'app\b' Dockerfile
COPY . /app
WORKDIR /app
CMD ["/app/.venv/bin/fastapi", "run", "app/main.py", "--port", "80"]
$ docker build -qt fastapi-app . && docker run -p 8000:80 fastapi-app
sha256:9c0fe8617c2c026bd7193ce1a096dc44b62180c52a8531fa7aa0e847242c1b2a
INFO     Using path app/main.py
INFO     Resolved absolute path /app/app/main.py
INFO     Searching for package file structure from directories with __init__.py
         files
INFO     Importing from /app

 ╭─ Python package file structure ─╮
 │                                 │
 │  📁 app                         │
 │  ├── 🐍 __init__.py             │
 │  └── 🐍 main.py                 │
 │                                 │
 ╰─────────────────────────────────╯

INFO     Importing module app.main
INFO     Found importable FastAPI app

 ╭── Importable FastAPI app ──╮
 │                            │
 │  from app.main import app  │
 │                            │
 ╰────────────────────────────╯

INFO     Using import string app.main:app

 ╭─────────── FastAPI CLI - Production mode ───────────╮
 │                                                     │
 │  Serving at: http://0.0.0.0:80                      │
 │                                                     │
 │  API docs: http://0.0.0.0:80/docs                   │
 │                                                     │
 │  Running in production mode, for development use:   │
 │                                                     │
 │  fastapi dev                                        │
 │                                                     │
 ╰─────────────────────────────────────────────────────╯

INFO:     Started server process [1]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)

I suppose a reverting PR is in order or some other change to lower the risk of confusion.

@zanieb
Copy link
Member

zanieb commented Nov 16, 2025

@jspablo did you not test the change as described in the test plan.. ?

@jspablo
Copy link
Contributor Author

jspablo commented Nov 16, 2025

It was a mistake on my side when moving to a compose file, the build context was different and thought the error was the folder, which caused the misunderstanding and fixing it locally with the wrong setup.

@zanieb
Copy link
Member

zanieb commented Nov 16, 2025

Interesting, thanks for the context

zanieb added a commit that referenced this pull request Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants