|
FROM python:3.10 |
|
|
|
|
|
RUN useradd -m -u 1000 user |
|
ENV PATH="/home/user/.local/bin:$PATH" |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
COPY requirements.txt requirements.txt |
|
RUN pip install --no-cache-dir --upgrade -r requirements.txt |
|
|
|
|
|
RUN apt-get update && apt-get install -y curl git tmate && apt-get clean |
|
|
|
|
|
COPY . /app |
|
|
|
|
|
RUN chown -R user:user /app |
|
|
|
|
|
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' |
|
|
|
|
|
RUN chmod +x /app/start.sh |
|
|
|
|
|
USER user |
|
|
|
|
|
CMD ["bash", "/app/start.sh"] |
|
|