Spaces:
Running
Running
Ashwin V. Mohanan
commited on
Commit
·
6042424
1
Parent(s):
955dabc
Reorder setting up application code
Browse files- Dockerfile +19 -16
Dockerfile
CHANGED
@@ -31,21 +31,33 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
|
31 |
libgl1 \
|
32 |
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
33 |
|
34 |
-
# Install `uv`
|
35 |
-
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
36 |
-
|
37 |
# Create a non-root user
|
38 |
RUN useradd -m -u 1000 appuser
|
39 |
|
40 |
# Set working directory
|
41 |
WORKDIR /home/appuser/app
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
# Copy dependency files and install dependencies
|
44 |
COPY --chown=appuser pyproject.toml dawsonia.toml uv.lock LICENSE README.md ./
|
45 |
-
RUN uv sync -p 3.10 --frozen --no-cache \
|
46 |
-
&& chown -R appuser:appuser /home/appuser/app/.venv \
|
47 |
-
&& rm -rf /root/.cache /home/appuser/.cache
|
48 |
|
|
|
|
|
|
|
49 |
|
50 |
# Copy application code
|
51 |
COPY --chown=appuser app app
|
@@ -53,15 +65,6 @@ COPY --chown=appuser table_formats table_formats
|
|
53 |
COPY --chown=appuser examples examples
|
54 |
COPY --chown=appuser output output
|
55 |
|
56 |
-
# Ensure non-root user has write access to cache and tmp directories
|
57 |
-
RUN mkdir -p /home/appuser/.cache/transformers /home/appuser/tmp /home/appuser/.cache \
|
58 |
-
&& chown -R appuser:appuser /home/appuser/.cache /home/appuser/tmp/ /home/appuser/app/
|
59 |
-
|
60 |
-
# Switch to non-root user
|
61 |
-
USER appuser
|
62 |
-
|
63 |
-
# Expose port for Gradio
|
64 |
-
EXPOSE 7860
|
65 |
|
66 |
# Command to run the application
|
67 |
-
CMD ["uv", "run", "app/main.py"]
|
|
|
31 |
libgl1 \
|
32 |
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
33 |
|
|
|
|
|
|
|
34 |
# Create a non-root user
|
35 |
RUN useradd -m -u 1000 appuser
|
36 |
|
37 |
# Set working directory
|
38 |
WORKDIR /home/appuser/app
|
39 |
|
40 |
+
# Switch to non-root user
|
41 |
+
USER appuser
|
42 |
+
|
43 |
+
# Expose port for Gradio
|
44 |
+
EXPOSE 7860
|
45 |
+
|
46 |
+
# Ensure non-root user has write access to cache and tmp directories
|
47 |
+
RUN mkdir -p /home/appuser/.cache/transformers /home/appuser/tmp /home/appuser/.cache
|
48 |
+
|
49 |
+
# Install `uv`
|
50 |
+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
51 |
+
|
52 |
+
# Change shell to bash
|
53 |
+
SHELL ["/bin/bash", "-c"]
|
54 |
+
|
55 |
# Copy dependency files and install dependencies
|
56 |
COPY --chown=appuser pyproject.toml dawsonia.toml uv.lock LICENSE README.md ./
|
|
|
|
|
|
|
57 |
|
58 |
+
RUN /home/appuser/.local/bin/uv sync -p 3.10 --frozen --no-cache \
|
59 |
+
&& chown -R appuser:appuser /home/appuser/app/.venv \
|
60 |
+
&& rm -rf /home/appuser/.cache
|
61 |
|
62 |
# Copy application code
|
63 |
COPY --chown=appuser app app
|
|
|
65 |
COPY --chown=appuser examples examples
|
66 |
COPY --chown=appuser output output
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
# Command to run the application
|
70 |
+
CMD ["/home/appuser/.local/bin/uv", "run", "app/main.py"]
|