Spaces:
Running
Running
File size: 2,581 Bytes
a5b8412 abca28c 7d21c78 f415594 1d03623 fdc46e6 f415594 abca28c f415594 abca28c c49ec7e abca28c fdc46e6 abca28c 876e093 95dd3a9 58afa5f 645c1ca ee5ac17 c218394 dc0bc9b 17bb3b6 1140eec 48890c1 4a24368 5291aed 287f967 6eda99c a5b8412 abca28c a31519b 1927505 8f8eb58 d01829a 9e5bf4a a5b8412 abca28c b5d454f abca28c fdc46e6 e3708b5 b5d454f f415594 a5b8412 f415594 03b1786 fdc46e6 97e2718 | 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | # Start with a standard, lightweight Python base image
FROM python:3.10-slim
# Create non-root user with explicit UID
RUN adduser --disabled-password --gecos '' --uid 1000 appuser
# Set environment variables for Hugging Face cache
ENV HF_HOME=/data/huggingface_cache
#ENV TRANSFORMERS_CACHE=/data/huggingface_cache
#ENV TORCH_HOME=/data/huggingface_cache
# Create persistent data directories
RUN mkdir -p /data/user_models_data \
&& mkdir -p /data/huggingface_cache
# Set the working directory
WORKDIR /code
# Copy requirements first to leverage Docker cache
COPY ./requirements.txt /code/requirements.txt
# Install dependencies
RUN pip install --upgrade pip \
&& pip install --no-cache-dir --upgrade -r /code/requirements.txt \
&& pip install --upgrade resend
# Pre-download the sentence-transformers model as root
#RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
# Copy all individual files
COPY ./utils.py /code/utils.py
COPY ./main.py /code/main.py
COPY ./studio_generate.py /code/studio_generate.py
COPY ./polar_subscription.py /code/polar_subscription.py
COPY ./neura_self_hosted.py /code/neura_self_hosted.py
COPY ./model_info.py /code/model_info.py
COPY ./maintenance_control.py /code/maintenance_control.py
COPY ./usage_logger.py /code/usage_logger.py
COPY ./admin_panel.py /code/admin_panel.py
COPY ./crypto_payment.py /code/crypto_payment.py
COPY ./ai_ads.py /code/ai_ads.py
COPY ./reply_engine.py /code/reply_engine.py
COPY ./polar_subs_studio.py /code/polar_subs_studio.py
COPY ./serviceAccountKey.json /code/serviceAccountKey.json
# Copy user models data
COPY ./user_models_data /data/user_models_data
COPY ./static /data/static
COPY ./models /code/models
COPY ./agent /code/agent
COPY ./core /code/core
COPY ./services /code/services
COPY ./routers /code/routers
COPY ./models/datasets /code/models/datasets
# Set proper ownership for all directories
RUN chown -R appuser:appuser /data /code \
&& chmod -R 775 /data
# Fix cache ownership after model download
RUN chown -R appuser:appuser /data/huggingface_cache
# Volume to make learned data persistent
#VOLUME /data/user_models_data
# Switch to non-root user
USER appuser
# Expose the port used by Uvicorn
EXPOSE 7860
# Start the app
# This command activates your new AI
#uvicorn neura_self_hosted:app --reload
#CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
# Change the CMD to:
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "6000"] |