Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wptagent dockerfile #3012

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ services:
build:
context: .
dockerfile: docker/local/Dockerfile-wptagent
command: python3 wptagent.py -vvvv --xvfb --dockerized --server http://web/work/ --location Test --key 123456789
environment:
- SERVER_URL=http://web/work/
- LOCATION=Test
- KEY=123456789
init: true
#### ####

secrets:
Expand Down
72 changes: 40 additions & 32 deletions docker/local/Dockerfile-wptagent
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,61 @@
### Recommend to install with "docker build <GITHUB-REPO-LINK> -t TAGNAME",
### grabs the latest copy of WPT and build time on average takes 10 minutes.

FROM ubuntu
FROM ubuntu:22.04 as production

### TIMEZONE INSIDE THE CONTAINER ###
ARG TIMEZONE=UTC

### PREVENTs INTERACTIVE PROMPTS WHILE INSTALLING ###
ARG DEBIAN_FRONTEND=noninteractive

### COPYING ENTIRE DIR TO LOCAL DOCKER /wptagent
#COPY / /wptagent
RUN apt-get update

# Install software
RUN apt-get install -y git
RUN git clone -b master https://github.com/WPO-Foundation/wptagent.git
#COPY docker/linux-headless/entrypoint.sh /wptagent/entrypoint.sh

### UPDATE ###
RUN apt-get update
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
RUN apt update

### INSTALL APT-GET LIBS ###
RUN xargs -a /wptagent/.github/workflows/docker-apt-get.txt apt-get install --no-install-recommends --yes
# set default timezone beforehand to avoid user interaction for tzdata package
RUN ln -fs /usr/share/zoneinfo/$TIMEZONE /etc/localtime && apt install -y \
git \
python3 python3-pip python3-ujson \
imagemagick dbus-x11 traceroute software-properties-common psmisc libnss3-tools iproute2 net-tools openvpn \
libtiff5-dev libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk \
python3-dev libavutil-dev libmp3lame-dev libx264-dev yasm autoconf automake build-essential libass-dev libfreetype6-dev libtheora-dev \
libtool libvorbis-dev pkg-config texi2html libtext-unidecode-perl python3-numpy python3-scipy perl \
adb ethtool nodejs cmake git-core libsdl2-dev libva-dev libvdpau-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev texinfo wget \
ttf-mscorefonts-installer fonts-noto fonts-roboto fonts-open-sans ffmpeg npm sudo curl xvfb

# Get WPTAgent for dependecies
RUN git clone -b master https://github.com/WPO-Foundation/wptagent.git

### UPGRADING PIP AND INSTALLING REQUIRED PACKAGES ###
RUN python3 -m pip install --upgrade --user pip && \
python3 -m pip install --user -r /wptagent/.github/workflows/requirements.txt
### UPDATE FONT CACHE ###
RUN fc-cache -f -v

### INSTALLING LIGHTHOUSE FROM NPM ###
RUN npm install -g lighthouse

### INSTALLING CHROME BROWSER ###
### Fails to Find all libs needed to run
# RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
# dpkg -i google-chrome-stable_current_amd64.deb; exit 0 && \
# apt -f install -y && \
# apt-get install google-chrome-stable
RUN curl -o /tmp/google-chrome-stable_current_amd64.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
apt install -y /tmp/google-chrome-stable_current_amd64.deb && rm /tmp/google-chrome-stable_current_amd64.deb

### BETTER INSTALLING CHROME BROWSER METHOD ###
### Better Installing method but would like to change this to something less complex.
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update && apt-get -y install google-chrome-stable ; exit 0
RUN apt-get update --fix-missing -y
RUN apt-get install -f -y
### UPGRADING PIP AND INSTALLING REQUIRED PACKAGES ###
RUN python3 -m pip install --upgrade --user pip && \
python3 -m pip install --user -r /wptagent/.github/workflows/requirements.txt

### CLEAN UP ###
# We could add some clean up here but in testing it was negotiable
WORKDIR /wptagent

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

WORKDIR /wptagent
### DEBUG CONTAINER ###
# To build the debug container add `--target debug` as a build parameter
FROM production as debug

### INSTALLING DEBUG DEPENDENCIES ###
RUN pip install debugpy

### COPY DEBUG AGENT AND MOVE REAL ONE ###
RUN mv wptagent.py wptagent_starter.py
COPY wptagent_debug.py wptagent.py

### /bin/bash LOCATION OF COMMAND EXECUTION ###
#CMD ["python3","wptagent.py", "-vvvv", "--xvfb", "--server", "http://web/work/", "--location", "Test", "--key", "123456789"]
### SETTING PRODUCTION BUILD AS DEFAULT ###
FROM production
8 changes: 6 additions & 2 deletions docker/local/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ Since the Webpagetest container is packaged with an agent, we first need to stop
```docker-compose.yml
#### DOCKER WPTAGENT - comment this out to run a standalone agent ####
agent:
cap_add:
cap_add: #### Allows traffic shapping
- NET_ADMIN
build:
context: .
dockerfile: docker/local/Dockerfile-wptagent
command: python3 wptagent.py -vvvv --xvfb --dockerized --server http://web/work/ --location Test --key 123456789
environment:
- SERVER_URL=http://web/work/
- LOCATION=Test
- KEY=123456789
init: true
#### ####
```

Expand Down