Update Dockerfile
Browse files- Dockerfile +29 -4
Dockerfile
CHANGED
|
@@ -1,20 +1,45 @@
|
|
|
|
|
| 1 |
FROM python:3.9
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
RUN useradd -m -u 1000 user
|
|
|
|
| 4 |
USER user
|
|
|
|
| 5 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 6 |
|
| 7 |
-
# Set the working directory
|
| 8 |
WORKDIR /app
|
| 9 |
-
|
| 10 |
# Clone the repo to current directory
|
| 11 |
RUN git clone https://github.com/nishantprime/WebProxy.git .
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
# Install Python dependencies listed in requirements.txt
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
# Copy the rest of
|
|
|
|
| 17 |
COPY --chown=user . /app
|
| 18 |
|
| 19 |
# Specify the command to run the application with Gunicorn
|
|
|
|
| 20 |
CMD ["gunicorn", "app:app", "-b", "0.0.0.0:7860"]
|
|
|
|
| 1 |
+
# Use the same Python base image
|
| 2 |
FROM python:3.9
|
| 3 |
|
| 4 |
+
# Switch to root user temporarily to install system packages
|
| 5 |
+
USER root
|
| 6 |
+
|
| 7 |
+
# Install system dependencies:
|
| 8 |
+
# - chromium-browser: The browser Selenium will control
|
| 9 |
+
# - chromium-chromedriver: The driver executable Selenium uses to talk to Chrome
|
| 10 |
+
# - Recommended: Clean up apt cache afterwards to keep image size down
|
| 11 |
+
RUN apt-get update && apt-get install -y \
|
| 12 |
+
chromium-browser \
|
| 13 |
+
chromium-chromedriver \
|
| 14 |
+
--no-install-recommends \
|
| 15 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
+
|
| 17 |
+
# --- Back to your original Dockerfile structure ---
|
| 18 |
+
|
| 19 |
+
# Create a non-root user for security
|
| 20 |
RUN useradd -m -u 1000 user
|
| 21 |
+
# Switch to the non-root user
|
| 22 |
USER user
|
| 23 |
+
# Add user's local bin to PATH (good practice, esp. if pip installs executables)
|
| 24 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 25 |
|
| 26 |
+
# Set the working directory
|
| 27 |
WORKDIR /app
|
|
|
|
| 28 |
# Clone the repo to current directory
|
| 29 |
RUN git clone https://github.com/nishantprime/WebProxy.git .
|
| 30 |
|
| 31 |
+
# Copy the rest of the application code from the host to the container
|
| 32 |
+
COPY --chown=user . /app
|
| 33 |
+
|
| 34 |
# Install Python dependencies listed in requirements.txt
|
| 35 |
+
# Use --user flag as we are running as non-root user
|
| 36 |
+
# Make sure requirements.txt now includes: flask, requests, beautifulsoup4, selenium, gunicorn
|
| 37 |
+
RUN pip install --no-cache-dir --user --upgrade -r requirements.txt
|
| 38 |
|
| 39 |
+
# Copy the rest of your application code (including your modified app.py)
|
| 40 |
+
# This replaces the git clone step, assuming your local code is what you want to deploy.
|
| 41 |
COPY --chown=user . /app
|
| 42 |
|
| 43 |
# Specify the command to run the application with Gunicorn
|
| 44 |
+
# Ensure app.py is the file containing your Flask app instance named 'app'
|
| 45 |
CMD ["gunicorn", "app:app", "-b", "0.0.0.0:7860"]
|