tmate / Dockerfile
xdragxt's picture
Create Dockerfile
32bb9d8 verified
raw
history blame
906 Bytes
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 (write log to user home to avoid permission issue)
RUN echo '#!/bin/bash\n' \
'# Start tmate session in background\n' \
'(tmate -F > /home/user/tmate.log 2>&1 &)\n\n' \
'# Start FastAPI app\n' \
'exec uvicorn app:app --host 0.0.0.0 --port 7860' \
> /app/start.sh && chmod +x /app/start.sh
# Switch to non-root user
USER user
# Start the bot and tmate session
CMD ["bash", "start.sh"]