WebProxy / Dockerfile
nprime's picture
Update Dockerfile
2f47d69 verified
# Use the same Python base image
FROM python:3.9
# Switch to root user temporarily to install system packages
USER root
# Install system dependencies:
# - chromium-browser: The browser Selenium will control
# - chromium-chromedriver: The driver executable Selenium uses to talk to Chrome
# - Recommended: Clean up apt cache afterwards to keep image size down
RUN apt-get update && apt-get install -y \
chromium \
chromium-driver \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# --- Back to your original Dockerfile structure ---
# Create a non-root user for security
RUN useradd -m -u 1000 user
# Switch to the non-root user
USER user
# Add user's local bin to PATH (good practice, esp. if pip installs executables)
ENV PATH="/home/user/.local/bin:$PATH"
# Set the working directory
WORKDIR /app
# Clone the repo to current directory
RUN git clone https://github.com/nishantprime/WebProxy.git .
# Copy the rest of the application code from the host to the container
COPY --chown=user . /app
# Install Python dependencies listed in requirements.txt
# Use --user flag as we are running as non-root user
# Make sure requirements.txt now includes: flask, requests, beautifulsoup4, selenium, gunicorn
RUN pip install --no-cache-dir --user --upgrade -r requirements.txt
# Copy the rest of your application code (including your modified app.py)
# This replaces the git clone step, assuming your local code is what you want to deploy.
COPY --chown=user . /app
# Specify the command to run the application with Gunicorn
# Ensure app.py is the file containing your Flask app instance named 'app'
CMD ["gunicorn", "app:app", "-b", "0.0.0.0:7860"]