File size: 1,672 Bytes
9117cb6
e9b3258
 
9117cb6
 
 
 
 
 
 
 
2f47d69
 
9117cb6
 
 
 
 
 
e9b3258
9117cb6
e9b3258
9117cb6
e9b3258
 
9117cb6
e9b3258
 
 
 
9117cb6
 
 
e9b3258
9117cb6
 
 
e9b3258
9117cb6
 
e9b3258
 
 
9117cb6
e9b3258
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
# 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"]