Skip to content

Commit

Permalink
Build FFmpeg and optimize video container
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 committed Nov 22, 2024
1 parent 6dc901e commit 22a50fb
Show file tree
Hide file tree
Showing 21 changed files with 188 additions and 211 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- build-test
if: (contains(toJson(github.event.commits), '[deploy]') || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true')) && !failure() && !cancelled()
name: Deploy and Release
runs-on: ubuntu-latest
runs-on: blacksmith-8vcpu-ubuntu-2204
permissions: write-all
steps:
- name: Free Disk Space (Ubuntu)
Expand Down Expand Up @@ -83,11 +83,10 @@ jobs:
AUTHORS: ${{ vars.AUTHORS || 'SeleniumHQ' }}
- name: Sets prerelease to false by default
run: echo "PRERELEASE=false" >> $GITHUB_ENV
- name: Build base image to get Grid version
run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base
- name: Get Grid version
# sed used to remove last comma of Selenium version output
run: echo "GRID_VERSION=$(docker run --rm ${NAME}/base:local-${BUILD_DATE} java -jar /opt/selenium/selenium-server.jar hub --version | awk '{print $3}' | sed 's/\(.*\),/\1 /')" | awk '{$1=$1;print}' >> $GITHUB_ENV
run: |
echo ${BASE_VERSION}
echo "GRID_VERSION=${BASE_VERSION}" >> $GITHUB_ENV
- name: Is it a prerelease?
run: echo "GRID_VERSION=${GRID_VERSION}-prerelease" >> $GITHUB_ENV && echo "PRERELEASE=true" >> $GITHUB_ENV
if: contains(toJson(github.event.commits), '[prerelease]') == true
Expand Down Expand Up @@ -121,7 +120,7 @@ jobs:
if: github.event.inputs.skip-build-push-image != 'true'
uses: nick-invision/retry@master
with:
timeout_minutes: 90
timeout_minutes: 300
max_attempts: 3
retry_wait_seconds: 60
command: PLATFORMS="${PLATFORMS}" VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build
Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,11 @@ jobs:
uses: nick-invision/retry@master
if: matrix.build-all == true
with:
timeout_minutes: 20
timeout_minutes: 60
max_attempts: 3
retry_wait_seconds: 60
command: |
VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build
- name: Pre-build to reduce logs in test phase
uses: nick-invision/retry@master
if: matrix.build-all != true
with:
timeout_minutes: 30
max_attempts: 3
retry_wait_seconds: 60
command: |
VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make hub
VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make chrome
VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make firefox
VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make edge
- name: Set test parameters
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
run: |
Expand All @@ -158,7 +146,7 @@ jobs:
- name: Run Docker Compose to ${{ matrix.test-strategy }}
uses: nick-invision/retry@master
with:
timeout_minutes: 40
timeout_minutes: 120
max_attempts: 2
retry_wait_seconds: 60
command: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/helm-chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
- name: Build Docker images
uses: nick-invision/retry@master
with:
timeout_minutes: 12
timeout_minutes: 60
max_attempts: 3
retry_wait_seconds: 60
command: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- build-test
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && !failure() && !cancelled()
name: Deploy and Release Nightly
runs-on: ubuntu-latest
runs-on: blacksmith-8vcpu-ubuntu-2204
permissions: write-all
steps:
- name: Free Disk Space (Ubuntu)
Expand Down Expand Up @@ -63,16 +63,13 @@ jobs:
env:
NAMESPACE: ${{ vars.DOCKER_NAMESPACE || 'selenium' }}
AUTHORS: ${{ vars.AUTHORS || 'SeleniumHQ' }}
- name: Build base image to get Grid version
run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base
- name: Get Grid version
# sed used to remove last comma of Selenium version output
run: |
echo "GRID_VERSION=$(docker run --rm ${NAME}/base:local-${BUILD_DATE} java -jar /opt/selenium/selenium-server.jar hub --version | awk '{print $3}' | sed 's/\(.*\),/\1 /')" | awk '{$1=$1;print}' >> $GITHUB_ENV
echo ${BASE_VERSION}
echo "GRID_VERSION=${BASE_VERSION}" >> $GITHUB_ENV
- name: Display Grid version and set Base version
run: |
echo ${GRID_VERSION}
echo "BASE_VERSION=$(echo ${GRID_VERSION})" >> $GITHUB_ENV
echo "BASE_RELEASE=nightly" >> $GITHUB_ENV
- name: Update tag nightly
uses: richardsimko/update-tag@v1.0.11
Expand All @@ -83,7 +80,7 @@ jobs:
- name: Build images
uses: nick-invision/retry@master
with:
timeout_minutes: 90
timeout_minutes: 300
max_attempts: 3
retry_wait_seconds: 60
command: PLATFORMS="${PLATFORMS}" VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build
Expand Down
26 changes: 14 additions & 12 deletions Base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ ENV DEBIAN_FRONTEND=noninteractive \
SEL_GID=${GID} \
HOME=${HOME} \
TZ=${TZ} \
SEL_DOWNLOAD_DIR=${HOME}/Downloads
SEL_DOWNLOAD_DIR=${HOME}/Downloads \
VIDEO_FOLDER="/videos"

#========================
# Miscellaneous packages
# Includes minimal runtime used for executing non GUI Java programs
#========================
RUN --mount=type=secret,id=SEL_PASSWD \
if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
echo "deb http://archive.ubuntu.com/ubuntu noble main universe\n" > /etc/apt/sources.list \
&& echo "deb http://archive.ubuntu.com/ubuntu noble-updates main universe\n" >> /etc/apt/sources.list \
&& echo "deb http://security.ubuntu.com/ubuntu noble-security main universe\n" >> /etc/apt/sources.list ; \
Expand All @@ -61,8 +61,10 @@ RUN --mount=type=secret,id=SEL_PASSWD \
gnupg2 \
libnss3-tools \
python3-pip \
openjdk-${JRE_VERSION}-jre-headless \
&& if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" = "v7" ]; then \
openjdk-${JRE_VERSION}-jre-headless

RUN --mount=type=secret,id=SEL_PASSWD \
if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" = "v7" ]; then \
export ARCH=armhf ; \
else \
export ARCH=$(dpkg --print-architecture) ; \
Expand Down Expand Up @@ -93,18 +95,18 @@ RUN --mount=type=secret,id=SEL_PASSWD \
# Selenium & relaxing permissions for OpenShift and other non-sudo environments
#==========
&& mkdir -p /opt/selenium /opt/selenium/assets /opt/selenium/secrets /var/run/supervisor /var/log/supervisor ${SEL_DOWNLOAD_DIR} \
${HOME}/.mozilla ${HOME}/.vnc ${HOME}/.pki/nssdb \
${HOME}/.mozilla ${HOME}/.vnc ${HOME}/.pki/nssdb ${VIDEO_FOLDER} \
# NSSDB initialization with an empty password
&& certutil -d sql:${HOME}/.pki/nssdb -N --empty-password \
&& touch /opt/selenium/config.toml \
&& chown -R ${SEL_USER}:${SEL_GROUP} /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd ${HOME} \
&& chmod -R 775 /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd ${HOME} \
&& chown -R ${SEL_USER}:${SEL_GROUP} /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd ${HOME} ${VIDEO_FOLDER} \
&& chmod -R 775 /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd ${HOME} ${VIDEO_FOLDER} \
&& wget --no-verbose https://github.com/${AUTHORS}/selenium/releases/download/${RELEASE}/selenium-server-${VERSION}.jar \
-O /opt/selenium/selenium-server.jar \
&& chgrp -R 0 /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
&& chmod -R g=u /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
&& setfacl -Rm u:${SEL_USER}:rwx /opt /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
&& setfacl -Rm g:${SEL_GROUP}:rwx /opt /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
&& chgrp -R 0 /opt/selenium ${HOME} ${VIDEO_FOLDER} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
&& chmod -R g=u /opt/selenium ${HOME} ${VIDEO_FOLDER} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
&& setfacl -Rm u:${SEL_USER}:rwx /opt /opt/selenium ${HOME} ${VIDEO_FOLDER} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
&& setfacl -Rm g:${SEL_GROUP}:rwx /opt /opt/selenium ${HOME} ${VIDEO_FOLDER} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \
#=====
# Download observability related OpenTelemetry jars and make them available in a separate directory
# so that the container can skip downloading them everytime it comes up
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ BUILD_ARGS := $(BUILD_ARGS) --progress plain
MAJOR := $(word 1,$(subst ., ,$(TAG_VERSION)))
MINOR := $(word 2,$(subst ., ,$(TAG_VERSION)))
MAJOR_MINOR_PATCH := $(word 1,$(subst -, ,$(TAG_VERSION)))
FFMPEG_VERSION := $(or $(FFMPEG_VERSION),$(FFMPEG_VERSION),7.1)
FFMPEG_TAG_PREV_VERSION := $(or $(FFMPEG_TAG_PREV_VERSION),$(FFMPEG_TAG_PREV_VERSION),ffmpeg-7.1)
FFMPEG_TAG_VERSION := $(or $(FFMPEG_TAG_VERSION),$(FFMPEG_TAG_VERSION),ffmpeg-7.1)
FFMPEG_BASED_NAME := $(or $(FFMPEG_BASED_NAME),$(FFMPEG_BASED_NAME),linuxserver)
Expand Down Expand Up @@ -244,7 +245,7 @@ standalone_edge_beta: edge_beta
cd ./Standalone && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg NAMESPACE=$(NAME) --build-arg VERSION=beta --build-arg BASE=node-edge -t $(NAME)/standalone-edge:beta .

video:
cd ./Video && SEL_PASSWD=$(SEL_PASSWD) docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg NAMESPACE=$(FFMPEG_BASED_NAME) --build-arg BASED_TAG=$(FFMPEG_BASED_TAG) --secret id=SEL_PASSWD --sbom=true --attest type=provenance,mode=max -t $(NAME)/video:$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) .
cd ./Video && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg VERSION_FFMPEG=$(FFMPEG_VERSION) $(FROM_IMAGE_ARGS) -t $(NAME)/video:$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) .

