File size: 1,484 Bytes
fa8724a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
976fbc9
fa8724a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
976fbc9
250973e
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
FROM python:3.11-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    APP_HOME=/app

# Create and set permissions for the application directory
RUN mkdir -p $APP_HOME && \
    chown -R 1000:1000 $APP_HOME

# Switch to root user for system dependencies installation
USER root

# Install system dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        build-essential \
        default-libmysqlclient-dev \
        pkg-config \
        gcc \
        git && \
    pip install --upgrade pip

# Switch to app directory
WORKDIR $APP_HOME

# Clone the application repository
RUN git clone --branch dev-t https://github.com/kadabengarann/gemini-chatbot.git $APP_HOME
RUN ls $APP_HOME

# Adjust ownership of cloned files
RUN chown -R 1000:1000 $APP_HOME

# Switch to non-root user
USER 1000:1000

# Install Python dependencies with user flag
RUN pip install --no-cache-dir --prefix=$APP_HOME/.local -r requirements.txt

# Add ~/.local/bin to the PATH
ENV PATH=$PATH:$APP_HOME/.local/bin
ENV PYTHONPATH=$PYTHONPATH:$APP_HOME/.local/lib/python3.11/site-packages

# Verify Gunicorn installation
RUN which gunicorn
RUN python -c "import gunicorn; print('Gunicorn module found!')"

# Expose the application port
EXPOSE 7860

# Pull the latest changes on container start
CMD cd $APP_HOME && git pull origin dev-t && \
    gunicorn --bind 0.0.0.0:7860 --worker-class=gevent --worker-connections=1000 --workers=3 wsgi:app