chat-7 / Dockerfile
rishi1985's picture
Update Dockerfile
7dcbf63
raw
history blame
4.41 kB
# Use the official Python 3.9 image as the base image
FROM python:3.11
# Expose the port
EXPOSE 7860
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Set the PYNGROK_CONFIG environment variable
ENV PYNGROK_CONFIG /tmp/pyngrok.yml
# Set the NGROK_PATH environment variable to a writable location
ENV NGROK_PATH /tmp/ngrok
# Copy requirements.txt into the container
COPY requirements.txt .
# RUN apt-get update
# RUN apt-get install -y wget
# RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# RUN apt-get install ./google-chrome-stable_current_amd64.deb -y
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get -y update
RUN apt-get install -y google-chrome-stable
# install chromedriver
RUN apt-get install -yqq unzip
RUN wget -O /tmp/chromedriver-linux64.zip https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.105/linux64/chromedriver-linux64.zip
RUN unzip /tmp/chromedriver-linux64.zip chromedriver-linux64/chromedriver -d /usr/local/bin/
RUN apt install wget -y
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-linux64.tar.gz
RUN tar -xzvf geckodriver-v0.32.0-linux64.tar.gz -C /usr/local/bin
RUN chmod +x /usr/local/bin/geckodriver
RUN geckodriver -V
# RUN add-apt-repository p?pa:mozillateam/ppa -y
RUN apt install firefox-esr -y
RUN which firefox-esr
# RUN apt-get install firefox-geckodriver
# Upgrade pip and install the required packages
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# Install sudo and create the necessary directories before copying the files
RUN apt-get update && \
apt-get install -y sudo && \
mkdir -p /code/image
RUN apt-get install -y socat
# RUN socat TCP-LISTEN:8888,fork PROXY:your-auth-proxy-server:proxy-port,proxyauth=user:pa
# RUN socat TCP-LISTEN:8888,fork PROXY:http://p.webshare.io:80,proxyauth=hnbynugo-rotate:2491y5ds75e7 &
RUN nohup socat TCP-LISTEN:8888,fork PROXY:http://p.webshare.io:80,proxyauth=hnbynugo-rotate:2491y5ds75e7 > socat.log 2>&1 &
# RUN socat TCP-LISTEN:8888,fork PROXY:http://p.webshare.io:80,proxyauth=hnbynugo-rotate:2491y5ds75e7
# Creates a non-root user with an explicit UID and adds permission to access the /code folder
RUN adduser -u 5678 --disabled-password --gecos "" appuser && \
usermod -aG sudo appuser && \
usermod -aG root appuser && \
chown -R appuser:appuser /code
# Create the pyngrok bin directory and set the ownership and permissions for appuser
RUN mkdir -p /usr/local/lib/python3.9/site-packages/pyngrok/bin && \
chown -R appuser:appuser /usr/local/lib/python3.9/site-packages/pyngrok/bin && \
chmod -R 777 /usr/local/lib/python3.9/site-packages/pyngrok/bin
RUN mkdir -p /.ngrok2 && \
chown -R appuser:appuser /.ngrok2 && \
chmod -R 777 /.ngrok2
RUN mkdir /.local
RUN chmod -R 777 /.local
RUN apt-get update && \
apt-get install -y curl
RUN echo "deb http://deb.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list.d/debian.list
# RUN apt install firefox-esr && \
# apt install geckodriver
# Set the working directory and copy the files
WORKDIR /code
# Set the ownership and permissions for the /code directory and its contents
RUN chown -R appuser:appuser /code && \
chmod -R 777 /code
COPY . /code
# RUN chown -R appuser:appuser /code/data.csv && \
# chmod -R 777 /code/data.csv
# Copy the pyngrok.yml configuration file
COPY pyngrok.yml /tmp/pyngrok.yml
# Set the TRANSFORMERS_CACHE environment variable to a cache directory inside /tmp
ENV TRANSFORMERS_CACHE /tmp/transformers_cache
ENV TORCH_HOME /tmp/torch_cache
# USER appuser
# Start the application using pyngrok
# CMD python main.py
# Get the public IP address and display it
RUN curl -s https://api.ipify.org | xargs echo "Public IP:"
RUN pip install gunicorn
# Start the Uvicorn server
# ENTRYPOINT ["python", "main.py"]
# CMD ["sh", "-c", "python main.py & sleep infinity"]
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860","--workers","2"]
# CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]