Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +19 -10
Dockerfile
CHANGED
|
@@ -4,25 +4,34 @@ FROM python:3.10.9
|
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
-
#
|
|
|
|
|
|
|
|
|
|
| 10 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 11 |
|
| 12 |
# Create a non-root user
|
| 13 |
RUN useradd -m appuser
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
RUN
|
| 17 |
-
chown -R appuser:appuser /app /tmp/app-work && \
|
| 18 |
chmod -R 755 /app && \
|
| 19 |
-
chmod -R 777 /
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
# Switch to
|
| 22 |
USER appuser
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
|
| 27 |
-
#
|
| 28 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Create necessary directories
|
| 8 |
+
RUN mkdir -p /app/sites /app/temp
|
| 9 |
|
| 10 |
+
# Copy requirements first for better caching
|
| 11 |
+
COPY requirements.txt /app/
|
| 12 |
+
|
| 13 |
+
# Requirements for the static site server
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
# Create a non-root user
|
| 17 |
RUN useradd -m appuser
|
| 18 |
|
| 19 |
+
# Set up proper permissions
|
| 20 |
+
RUN chown -R appuser:appuser /app && \
|
|
|
|
| 21 |
chmod -R 755 /app && \
|
| 22 |
+
chmod -R 777 /app/sites /app/temp
|
| 23 |
+
|
| 24 |
+
# Copy the application code
|
| 25 |
+
COPY . /app/
|
| 26 |
+
|
| 27 |
+
# Set proper ownership for copied files
|
| 28 |
+
RUN chown -R appuser:appuser /app
|
| 29 |
|
| 30 |
+
# Switch to non-root user
|
| 31 |
USER appuser
|
| 32 |
|
| 33 |
+
# Expose the port
|
| 34 |
+
EXPOSE 7860
|
| 35 |
|
| 36 |
+
# Command to run the application
|
| 37 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|