Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +12 -19
Dockerfile
CHANGED
|
@@ -1,40 +1,33 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
|
| 3 |
-
FROM python:3.9-slim-bullseye
|
| 4 |
|
| 5 |
-
# Set environment variables
|
| 6 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 7 |
PYTHONUNBUFFERED=1
|
| 8 |
|
| 9 |
# Set working directory
|
| 10 |
WORKDIR /code
|
| 11 |
|
| 12 |
-
# Install
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
ca-certificates \
|
| 17 |
-
netbase \
|
| 18 |
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
-
# Create
|
| 21 |
RUN useradd -m -u 1000 user
|
| 22 |
|
| 23 |
-
# Copy
|
| 24 |
COPY ./requirements.txt /code/requirements.txt
|
| 25 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 26 |
|
| 27 |
-
# Copy
|
| 28 |
-
# This is critical: standard COPY makes files owned by root, which can cause permission errors
|
| 29 |
COPY --chown=user . /code
|
| 30 |
|
| 31 |
-
# Switch
|
| 32 |
USER user
|
| 33 |
-
|
| 34 |
-
# Set home environment
|
| 35 |
ENV HOME=/home/user \
|
| 36 |
PATH=/home/user/.local/bin:$PATH
|
| 37 |
|
| 38 |
-
# Run
|
| 39 |
-
# Using 0.0.0.0 is required for Docker networking
|
| 40 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use full Python 3.10 (Debian based, includes all standard libs)
|
| 2 |
+
FROM python:3.10
|
|
|
|
| 3 |
|
| 4 |
+
# Set environment variables
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
PYTHONUNBUFFERED=1
|
| 7 |
|
| 8 |
# Set working directory
|
| 9 |
WORKDIR /code
|
| 10 |
|
| 11 |
+
# Install specific networking tools for debugging (optional but helpful)
|
| 12 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 13 |
+
dnsutils \
|
| 14 |
+
iputils-ping \
|
|
|
|
|
|
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
+
# Create user
|
| 18 |
RUN useradd -m -u 1000 user
|
| 19 |
|
| 20 |
+
# Copy and install requirements
|
| 21 |
COPY ./requirements.txt /code/requirements.txt
|
| 22 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 23 |
|
| 24 |
+
# Copy application files with ownership
|
|
|
|
| 25 |
COPY --chown=user . /code
|
| 26 |
|
| 27 |
+
# Switch user
|
| 28 |
USER user
|
|
|
|
|
|
|
| 29 |
ENV HOME=/home/user \
|
| 30 |
PATH=/home/user/.local/bin:$PATH
|
| 31 |
|
| 32 |
+
# Run app
|
|
|
|
| 33 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|