Skip to content

Commit 8cebfb8

Browse files
committed
restored README and moved to docker.md
1 parent 05bcf0e commit 8cebfb8

File tree

4 files changed

+68
-66
lines changed

4 files changed

+68
-66
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ docs
99
test
1010

1111
# unused script and files
12+
README.md
1213
alive.bat
1314
browsers.ini.sample
1415
centos_install.sh

Dockerfile

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ FROM ubuntu:22.04 as production
1818
ARG TIMEZONE=UTC
1919

2020
### UPDATE ###
21-
RUN apt update
22-
23-
### COPYING ENTIRE DIR TO LOCAL DOCKER /wptagent ###
24-
# see .dockerignore for filterd out folders
25-
COPY / /wptagent
26-
2721
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
28-
29-
### UPDATE ###
3022
RUN apt update
3123

3224
### INSTALL APT-GET LIBS ###
@@ -39,33 +31,40 @@ RUN ln -fs /usr/share/zoneinfo/$TIMEZONE /etc/localtime && DEBIAN_FRONTEND=nonin
3931
python3-dev libavutil-dev libmp3lame-dev libx264-dev yasm autoconf automake build-essential libass-dev libfreetype6-dev libtheora-dev \
4032
libtool libvorbis-dev pkg-config texi2html libtext-unidecode-perl python3-numpy python3-scipy perl \
4133
adb ethtool nodejs cmake git-core libsdl2-dev libva-dev libvdpau-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev texinfo wget \
42-
ttf-mscorefonts-installer fonts-noto fonts-roboto fonts-open-sans ffmpeg npm sudo curl
34+
ttf-mscorefonts-installer fonts-noto fonts-roboto fonts-open-sans ffmpeg npm sudo curl xvfb
4335

4436
### UPDATE FONT CACHE ###
4537
RUN fc-cache -f -v
4638

47-
### UPGRADING PIP AND INSTALLING REQUIRED PACKAGES ###
48-
RUN python3 -m pip install --upgrade --user pip && \
49-
python3 -m pip install --user -r /wptagent/.github/workflows/requirements.txt
50-
5139
### INSTALLING LIGHTHOUSE FROM NPM ###
5240
RUN npm install -g lighthouse
5341

5442
### INSTALLING CHROME BROWSER ###
55-
RUN curl -o google-chrome-stable_current_amd64.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
56-
apt install -y /google-chrome-stable_current_amd64.deb && rm /google-chrome-stable_current_amd64.deb
43+
RUN curl -o /tmp/google-chrome-stable_current_amd64.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
44+
apt install -y /tmp/google-chrome-stable_current_amd64.deb && rm /tmp/google-chrome-stable_current_amd64.deb
45+
46+
### UPGRADING PIP AND INSTALLING REQUIRED PACKAGES ###
47+
COPY /.github/workflows/requirements.txt /tmp/agent_requirements.txt
48+
RUN python3 -m pip install --upgrade --user pip && \
49+
python3 -m pip install --user -r /tmp/agent_requirements.txt && \
50+
rm /tmp/agent_requirements.txt
5751

52+
### COPYING ENTIRE DIR TO LOCAL DOCKER /wptagent ###
53+
# see .dockerignore for filterd out folders
54+
# source copy last so we don't need to rebuild all the other layers
55+
COPY / /wptagent
5856
WORKDIR /wptagent
5957

6058
ENTRYPOINT ["/bin/sh", "/wptagent/docker/linux-headless/entrypoint.sh"]
6159

6260
### DEBUG CONTAINER ###
6361
FROM production as debug
6462

63+
### INSTALLING DEBUG DEPENDENCIES ###
6564
RUN pip install debugpy
6665

66+
### COPY DEBUG AGENT AND MOVE REAL ONE ###
6767
RUN mv wptagent.py wptagent_starter.py
68-
6968
COPY wptagent_debug.py wptagent.py
7069

7170
### SETTING PRODUCTION BUILD AS DEFAULT ###

README.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -141,37 +141,6 @@ The test result is written as JSON to `stdout`. If a server, location, and key a
141141
- `--testruns`: Number of runs to test. Defaults to 1.
142142
- `--testrv`: Include repeat view (defaults to only testing first view)
143143

