Template
mirror of
https://github.com/Nekidev/uv-fastapi-tortoise.git
synced 2026-09-12 19:57:25 +00:00
Add default Dockerfile
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
|||||||
|
FROM git.moan.dev/docker/python/with-uv:3.14-alpine
|
||||||
|
|
||||||
|
# Only copy uv-related files, necessary for syncing and caching.
|
||||||
|
WORKDIR /app
|
||||||
|
COPY pyproject.toml uv.lock /app/
|
||||||
|
|
||||||
|
# Run with --no-dev on not to install dev dependencies.
|
||||||
|
RUN python3 -m uv sync --no-dev
|
||||||
|
|
||||||
|
# Copy the rest of your app.
|
||||||
|
COPY . /app/
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/bin/sh", "-c" ]
|
||||||
|
CMD [ "cd /app && python3 -m uv run --no-dev uvicorn project:app --workers ${WORKERS:-$(nproc)} --host ${BIND_HOST:-0.0.0.0} --port ${BIND_PORT:-8000}" ]
|
||||||
@@ -445,7 +445,19 @@ your now-renamed source code folder.
|
|||||||
To start the server, run:
|
To start the server, run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ uv run uvicorn project:app --reload
|
$ uv run uvicorn project:app --reload --reload-include "docs/**/*.md"
|
||||||
```
|
```
|
||||||
|
|
||||||
`project` is your import name.
|
`project` is your import name.
|
||||||
|
|
||||||
|
This template ships with a `Dockerfile` that will work out of the box by default in
|
||||||
|
most cases. By default, it uses the following environment variables:
|
||||||
|
|
||||||
|
| Name | Description | Possible Values | Default |
|
||||||
|
| ----------- | -------------------------------------------- | -------------------------------------- | ---------- |
|
||||||
|
| `BIND_HOST` | The IP address to bind the server to. | Available IP addresses. | `0.0.0.0` |
|
||||||
|
| `BIND_PORT` | The port to bind the server to. | Unused IP address ports. | `8000` |
|
||||||
|
| `WORKERS` | The amount of workers to start Uvicorn with. | An integer greater than or equal to 1. | `$(nproc)` |
|
||||||
|
|
||||||
|
If you're prefixing your environment variables with your project's name, make sure to
|
||||||
|
edit the `Dockerfile`'s `CMD` statement to reflect those changes.
|
||||||
|
|||||||
Reference in New Issue
Block a user