File size: 996 Bytes
32bb9d8 95c40e2 edf25b0 95c40e2 edf25b0 95c40e2 edf25b0 95c40e2 edf25b0 95c40e2 edf25b0 95c40e2 edf25b0 95c40e2 edf25b0 32bb9d8 edf25b0 |
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 43 44 45 46 47 48 |
FROM python:3.10
# Create a non-root user
RUN useradd -m -u 1000 user
ENV PATH="/home/user/.local/bin:$PATH"
# Set working directory
WORKDIR /app
# Install dependencies
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Install tmate and required tools
RUN apt-get update && apt-get install -y curl git tmate && apt-get clean
# Copy app code
COPY . /app
# Set permissions for non-root user
RUN chown -R user:user /app
# Create startup script using proper heredoc
RUN bash -c 'cat <<EOF > /app/start.sh
#!/bin/bash
# Start tmate in background and log output
tmate -F > /tmp/tmate.log 2>&1 &
# Wait for tmate to start
sleep 2
# Show SSH/Web link in logs
grep -E "ssh|web|https" /tmp/tmate.log || tail -n 20 /tmp/tmate.log
# Run FastAPI
exec uvicorn main:app --host 0.0.0.0 --port 7860
EOF'
# Make script executable
RUN chmod +x /app/start.sh
# Switch to non-root user
USER user
# Run the startup script
CMD ["bash", "/app/start.sh"]
|