Spaces:
Sleeping
Sleeping
File size: 845 Bytes
8603dd8 cf8b861 8603dd8 cf8b861 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# Use a slim Python runtime as a parent image
FROM python:3.12-slim
# Set environment variables for Python
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Create and switch to a non-root user for security
RUN useradd -m -u 1000 user
USER user
# Set the working directory
WORKDIR /home/user/app
ENV PATH="/home/user/.local/bin:${PATH}"
# Copy and install dependencies
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the application code
COPY --chown=user . .
# Copy and set permissions for entrypoint script
COPY --chown=user entrypoint.sh .
RUN chmod +x entrypoint.sh
# Run collectstatic to gather all static files
RUN python manage.py collectstatic --no-input
# Expose the port the app runs on
EXPOSE 7860
# Run the entrypoint script
CMD ["/home/user/app/entrypoint.sh"]
|