(feat) add Dockerfile
This commit is contained in:
16
Dockerfile
Normal file
16
Dockerfile
Normal 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"]
|
||||||
11
README.md
11
README.md
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user