Spaces:
Paused
Paused
File size: 935 Bytes
2389d11 f0c7ec8 |
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 36 37 |
FROM python:3.11
ENV USERNAME=admin
# Create and use a non-root user
RUN useradd -ms /bin/bash $USERNAME
# Set working directory for the application
WORKDIR /app
# Install system dependencies and clean up in a single RUN step to reduce layers
RUN apt-get update -y && apt-get upgrade -y \
&& apt-get install -y git-all \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV HOME=/home/$USERNAME
RUN mkdir $HOME/.cache $HOME/.config \
&& chmod -R 777 $HOME
ENV PATH=$HOME/.local/bin:$PATH
COPY init.sh /app/init.sh
RUN chmod +x /app/init.sh
RUN /app/init.sh
# Set ownership and permissions for the app directory
RUN chown -R admin:admin /app && chmod -R 777 /app
# Switch to the non-root user for better security
USER admin
# Expose the port the application will run on
EXPOSE 7860
# Use init.sh as the entrypoint so it runs on container start
ENTRYPOINT ["/app/init.sh"]
CMD ["python", "-u", "-m", "FileServer"] |