fetch_grid_scaler_resources:
mkdir -p ./.keda/scalers \
Expand Down Expand Up @@ -932,7 +933,7 @@ chart_test_autoscaling_deployment:
./tests/charts/make/chart_test.sh DeploymentAutoscaling

chart_test_autoscaling_job_https:
PLATFORMS=$(PLATFORMS) TEST_EXISTING_KEDA=true RELEASE_NAME=selenium CHART_ENABLE_BASIC_AUTH=true SELENIUM_GRID_MONITORING=false SCALING_STRATEGY=accurate \
PLATFORMS=$(PLATFORMS) TEST_EXISTING_KEDA=true RELEASE_NAME=selenium CHART_ENABLE_BASIC_AUTH=true SELENIUM_GRID_MONITORING=false \
SECURE_CONNECTION_SERVER=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_PORT=443 SUB_PATH=/ \
MAX_SESSIONS_FIREFOX=1 MAX_SESSIONS_EDGE=2 MAX_SESSIONS_CHROME=3 TEST_NAME_OVERRIDE=true \
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) BASE_VERSION=$(BASE_VERSION) EXTERNAL_UPLOADER_CONFIG=true \
Expand All @@ -954,7 +955,7 @@ chart_test_autoscaling_job:
./tests/charts/make/chart_test.sh JobAutoscaling

