Spaces:
Paused
Paused
| FROM python:3.9-slim | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| HOME=/home/appuser \ | |
| APP_HOME=/app \ | |
| TZ=Asia/Shanghai \ | |
| GIT_Branch=master | |
| # Create non-root user with UID 1000 | |
| RUN groupadd -r -g 1000 appuser && useradd -r -u 1000 -g appuser -m -d /home/appuser appuser | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| curl \ | |
| git \ | |
| iproute2 \ | |
| tzdata \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set timezone | |
| RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ | |
| echo Asia/Shanghai > /etc/timezone | |
| # Create app directory and set permissions | |
| RUN mkdir -p /app && \ | |
| chown -R appuser:appuser /app && \ | |
| chmod 755 /app | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy and set up entrypoint script | |
| COPY docker/docker-entrypoint-huggingface.sh /docker-entrypoint-huggingface.sh | |
| RUN chmod +x /docker-entrypoint-huggingface.sh && \ | |
| chown appuser:appuser /docker-entrypoint-huggingface.sh | |
| # Clone repositories | |
| RUN git clone -b master --single-branch --depth=1 https://github.com/AirportR/FullTclash.git . && \ | |
| mkdir -p resources/emoji && \ | |
| chown -R appuser:appuser resources && \ | |
| git clone --single-branch --depth=1 https://github.com/twitter/twemoji.git resources/emoji/twemoji | |
| # Create necessary directories and set permissions | |
| RUN mkdir -p /app/logs /app/data /app/models && \ | |
| chmod -R 755 /app && \ | |
| chmod 777 /app/logs /app/data /app/models && \ | |
| chown -R appuser:appuser /app/* && \ | |
| chown appuser:appuser /app | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy config files | |
| # COPY --chown=appuser:appuser resources/config.yaml /app/resources/config.yaml | |
| # Switch to non-root user | |
| USER appuser | |
| # Set Python path | |
| ENV PYTHONPATH=${APP_HOME} | |
| # Expose port if needed | |
| EXPOSE 7860 | |
| # Set the entrypoint | |
| ENTRYPOINT ["/docker-entrypoint-huggingface.sh"] | |
| # CMD ["python", "main.py"] | |