144-
### Running the container
145-
146-
The `Dokerfile`` has multi-stage definition:
147-
* **production**: Default stage, produce a image without debug features;
148-
* **debug**: When running the produced image the wptagent script will wait for a debug to.attach
149-
150-
arguments can be passed at build time:
151-
* **TIMEZONE**: to set the timezone inside the container
152-
* **
153-
154-
To build the production container
155-
```sh
156-
docker build --tag wptagent .
157-
```
158-
To build the debug container
159-
```sh
160-
docker build --target debug --tag wptagent-debug .
161-
```
162-
163-
The entrypoint is `docker\linux-headless\entrypoint.sh` that has some of the above parameters as default: `--xvfb`, `--dockerized`, `-vvvv`.
164-
Mandatory parameters are required via environment variables:
165-
* **SERVER_URL**: corresponding to `--server` parameter;
166-
* **LOCATION**: corresponding to `--location` parameter.
167-
168-
Additional parameters can be passed. A typical run in debug mode looks like this
169-
170-
```sh
171-
docker run --network="host" -e SERVER_URL=http://127.0.0.1:80/work/ -e LOCATION=Test wptagent-debug --key 123456789
172-
```
173-
174-
where `-vvvv` and `--key` are optional parameters passed to the wptagent script.
175144
## Supported features
176145

177146
The following [Script Commands](https://docs.webpagetest.org/scripting/) are supported on Windows, Linux, Mac, and Android:

docs/docker.md

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,78 @@
1-
# Linux Headless Agent
1+
# Docker Linux Headless Agent
22

3-
To run the agent, simply specify a few environment variables with docker:
3+
The `Dokerfile` has multi-stage definition:
4+
* **production**: Default stage, produce a image without debug features;
5+
* **debug**: When running the produced image the wptagent script will wait for a debug to.attach
6+
7+
## Build the Image
48

5-
* `SERVER_URL`: will be passed as `--server` (note: it must end with '/work/')
6-
* `LOCATION`: will be passed as `--location`
7-
* `KEY`: will be passed as `--key`
8-
* `NAME`: will be passed as `--name` (optional)
9-
* `SHAPER`: will be passed as `--shaper` (optional)
10-
* `EXTRA_ARGS`: extra command-line options that will be passed through verbatim (optional)
9+
Arguments can be passed at build time:
10+
* **TIMEZONE**: to set the timezone inside the container
1111

12+
To build the production container
13+
```bash
14+
docker build --tag wptagent .
15+
```
16+
To build the debug container
17+
```bash
18+
docker build --target debug --tag wptagent-debug .
19+
```
1220
## Prerequisites to use traffic shaping in docker
1321
**Experimental**: Running the agent with traffic shaping is experimental. It might
1422
have influence on the host system network. Running multiple agents on the
1523
same host might result in incorrect traffic shaping.
1624

1725
For traffic shaping to work correctly, you need to load the ifb module on the **host**:
18-
26+
```bash
1927
sudo modprobe ifb numifbs=1
28+
```
2029

2130
Also, the container needs `NET_ADMIN` capabilities, so run the container with
2231
`--cap-add=NET_ADMIN`.
2332

24-
To disable traffic-shaping, pass SHAPER="none".
33+
To disable traffic-shaping, pass environment variable at docker un `SHAPER="none"`.
2534

26-
## Container Disk Space Fills Up Quickly
27-
28-
If you see disk space within the container filling up rapidly and you notice
29-
core dump files in the /wptagent folder, try adding `--shm-size=1g` to your Docker run
30-
command. This can help resolve an issue with shared memory and headless Chrome in Docker.
35+
## Run the container
36+
To run the agent, simply specify a few environment variables with docker:
3137

32-
## Example
38+
- `SERVER_URL`: will be passed as `--server` (note: it must end with '/work/')
39+
- `LOCATION`: will be passed as `--location`
40+
- `KEY`: will be passed as `--key`
41+
- `NAME`: will be passed as `--name` (optional)
42+
- `SHAPER`: will be passed as `--shaper` (optional)
43+
- `EXTRA_ARGS`: extra command-line options that will be passed through verbatim (optional)
3344

34-
Build the image first (from project root), load ifb and start it the container:
45+
Build the image first (from project root), load ifb and start it the container.
3546

36-
sudo docker build --tag wptagent .
47+
A typical run :
48+
```bash
3749
sudo modprobe ifb numifbs=1
38-
sudo docker run -d \
50+
docker build --tag wptagent .
51+
docker run -d \
3952
-e SERVER_URL="http://my-wpt-server.org/work/" \
4053
-e LOCATION="docker-location" \
4154
-e NAME="Docker Test" \
4255
--cap-add=NET_ADMIN \
4356
--init \
4457
wptagent
58+
```
59+
60+
Additional parameters can be also passed as additional commands.
61+
A typical run in debug mode, note that we need to expose the port as `50000`:
62+
```bash
63+
sudo modprobe ifb numifbs=1
64+
docker run -d \
65+
-e SERVER_URL=http://127.0.0.1:80/work/ \
66+
-e LOCATION=Test \
67+
--init \
68+
--cap-add=NET_ADMIN \
69+
-p 50000:50000 \
70+
wptagent-debug
71+
--key 123456789
72+
```
73+
74+
## Container Disk Space Fills Up Quickly
4575

76+
If you see disk space within the container filling up rapidly and you notice
77+
core dump files in the /wptagent folder, try adding `--shm-size=1g` to your Docker run
78+
command. This can help resolve an issue with shared memory and headless Chrome in Docker.

0 commit comments

Comments
 (0)