-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (47 loc) · 2.48 KB
/
Dockerfile
File metadata and controls
58 lines (47 loc) · 2.48 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
# Dockerfile for running Playwright QA tests using a Debian-based Python image
# Use an official Python 3.11 Slim Debian (Bookworm) base image
FROM python:3.11-slim-bookworm
# Install base system dependencies using apt-get
# - build-essential includes gcc, g++, make etc. (like build-base on Alpine)
# - libyaml-dev for PyYAML C extensions (like yaml-dev on Alpine)
# - unzip, gnupg potentially needed by Playwright install scripts
# - curl is useful for debugging network issues
# - ca-certificates helps ensure HTTPS connections work reliably
RUN apt-get update && \
apt-get install -y --no-install-recommends \
unzip \
gnupg \
build-essential \
libyaml-dev \
curl \
ca-certificates \
# Clean apt cache to reduce image size
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements file first for better Docker layer caching
COPY requirements.txt /app/requirements.txt
# Install Python dependencies using python3's pip module
# Ensures we use the correct pip associated with python3
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel && \
python3 -m pip install --no-cache-dir -r requirements.txt
# Install Playwright browsers and their OS dependencies using the --with-deps flag
# This command works on Debian/Ubuntu too; it will use apt-get internally.
# Installing only chromium, add 'firefox' or 'webkit' if needed.
RUN python3 -m playwright install --with-deps chromium
# Copy the main application script and configuration file
# Assumes your Playwright script is named main.py
COPY main.py /app/main.py
COPY test_config.yml /app/test_config.yml
# --- Optional: Copy Report Generation Files ---
# Uncomment only if you intend to run report generation *inside* this container.
# COPY scripts/generate_html_report.py /app/scripts/generate_html_report.py
# COPY scripts/templates/report_template.html /app/scripts/templates/report_template.html
# ---------------------------------------------
# Set environment variable for Playwright browser path (standard location for root user)
ENV PLAYWRIGHT_BROWSERS_PATH=/root/.cache/ms-playwright
# Define the default command to run the test script using python3
CMD ["python3", "main.py", "--config", "test_config.yml"]
# --- Optional: Alternative CMD for In-Container Report Generation ---
# CMD ["sh", "-c", "python3 main.py --config test_config.yml && python3 scripts/generate_html_report.py"]
# ---------------------------------------------------------------------