(feat) add Dockerfile

This commit is contained in:
Nicolas Sebastian Schuler
2025-07-16 10:48:46 +02:00
parent 7f1034a22f
commit eaa96ef6ce
2 changed files with 27 additions and 0 deletions

16
Dockerfile Normal file
View File

@@ -0,0 +1,16 @@
FROM python:3.12.6
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Copy the project into the image
ADD . /app
# Sync the project into a new environment, asserting the lockfile is up to date
WORKDIR /app
RUN uv sync --locked
ENV PATH="/app/.venv/bin:$PATH"
CMD ["fastapi", "run", "app/main.py", "--port", "80"]

View File

@@ -17,6 +17,17 @@ uv sync
fastapi run app/main.py fastapi run app/main.py
``` ```
## Build Docker Image
```bash
docker build -t stack:latest .
```
## Use Docker Image
```bash
docker run -d --name mycontainer -p 80:80 stack:latest
```
## Testing ## Testing
```bash ```bash
source .venv/bin/activate source .venv/bin/activate