|
1 | | -# Linux Headless Agent |
| 1 | +# Docker Linux Headless Agent |
2 | 2 |
|
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 |
4 | 8 |
|
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 |
11 | 11 |
|
| 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 | +``` |
12 | 20 | ## Prerequisites to use traffic shaping in docker |
13 | 21 | **Experimental**: Running the agent with traffic shaping is experimental. It might |
14 | 22 | have influence on the host system network. Running multiple agents on the |
15 | 23 | same host might result in incorrect traffic shaping. |
16 | 24 |
|
17 | 25 | For traffic shaping to work correctly, you need to load the ifb module on the **host**: |
18 | | - |
| 26 | +```bash |
19 | 27 | sudo modprobe ifb numifbs=1 |
| 28 | +``` |
20 | 29 |
|
21 | 30 | Also, the container needs `NET_ADMIN` capabilities, so run the container with |
22 | 31 | `--cap-add=NET_ADMIN`. |
23 | 32 |
|
24 | | -To disable traffic-shaping, pass SHAPER="none". |
| 33 | +To disable traffic-shaping, pass environment variable at docker un `SHAPER="none"`. |
25 | 34 |
|
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: |
31 | 37 |
|
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) |
33 | 44 |
|
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. |
35 | 46 |
|
36 | | - sudo docker build --tag wptagent . |
| 47 | +A typical run : |
| 48 | +```bash |
37 | 49 | sudo modprobe ifb numifbs=1 |
38 | | - sudo docker run -d \ |
| 50 | + docker build --tag wptagent . |
| 51 | + docker run -d \ |
39 | 52 | -e SERVER_URL="http://my-wpt-server.org/work/" \ |
40 | 53 | -e LOCATION="docker-location" \ |
41 | 54 | -e NAME="Docker Test" \ |
42 | 55 | --cap-add=NET_ADMIN \ |
43 | 56 | --init \ |
44 | 57 | 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 |
45 | 75 |
|
| 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