CoolFace
Apppublic

prlabs2023/ping-master-salve

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
Dockerfile83 linesDownload Raw Back to root
1# Use the official Python 3.9 image as the base image2FROM python:3.93 4# Expose the port5EXPOSE 78606 7# Keeps Python from generating .pyc files in the container8ENV PYTHONDONTWRITEBYTECODE=19 10# Turns off buffering for easier container logging11ENV PYTHONUNBUFFERED=112 13# Set the PYNGROK_CONFIG environment variable14ENV PYNGROK_CONFIG /tmp/pyngrok.yml15 16# Set the NGROK_PATH environment variable to a writable location17ENV NGROK_PATH /tmp/ngrok18 19# Copy requirements.txt into the container20COPY requirements.txt .21 22# Upgrade pip and install the required packages23RUN pip install --upgrade pip && \24    pip install -r requirements.txt25 26# Install sudo and create the necessary directories before copying the files27RUN apt-get update && \28    apt-get install -y sudo && \29    mkdir -p /code/image30 31# Creates a non-root user with an explicit UID and adds permission to access the /code folder32RUN adduser -u 5678 --disabled-password --gecos "" appuser && \33    usermod -aG sudo appuser && \34    usermod -aG root appuser && \35    chown -R appuser:appuser /code36 37# Create the pyngrok bin directory and set the ownership and permissions for appuser38RUN mkdir -p /usr/local/lib/python3.9/site-packages/pyngrok/bin && \39    chown -R appuser:appuser /usr/local/lib/python3.9/site-packages/pyngrok/bin && \40    chmod -R 777 /usr/local/lib/python3.9/site-packages/pyngrok/bin41 42RUN mkdir -p /.ngrok2 && \43    chown -R appuser:appuser /.ngrok2 && \44    chmod -R 777 /.ngrok245 46RUN apt-get update && \47    apt-get install -y curl48 49# Set the working directory and copy the files50WORKDIR /code51 52# Set the ownership and permissions for the /code directory and its contents53RUN chown -R appuser:appuser /code && \54    chmod -R 777 /code55 56COPY . /code57 58# RUN chown -R appuser:appuser /code/data.csv && \59#     chmod -R 777 /code/data.csv60 61# Copy the pyngrok.yml configuration file62COPY pyngrok.yml /tmp/pyngrok.yml63 64# Set the TRANSFORMERS_CACHE environment variable to a cache directory inside /tmp65ENV TRANSFORMERS_CACHE /tmp/transformers_cache66ENV TORCH_HOME /tmp/torch_cache67 68USER appuser69 70# Start the application using pyngrok71# CMD python main.py72# Get the public IP address and display it73RUN curl -s https://api.ipify.org | xargs echo "Public IP:"74# RUN pip install gunicorn75 76 77# RUN --mount=type=secret,id=key,mode=0444,required=true \78#    cat /run/secrets/key > /test79 80# Start the Uvicorn server81# ENTRYPOINT ["python", "main.py"]82# CMD ["sh", "-c", "python main.py & sleep infinity"]83CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]