diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f4950a2 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md index 176c49c..10fb27f 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,17 @@ uv sync 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 ```bash source .venv/bin/activate