Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Alina Lozovskaya
commited on
Commit
·
aa33679
1
Parent(s):
d1ed69b
Fix ownership Dockerfile
Browse files- Dockerfile +34 -13
- uv.lock +4 -4
Dockerfile
CHANGED
|
@@ -1,30 +1,51 @@
|
|
| 1 |
-
# Use
|
| 2 |
FROM python:3.12.1-slim
|
| 3 |
|
| 4 |
-
# Install dependencies required for UV and
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
curl ca-certificates git && \
|
| 7 |
rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
# Install UV (fast Python dependency manager)
|
| 10 |
-
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Set working directory
|
| 16 |
-
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
RUN uv venv && uv sync
|
| 21 |
|
| 22 |
-
# Copy application code
|
| 23 |
-
COPY
|
| 24 |
|
| 25 |
# Expose Gradio app port
|
| 26 |
EXPOSE 7860
|
| 27 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
|
|
|
| 1 |
+
# Use a minimal Python image
|
| 2 |
FROM python:3.12.1-slim
|
| 3 |
|
| 4 |
+
# Install system dependencies required for UV and Git
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
curl ca-certificates git && \
|
| 7 |
rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
# Install UV (fast Python dependency manager)
|
| 10 |
+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
|
| 11 |
+
mv /root/.local/bin/uv /usr/local/bin/uv && chmod +x /usr/local/bin/uv
|
| 12 |
|
| 13 |
+
# Verify UV installation
|
| 14 |
+
RUN uv --version
|
| 15 |
+
|
| 16 |
+
# Create a non-root user for security
|
| 17 |
+
RUN useradd -m -u 1000 uvuser
|
| 18 |
+
|
| 19 |
+
# Set environment variables properly
|
| 20 |
+
ENV HOME=/home/uvuser \
|
| 21 |
+
PATH="/usr/local/bin:$PATH" \
|
| 22 |
+
XDG_CACHE_HOME=/home/uvuser/.cache \
|
| 23 |
+
UV_VENV_PATH="/home/uvuser/.venv"
|
| 24 |
|
| 25 |
# Set working directory
|
| 26 |
+
WORKDIR /home/uvuser/app
|
| 27 |
+
|
| 28 |
+
# Ensure necessary directories exist and are writable
|
| 29 |
+
RUN mkdir -p /app/uploaded_files /home/uvuser/.cache && chown -R uvuser:uvuser /app /home/uvuser
|
| 30 |
+
|
| 31 |
+
# Copy pyproject.toml and uv.lock to the working directory
|
| 32 |
+
COPY pyproject.toml uv.lock ./
|
| 33 |
+
|
| 34 |
+
# Create the virtual environment and install dependencies as root
|
| 35 |
+
RUN uv venv && uv sync $(test -f uv.lock && echo "--frozen" || echo "")
|
| 36 |
+
|
| 37 |
+
# Fix ownership of cache and installed dependencies
|
| 38 |
+
RUN chown -R uvuser:uvuser /home/uvuser/.cache /home/uvuser/.venv /home/uvuser/app || true
|
| 39 |
|
| 40 |
+
# Switch to non-root user before running the app
|
| 41 |
+
USER uvuser
|
|
|
|
| 42 |
|
| 43 |
+
# Copy the rest of the application code
|
| 44 |
+
COPY --chown=uvuser:uvuser . ./
|
| 45 |
|
| 46 |
# Expose Gradio app port
|
| 47 |
EXPOSE 7860
|
| 48 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 49 |
|
| 50 |
+
# Run the application
|
| 51 |
+
CMD ["uv", "run", "python", "app.py"]
|
uv.lock
CHANGED
|
@@ -1150,7 +1150,7 @@ wheels = [
|
|
| 1150 |
|
| 1151 |
[[package]]
|
| 1152 |
name = "openai"
|
| 1153 |
-
version = "1.65.
|
| 1154 |
source = { registry = "https://pypi.org/simple" }
|
| 1155 |
dependencies = [
|
| 1156 |
{ name = "anyio" },
|
|
@@ -1162,9 +1162,9 @@ dependencies = [
|
|
| 1162 |
{ name = "tqdm" },
|
| 1163 |
{ name = "typing-extensions" },
|
| 1164 |
]
|
| 1165 |
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
| 1166 |
wheels = [
|
| 1167 |
-
{ url = "https://files.pythonhosted.org/packages/
|
| 1168 |
]
|
| 1169 |
|
| 1170 |
[[package]]
|
|
@@ -2042,7 +2042,7 @@ wheels = [
|
|
| 2042 |
[[package]]
|
| 2043 |
name = "yourbench"
|
| 2044 |
version = "0.2.0"
|
| 2045 |
-
source = { git = "https://github.com/huggingface/yourbench.git?rev=v0.2-alpha-summarization#
|
| 2046 |
dependencies = [
|
| 2047 |
{ name = "asyncio" },
|
| 2048 |
{ name = "datasets" },
|
|
|
|
| 1150 |
|
| 1151 |
[[package]]
|
| 1152 |
name = "openai"
|
| 1153 |
+
version = "1.65.3"
|
| 1154 |
source = { registry = "https://pypi.org/simple" }
|
| 1155 |
dependencies = [
|
| 1156 |
{ name = "anyio" },
|
|
|
|
| 1162 |
{ name = "tqdm" },
|
| 1163 |
{ name = "typing-extensions" },
|
| 1164 |
]
|
| 1165 |
+
sdist = { url = "https://files.pythonhosted.org/packages/32/4f/b34b6fad12e1f6b3f42922214c161d5ef74a50fa97d9ae7d680db0958ff4/openai-1.65.3.tar.gz", hash = "sha256:9b7cd8f79140d03d77f4ed8aeec6009be5dcd79bbc02f03b0e8cd83356004f71", size = 358821 }
|
| 1166 |
wheels = [
|
| 1167 |
+
{ url = "https://files.pythonhosted.org/packages/86/d5/b8378be0f4cf192992aa3080eb9ddcdca3109b399be61984424aaa79f847/openai-1.65.3-py3-none-any.whl", hash = "sha256:a155fa5d60eccda516384d3d60d923e083909cc126f383fe4a350f79185c232a", size = 472758 },
|
| 1168 |
]
|
| 1169 |
|
| 1170 |
[[package]]
|
|
|
|
| 2042 |
[[package]]
|
| 2043 |
name = "yourbench"
|
| 2044 |
version = "0.2.0"
|
| 2045 |
+
source = { git = "https://github.com/huggingface/yourbench.git?rev=v0.2-alpha-summarization#11d9df14106262cd5f768808307d9ca48c532e02" }
|
| 2046 |
dependencies = [
|
| 2047 |
{ name = "asyncio" },
|
| 2048 |
{ name = "datasets" },
|