Spaces:
Sleeping
Sleeping
File size: 1,019 Bytes
0598ebe 19868d6 0598ebe a30fdbb 19868d6 0598ebe 4c53429 19868d6 02bde37 19868d6 31313bf 19868d6 3dcf1d1 0598ebe 3dcf1d1 3f76caf 3dcf1d1 19868d6 3f76caf 31313bf 19868d6 4c53429 0598ebe 4c53429 3f76caf bd87b84 19868d6 |
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 38 39 40 41 42 |
FROM python:3.9
# Switch to root for system installations
USER root
# Install dependencies
RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -u 1000 user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PORT=7860
# Clone repository into a temporary subdirectory
RUN --mount=type=secret,id=Access_key,mode=0444,required=true \
git clone $(cat /run/secrets/Access_key) $HOME/app/gitfolder
# Copy files from gitfolder to app and ensure correct permissions
RUN mkdir -p $HOME/app/uploads $HOME/app/temp && \
cp -r $HOME/app/gitfolder/* $HOME/app/ && \
rm -rf $HOME/app/gitfolder && \
chown -R user:user $HOME/app
# Set working directory
WORKDIR $HOME/app
# Switch to non-root user
USER user
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Expose port 7860
EXPOSE 7860
# Start the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|