Spaces:
Sleeping
Sleeping
File size: 1,509 Bytes
b9f6a03 cf65513 b9f6a03 cf65513 b9f6a03 87ac8bd b9f6a03 d3fa1fe 1f3b631 d3fa1fe b9f6a03 cf65513 87ac8bd cf65513 9445684 b9f6a03 9445684 cf65513 1f3b631 87ac8bd |
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 |
FROM python:3.11-slim
# Create user first
RUN useradd -m -u 1000 user
# Create necessary directories
RUN mkdir -p /tmp/fasttext_cache /app/logs && \
chown -R user:user /tmp/fasttext_cache /app/logs
# Install curl for healthcheck
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Create startup script
RUN echo '#!/bin/bash\n\
echo "Starting application..."\n\
echo "Checking MODEL_URL accessibility..."\n\
curl --head --silent --fail ${MODEL_URL} || (echo "ERROR: Cannot access MODEL_URL" && exit 1)\n\
echo "MODEL_URL is accessible"\n\
echo "Starting uvicorn server..."\n\
exec uvicorn main:app --host 0.0.0.0 --port 7860 --log-level info' > /app/start.sh && \
chmod +x /app/start.sh && \
chown user:user /app/start.sh
# Switch to user after setting up permissions
USER user
ENV PATH="/home/user/.local/bin:$PATH"
ENV MODEL_URL="https://huggingface.co/Miroir/cc.fr.300.reduced/resolve/main/cc.fr.300.reduced.vec"
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY --chown=user requirements.txt requirements.txt
# Install dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir --upgrade -r requirements.txt
COPY --chown=user . .
# Create data directory for game state
RUN mkdir -p /app/data && chown user:user /app/data
# Add healthcheck
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
CMD ["/app/start.sh"] |