chart_test_autoscaling_playwright_connect_grid:
PLATFORMS=$(PLATFORMS) CHART_ENABLE_TRACING=true CHART_ENABLE_BASIC_AUTH=true MATRIX_TESTS=CDPTests SCALING_STRATEGY=accurate \
PLATFORMS=$(PLATFORMS) CHART_ENABLE_TRACING=true CHART_ENABLE_BASIC_AUTH=true MATRIX_TESTS=CDPTests \
BASIC_AUTH_USERNAME=docker-selenium BASIC_AUTH_PASSWORD=2NMI4jdBi6k7bENoeUfV25295VvzwAE9chM24a+2VL95uOHozo \
SECURE_INGRESS_ONLY_DEFAULT=true SECURE_USE_EXTERNAL_CERT=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_HOST=$$(hostname -i) SELENIUM_GRID_PORT=443 \
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) BASE_VERSION=$(BASE_VERSION) \
Expand Down
11 changes: 6 additions & 5 deletions NodeBase/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/base:${VERSION}
ARG BASE=base
FROM ${NAMESPACE}/${BASE}:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}

Expand Down Expand Up @@ -66,8 +67,7 @@ ENV LANG_WHICH=${LANG_WHICH} \
# Following line fixes https://github.com/SeleniumHQ/docker-selenium/issues/87
DBUS_SESSION_BUS_ADDRESS=/dev/null

RUN --mount=type=secret,id=SEL_PASSWD \
apt-get update -qqy \
RUN apt-get update -qqy \
&& apt-get -qqy --no-install-recommends install \
#==============
# Xvfb
Expand Down Expand Up @@ -104,11 +104,12 @@ RUN --mount=type=secret,id=SEL_PASSWD \
&& apt-get -qyy autoremove \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get -qyy clean \
&& pip install --no-cache-dir --upgrade --break-system-packages setuptools \
&& pip install --no-cache-dir --upgrade --break-system-packages setuptools
########################################
# noVNC exposes VNC through a web page #
########################################
&& wget -nv -O noVNC.zip \
RUN --mount=type=secret,id=SEL_PASSWD \
wget -nv -O noVNC.zip \
"https://github.com/novnc/noVNC/archive/refs/${NOVNC_SOURCE}/${NOVNC_VERSION}.zip" \
&& unzip -x noVNC.zip \
&& mv noVNC-${NOVNC_VERSION} /opt/bin/noVNC \
Expand Down
3 changes: 2 additions & 1 deletion NodeChrome/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/node-base:${VERSION}
ARG BASE=node-base
FROM ${NAMESPACE}/${BASE}:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}

Expand Down
3 changes: 2 additions & 1 deletion NodeChromium/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/node-base:${VERSION}
ARG BASE=node-base
FROM ${NAMESPACE}/${BASE}:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}

Expand Down
3 changes: 2 additions & 1 deletion NodeEdge/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/node-base:${VERSION}
ARG BASE=node-base
FROM ${NAMESPACE}/${BASE}:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}

Expand Down
3 changes: 2 additions & 1 deletion NodeFirefox/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/node-base:${VERSION}
ARG BASE=node-base
FROM ${NAMESPACE}/${BASE}:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}

Expand Down
Loading

0 comments on commit 22a50fb

Please sign in to comment.