Skip to content
This repository was archived by the owner on May 19, 2024. It is now read-only.

Commit efbf1f2

Browse files
authored
Update example to use brave plus update pull request error handling (#48)
* Update firefox example * remove yarn-error.log * Build examples ci * run as root * sudo * sudo * use temp folder * temp folder * sudo chmod * fix a typo * fix sudo unzip error * fix error handling * run and pipe all fails * unzip * trap errors * tini * tini entrypoint * use brave * load * error handling * use sleep instead of timeout * catch container id * simple but sure * suppress error 124 * edit bash and use current image * warp:brave * better docker image name tagging * use vanilla docker build * remove if statement * entrypoint * make entrypoint directory * entrypoint dir * use sudo in brave example * use sudo rm * user data directory * update pull request styling * change color
1 parent 5ddabb5 commit efbf1f2

File tree

14 files changed

+190
-1035
lines changed

14 files changed

+190
-1035
lines changed

.docker/base/Dockerfile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ARG USER_GID=${USER_UID}
3434
RUN apt-get update; \
3535
apt-get -y upgrade;\
3636
apt-get install --assume-yes --no-install-recommends \
37-
sudo software-properties-common ca-certificates libnss3-tools \
37+
sudo software-properties-common ca-certificates gnupg libnss3-tools \
3838
wget curl vim pulseaudio xvfb dbus-x11 libdbus-c++-1-0v5; \
3939
#
4040
#clean up
@@ -75,12 +75,14 @@ RUN apt-get update; \
7575
#
7676
#make directories for warp
7777
#
78-
mkdir -p /etc/warp /certs/ /media/ /usr/bin/warp;\
78+
mkdir -p /etc/warp /certs/ /media/ /usr/bin/warp /etc/warp/entrypoint.d/;\
7979
chmod 1777 /certs/; \
8080
chmod 1777 /media/; \
8181
chmod 1777 /usr/bin/warp; \
82+
chmod 1777 /etc/warp/entrypoint.d/; \
8283
chown ${USERNAME} /certs/; \
8384
chown ${USERNAME} /usr/bin/warp/; \
85+
chown ${USERNAME} /etc/warp/entrypoint.d/; \
8486
chown ${USERNAME} /media/; \
8587
chown -R $USERNAME:$USERNAME /home/${USERNAME}
8688

@@ -95,16 +97,19 @@ RUN mkdir /tmp/.X11-unix; \
9597
#Install tini Reference:https://github.com/krallin/tini
9698
#
9799
ARG TINI_VERSION=v0.19.0
98-
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
99-
RUN chmod +x /tini
100-
ENTRYPOINT [ "/tini","--" ]
100+
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
101+
RUN chmod +x /usr/bin/tini
102+
ENTRYPOINT [ "/usr/bin/tini","--" ]
101103

102104
#
103105
#Copy config files
104106
#
105107
COPY .docker/base/entrypoint.sh /etc/warp/entrypoint.sh
106108
RUN chmod +x /etc/warp/entrypoint.sh
107109

110+
COPY .docker/base/run-bash.sh /etc/warp/run-bash.sh
111+
RUN chmod +x /etc/warp/run-bash.sh
112+
108113
COPY .docker/base/generate-certs.sh /certs/generate-certs.sh
109114
RUN chmod +x /certs/generate-certs.sh
110115

@@ -113,12 +118,16 @@ RUN chmod +x /etc/warp/ffmpeg.sh
113118

114119
COPY --from=warp /src /usr/bin/warp
115120

116-
USER ${USERNAME}
117121

118122
ENV USER ${USERNAME}
119123
ENV SHELL /bin/bash
120124
ENV DISPLAY=:99.0
121125

122126
EXPOSE 8080/udp
123127

128+
#
129+
#Run as user `Warp`
130+
#
131+
USER ${USERNAME}
132+
124133
CMD [ "/etc/warp/entrypoint.sh" ]

.docker/base/entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pacmd set-default-source vsink.monitor
2222

2323
#Start ffmpeg
2424
source /etc/warp/ffmpeg.sh &
25-
sleep 0.7 #ensure this has started before moving on
25+
sleep 1 #ensure this has started before moving on
2626

2727
#Generate selfsigned certs for warp
2828
source /certs/generate-certs.sh
@@ -31,6 +31,10 @@ set -e
3131
#Start warp server
3232
/usr/bin/warp/warp &
3333

34+
set -e
35+
#run child image entrypoint
36+
source /etc/warp/run-bash.sh
37+
3438
wait -n
3539

3640
jobs -p | xargs --no-run-if-empty kill

.docker/base/run-bash.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
set -xeuo pipefail
4+
5+
# Set the directory where the other bash files are located
6+
OTHER_SCRIPTS_DIR="/etc/warp/entrypoint.d/"
7+
8+
# Check if the directory exists
9+
if [ -d "$OTHER_SCRIPTS_DIR" ]; then
10+
# Loop through all the files in the directory
11+
for script_file in $OTHER_SCRIPTS_DIR/*.sh; do
12+
# Check if the file is a bash script and is executable
13+
if [ -x "$script_file" ] && [ "${script_file: -3}" == ".sh" ]; then
14+
# Run the script
15+
echo "Running script $script_file"
16+
bash "$script_file"
17+
fi
18+
done
19+
else
20+
echo "Directory $OTHER_SCRIPTS_DIR not found "
21+
fi
22+
23+
# Run the default command (if provided)
24+
exec "$@"

.github/workflows/ghcr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
REGISTRY: ghcr.io
1313
IMAGE_NAME: wanjohiryan/warp
1414
BASE_TAG_PREFIX: x264
15-
CHROME_TAG_PREFIX: chrome-x264
15+
CHROME_TAG_PREFIX: firefox-x264
1616

1717
jobs:
1818
build-git-h264-base:
@@ -98,7 +98,7 @@ jobs:
9898
uses: docker/build-push-action@v4
9999
with:
100100
context: ./
101-
file: examples/chrome-x264/Dockerfile
101+
file: examples/firefox/Dockerfile
102102
push: true
103103
tags: ${{ steps.meta.outputs.tags }}
104104
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/pull-request.yml

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,100 @@ on:
66

77
jobs:
88
build-docker-base:
9-
name: Build docker image for testing
9+
name: Build base image
1010
runs-on: ubuntu-latest
1111
steps:
1212
-
1313
name: Checkout repo
1414
uses: actions/checkout@v3
15+
-
16+
name: Setup Docker Buildx
17+
uses: docker/setup-buildx-action@v2
18+
-
19+
name: Build Docker image
20+
uses: docker/build-push-action@v4
21+
with:
22+
context: ./
23+
file: .docker/base/Dockerfile
24+
push: false
25+
load: true
26+
tags: warp:latest
27+
-
28+
name: Run Docker Container
29+
#error code 124 is timeout error
30+
run: |
31+
set -o pipefail
32+
output=$(timeout 20s docker run warp:latest 2>&1) || exitcode=$?
33+
34+
if [[ $exitcode != 0 && $exitcode != 124 ]]; then
35+
echo "$output"
36+
exit $exitcode
37+
else
38+
echo "$output"
39+
echo -e "\033[01;34mDocker run successful\033[0m"
40+
exit 0
41+
fi
42+
shell: bash
1543

1644
-
17-
name: Build and run warp docker
18-
run: bash ${GITHUB_WORKSPACE}/build.sh
45+
name: Push Docker Image temporarily
46+
uses: docker/build-push-action@v4
47+
with:
48+
context: ./
49+
file: .docker/base/Dockerfile
50+
outputs: type=docker,dest=/tmp/warp.tar
51+
tags: warp:latest
52+
53+
-
54+
name: Upload artifact
55+
uses: actions/upload-artifact@v2
56+
with:
57+
name: warp
58+
path: /tmp/warp.tar
59+
60+
build-brave-example:
61+
name: Build brave browser
62+
needs: build-docker-base
63+
runs-on: ubuntu-latest
64+
steps:
65+
-
66+
name: Checkout repo
67+
uses: actions/checkout@v3
68+
-
69+
name: Download artifact
70+
uses: actions/download-artifact@v2
71+
with:
72+
name: warp
73+
path: /tmp
74+
-
75+
name: Load Docker image
76+
run: |
77+
docker load --input /tmp/warp.tar
78+
docker image ls -a
79+
-
80+
name: Build Docker example
81+
run: |
82+
set -o pipefail
83+
84+
cp examples/brave/Dockerfile .
85+
86+
docker build --tag warp:brave --build-arg WARP_IMAGE=warp:latest .
87+
88+
rm Dockerfile
89+
90+
-
91+
name: Run Docker Container example
92+
run: |
93+
set -o pipefail
94+
output=$(timeout 20s docker run warp:brave 2>&1) || exitcode=$?
95+
96+
if [[ $exitcode != 0 && $exitcode != 124 ]]; then
97+
echo "$output"
98+
exit $exitcode
99+
else
100+
echo "$output"
101+
echo -e "\033[01;34mDocker run successful\033[0m"
102+
exit 0
103+
fi
104+
105+
shell: bash

build.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/brave/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
#Import from base
3+
#
4+
5+
ARG WARP_IMAGE=ghcr.io/wanjohiryan/warp/x264:nightly
6+
FROM $WARP_IMAGE
7+
8+
#
9+
#Install brave
10+
#
11+
# Add Brave Browser repository and key
12+
RUN wget -qO - https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key add - ;\
13+
echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list; \
14+
sudo apt-get update && sudo apt-get install -y brave-browser; \
15+
#
16+
# clean up
17+
#
18+
sudo apt-get clean -y; \
19+
sudo rm -rf /var/lib/apt/lists/* /var/cache/apt/*
20+
21+
#
22+
#Copy entrypoint into a directory the parent entrypoint will see
23+
#
24+
COPY examples/brave/brave.sh /etc/warp/entrypoint.d/brave.sh
25+
RUN sudo chmod +x /etc/warp/entrypoint.d/brave.sh

examples/brave/brave.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -xeo pipefail
4+
5+
SCREEN_WIDTH=1920
6+
SCREEN_HEIGHT=1080
7+
8+
#Create brave user directory
9+
USER_DATA_DIR="/home/$USER/.config/brave-browser"
10+
sudo mkdir -p "$USER_DATA_DIR"
11+
12+
# Start Brave browser and play kygo
13+
brave-browser \
14+
--user-data-dir="$USER_DATA_DIR" \
15+
--no-sandbox \
16+
--disable-background-networking \
17+
--disable-default-apps \
18+
--disable-extensions \
19+
--disable-gpu \
20+
--disable-sync \
21+
--disable-translate \
22+
--disable-web-security \
23+
--no-first-run \
24+
--noerrdialogs \
25+
--remote-debugging-port=9222 \
26+
--start-maximized \
27+
"https://www.youtube.com/watch?v=iFPMz36std4" &
28+
29+
#Do you like kygo? :)

examples/chrome-x264/Dockerfile

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)