replace puppeteer with playwright
Build and Push Docker Images / build-and-push (push) Has been cancelled
Build and Push Docker Images / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
FROM python:3.9-slim
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Install required system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
@@ -6,11 +6,6 @@ RUN apt-get update && apt-get install -y \
|
||||
gnupg2 \
|
||||
procps \
|
||||
sqlite3 \
|
||||
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome-keyring.gpg \
|
||||
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google-chrome.list \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y \
|
||||
google-chrome-stable \
|
||||
fonts-ipafont-gothic \
|
||||
fonts-wqy-zenhei \
|
||||
fonts-thai-tlwg \
|
||||
@@ -19,9 +14,7 @@ RUN apt-get update && apt-get install -y \
|
||||
libxss1 \
|
||||
xvfb \
|
||||
--no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
# Verify Chrome installation
|
||||
&& google-chrome --version
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
@@ -30,6 +23,23 @@ WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Install Playwright system dependencies as root
|
||||
RUN playwright install-deps chromium
|
||||
|
||||
# Create a non-root user
|
||||
RUN useradd -m playwright
|
||||
|
||||
# Set HOME for playwright user and ensure cache directory exists
|
||||
ENV HOME=/home/playwright
|
||||
RUN mkdir -p /home/playwright/.cache/ms-playwright && chown -R playwright:playwright /home/playwright
|
||||
|
||||
# Install Playwright browsers as the playwright user
|
||||
USER playwright
|
||||
RUN playwright install chromium
|
||||
|
||||
# Switch back to root for file operations
|
||||
USER root
|
||||
|
||||
# Copy the rest of the application
|
||||
COPY . .
|
||||
|
||||
@@ -39,17 +49,19 @@ ENV API_KEY=""
|
||||
ENV CACHE_EXPIRY_HOURS=36
|
||||
ENV CLEANUP_CRON="0 3 * * *"
|
||||
|
||||
# Create a non-root user and switch to it
|
||||
RUN useradd -m puppeteer && chown -R puppeteer:puppeteer /app
|
||||
# Set ownership of the application to playwright user
|
||||
RUN chown -R playwright:playwright /app
|
||||
|
||||
# Create the database directory and set permissions
|
||||
RUN mkdir -p /db && chmod 777 /db && chown -R puppeteer:puppeteer /app
|
||||
RUN mkdir -p /db && chmod 777 /db && chown -R playwright:playwright /app
|
||||
|
||||
# Add system limits configuration
|
||||
RUN echo "* soft nofile 65535" >> /etc/security/limits.conf && \
|
||||
echo "* hard nofile 65535" >> /etc/security/limits.conf && \
|
||||
echo "session required pam_limits.so" >> /etc/pam.d/common-session
|
||||
|
||||
USER puppeteer
|
||||
# Switch to playwright user for running the application
|
||||
USER playwright
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8000
|
||||
|
||||
Reference in New Issue
Block a user