Skip to content

Commit 9bca401

Browse files
committed
feat(backend): Migrate to uv and update packages
1 parent b677ad9 commit 9bca401

File tree

6 files changed

+742
-52
lines changed

6 files changed

+742
-52
lines changed

backend/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.venv
2+
venv

backend/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

backend/Dockerfile

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1-
FROM python:3.13-alpine3.21
1+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
2+
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
3+
4+
# Disable Python downloads, because we want to use the system interpreter
5+
# across both images. If using a managed Python version, it needs to be
6+
# copied from the build image into the final image; see `standalone.Dockerfile`
7+
# for an example.
8+
ENV UV_PYTHON_DOWNLOADS=0
29

310
WORKDIR /app
11+
RUN --mount=type=cache,target=/root/.cache/uv \
12+
--mount=type=bind,source=uv.lock,target=uv.lock \
13+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
14+
uv sync --locked --no-install-project --no-dev
15+
COPY . /app
16+
RUN --mount=type=cache,target=/root/.cache/uv \
17+
uv sync --locked --no-dev
418

5-
COPY ./requirements.txt /app/requirements.txt
619

7-
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
20+
# Then, use a final image without uv
21+
FROM python:3.13-slim-bookworm
822

9-
COPY . /app
23+
WORKDIR /app
24+
25+
# Copy the application from the builder
26+
COPY --from=builder --chown=app:app /app /app
27+
28+
# Place executables in the environment at the front of the path
29+
ENV PATH="/app/.venv/bin:$PATH"
1030

31+
# Run the FastAPI application by default
1132
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

backend/pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[project]
2+
name = "betterslcm-backend"
3+
version = "0.1.0"
4+
description = "FastAPI application for SLCM Switch"
5+
readme = "README.md"
6+
authors = [
7+
{ name = "Karan Parashar", email = "whyredfire@gmail.com" },
8+
]
9+
requires-python = ">=3.13"
10+
dependencies = [
11+
"bs4>=0.0.2",
12+
"fastapi[standard]>=0.116.1",
13+
"requests>=2.32.4",
14+
]

backend/requirements.txt

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)