Skip to content

Commit 735fedc

Browse files
feat: Dockerfile
1 parent f18eeaa commit 735fedc

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

backend/Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM python:3.11-slim-bookworm
2+
3+
ENV PYTHONUNBUFFERED=1
4+
5+
WORKDIR /app/
6+
7+
# Install uv
8+
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
9+
COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /uvx /bin/
10+
11+
# Place executables in the environment at the front of the path
12+
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
13+
ENV PATH="/app/.venv/bin:$PATH"
14+
15+
# Compile bytecode
16+
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
17+
ENV UV_COMPILE_BYTECODE=1
18+
19+
# uv Cache
20+
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching
21+
ENV UV_LINK_MODE=copy
22+
23+
# Install dependencies
24+
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
25+
#RUN --mount=type=cache,target=/root/.cache/uv \
26+
# --mount=type=bind,source=uv.lock,target=uv.lock \
27+
# --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
28+
# uv sync --frozen --no-install-project
29+
30+
ENV PYTHONPATH=/app
31+
32+
# COPY ./scripts /app/scripts
33+
34+
35+
# COPY ./pyproject.toml ./uv.lock ./alembic.ini /app/
36+
37+
# COPY ./alembic ./apps ./common /app/
38+
COPY . /app/
39+
40+
# Sync the project
41+
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
42+
RUN --mount=type=cache,target=/root/.cache/uv \
43+
uv sync
44+
45+
CMD ["fastapi", "run", "--workers", "4", "main.py"]
46+
# CMD ["uvicorn", "main:app", "--reload"]
47+
# CMD ["python", "main.py", "--reload"]

backend/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "app"
2+
name = "sqlbot"
33
version = "0.1.0"
44
description = ""
55
requires-python = ">=3.10,<4.0"
@@ -38,6 +38,9 @@ dev-dependencies = [
3838
requires = ["hatchling"]
3939
build-backend = "hatchling.build"
4040

41+
[tool.hatch.build.targets.wheel]
42+
packages = ["."]
43+
4144
[tool.mypy]
4245
strict = true
4346
exclude = ["venv", ".venv", "alembic"]

0 commit comments

Comments
 (0)