Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Alina Lozovskaya
commited on
Commit
•
fd8845d
1
Parent(s):
f6c24b8
Temp reverting to poetry
Browse files- Dockerfile +13 -18
- backend/Dockerfile.dev +12 -22
- backend/pyproject.toml +25 -49
- docker-compose.yml +1 -1
Dockerfile
CHANGED
@@ -8,26 +8,23 @@ COPY frontend/ ./
|
|
8 |
RUN npm run build
|
9 |
|
10 |
# Build backend
|
11 |
-
FROM
|
12 |
-
|
13 |
WORKDIR /app
|
14 |
|
15 |
# Create non-root user
|
16 |
-
|
17 |
-
|
18 |
-
# Create and configure cache directory
|
19 |
-
RUN mkdir -p /app/.cache
|
20 |
-
#RUN chown -R user:user /app
|
21 |
|
22 |
-
#
|
23 |
-
|
24 |
-
ENV UV_CACHE_DIR=/app/.cache
|
25 |
|
26 |
-
#
|
27 |
-
|
|
|
28 |
|
29 |
-
#
|
30 |
-
|
|
|
|
|
31 |
|
32 |
# Copy backend code
|
33 |
COPY backend/ .
|
@@ -59,10 +56,8 @@ ENV HF_HOME=/app/.cache \
|
|
59 |
NODE_ENV=production
|
60 |
|
61 |
# Note: HF_TOKEN should be provided at runtime, not build time
|
62 |
-
|
63 |
-
RUN chmod -R 777 /app/
|
64 |
-
# USER user
|
65 |
EXPOSE 7860
|
66 |
|
67 |
# Start both servers with wait-for
|
68 |
-
CMD ["sh", "-c", "
|
|
|
8 |
RUN npm run build
|
9 |
|
10 |
# Build backend
|
11 |
+
FROM python:3.9-slim
|
|
|
12 |
WORKDIR /app
|
13 |
|
14 |
# Create non-root user
|
15 |
+
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
# Install poetry
|
18 |
+
RUN pip install poetry
|
|
|
19 |
|
20 |
+
# Create and configure cache directory
|
21 |
+
RUN mkdir -p /app/.cache && \
|
22 |
+
chown -R user:user /app
|
23 |
|
24 |
+
# Copy and install backend dependencies
|
25 |
+
COPY backend/pyproject.toml backend/poetry.lock* ./
|
26 |
+
RUN poetry config virtualenvs.create false \
|
27 |
+
&& poetry install --no-interaction --no-ansi --no-root --only main
|
28 |
|
29 |
# Copy backend code
|
30 |
COPY backend/ .
|
|
|
56 |
NODE_ENV=production
|
57 |
|
58 |
# Note: HF_TOKEN should be provided at runtime, not build time
|
59 |
+
USER user
|
|
|
|
|
60 |
EXPOSE 7860
|
61 |
|
62 |
# Start both servers with wait-for
|
63 |
+
CMD ["sh", "-c", "uvicorn app.asgi:app --host 0.0.0.0 --port 7861 & while ! nc -z localhost 7861; do sleep 1; done && cd frontend && npm run serve"]
|
backend/Dockerfile.dev
CHANGED
@@ -1,35 +1,25 @@
|
|
1 |
-
|
2 |
-
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
3 |
|
4 |
-
# Set the working directory
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
# Enable bytecode compilation
|
8 |
-
ENV UV_COMPILE_BYTECODE=1
|
9 |
-
|
10 |
-
# Copy from the cache instead of linking since it's a mounted volume
|
11 |
-
ENV UV_LINK_MODE=copy
|
12 |
-
|
13 |
-
# Environment variables configuration for logs
|
14 |
-
ENV PYTHONUNBUFFERED=1
|
15 |
-
ENV LOG_LEVEL=INFO
|
16 |
-
|
17 |
# Install required system dependencies
|
18 |
RUN apt-get update && apt-get install -y \
|
19 |
build-essential \
|
20 |
&& rm -rf /var/lib/apt/lists/*
|
21 |
|
22 |
-
#
|
23 |
-
|
24 |
|
25 |
-
#
|
26 |
-
|
27 |
|
28 |
-
#
|
29 |
-
|
|
|
30 |
|
31 |
-
#
|
32 |
-
|
|
|
33 |
|
34 |
# In dev, mount volume directly
|
35 |
-
CMD ["
|
|
|
1 |
+
FROM python:3.9-slim
|
|
|
2 |
|
|
|
3 |
WORKDIR /app
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Install required system dependencies
|
6 |
RUN apt-get update && apt-get install -y \
|
7 |
build-essential \
|
8 |
&& rm -rf /var/lib/apt/lists/*
|
9 |
|
10 |
+
# Install poetry
|
11 |
+
RUN pip install poetry
|
12 |
|
13 |
+
# Copy Poetry configuration files
|
14 |
+
COPY pyproject.toml poetry.lock* ./
|
15 |
|
16 |
+
# Install dependencies
|
17 |
+
RUN poetry config virtualenvs.create false && \
|
18 |
+
poetry install --no-interaction --no-ansi --no-root
|
19 |
|
20 |
+
# Environment variables configuration for logs
|
21 |
+
ENV PYTHONUNBUFFERED=1
|
22 |
+
ENV LOG_LEVEL=INFO
|
23 |
|
24 |
# In dev, mount volume directly
|
25 |
+
CMD ["uvicorn", "app.asgi:app", "--host", "0.0.0.0", "--port", "7860", "--reload", "--log-level", "warning", "--no-access-log"]
|
backend/pyproject.toml
CHANGED
@@ -1,54 +1,30 @@
|
|
1 |
-
[
|
2 |
name = "llm-leaderboard-backend"
|
3 |
version = "0.1.0"
|
4 |
description = "Backend for the Open LLM Leaderboard"
|
5 |
-
|
6 |
-
|
7 |
-
dependencies
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
[
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
"flake8 >=7.1.1",
|
28 |
-
]
|
29 |
-
|
30 |
-
[tool.ruff]
|
31 |
-
line-length = 120
|
32 |
-
target-version = "py312"
|
33 |
-
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
|
34 |
-
ignore=["I","EM","FBT","TRY003","S101","D101","D102","D103","D104","D105","G004","D107","FA102"]
|
35 |
-
fixable=["ALL"]
|
36 |
-
select=["ALL"]
|
37 |
-
|
38 |
-
[tool.ruff.lint]
|
39 |
-
select = ["E", "F"]
|
40 |
-
fixable = ["ALL"]
|
41 |
-
ignore = ["E501"] # line too long (black is taking care of this)
|
42 |
-
|
43 |
-
[tool.isort]
|
44 |
-
profile = "black"
|
45 |
-
|
46 |
-
[tool.black]
|
47 |
-
line-length = 119
|
48 |
|
49 |
[build-system]
|
50 |
-
requires = ["
|
51 |
-
build-backend = "
|
52 |
-
|
53 |
-
[tool.hatch.build.targets.wheel]
|
54 |
-
packages = ["backend"]
|
|
|
1 |
+
[tool.poetry]
|
2 |
name = "llm-leaderboard-backend"
|
3 |
version = "0.1.0"
|
4 |
description = "Backend for the Open LLM Leaderboard"
|
5 |
+
authors = ["Your Name <your.email@example.com>"]
|
6 |
+
|
7 |
+
[tool.poetry.dependencies]
|
8 |
+
python = "^3.9"
|
9 |
+
fastapi = "^0.104.1"
|
10 |
+
uvicorn = {extras = ["standard"], version = "^0.24.0"}
|
11 |
+
numpy = "1.24.3"
|
12 |
+
pandas = "^2.0.0"
|
13 |
+
datasets = "^2.0.0"
|
14 |
+
pyarrow = "^14.0.1"
|
15 |
+
python-multipart = "^0.0.6"
|
16 |
+
huggingface-hub = "^0.19.0"
|
17 |
+
transformers = "^4.35.0"
|
18 |
+
safetensors = "^0.4.0"
|
19 |
+
aiofiles = "^24.1.0"
|
20 |
+
fastapi-cache2 = "^0.2.1"
|
21 |
+
|
22 |
+
[tool.poetry.group.dev.dependencies]
|
23 |
+
pytest = "^7.4.0"
|
24 |
+
black = "^23.7.0"
|
25 |
+
isort = "^5.12.0"
|
26 |
+
flake8 = "^6.1.0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
[build-system]
|
29 |
+
requires = ["poetry-core>=1.0.0"]
|
30 |
+
build-backend = "poetry.core.masonry.api"
|
|
|
|
|
|
docker-compose.yml
CHANGED
@@ -13,7 +13,7 @@ services:
|
|
13 |
- ENVIRONMENT=${ENVIRONMENT:-development}
|
14 |
- HF_TOKEN=${HF_TOKEN}
|
15 |
- HF_HOME=${HF_HOME:-/.cache}
|
16 |
-
command:
|
17 |
|
18 |
frontend:
|
19 |
build:
|
|
|
13 |
- ENVIRONMENT=${ENVIRONMENT:-development}
|
14 |
- HF_TOKEN=${HF_TOKEN}
|
15 |
- HF_HOME=${HF_HOME:-/.cache}
|
16 |
+
command: uvicorn app.asgi:app --host 0.0.0.0 --port 8000 --reload
|
17 |
|
18 |
frontend:
|
19 |
build:
|