Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 committed Jul 6, 2023
1 parent dfd25a8 commit 51ad700
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 36 deletions.
7 changes: 6 additions & 1 deletion build/chrome/install-chrome
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ set -euxo pipefail

if [ "$1" = "linux/arm64" ]
then
mv /chrome-installer/arm64/ /chrome
apt-get update
apt-get install -y \
ca-certificates \
Expand Down Expand Up @@ -37,6 +36,10 @@ then
libxrender1 \
libxss1 \
libxtst6
mv /chrome-installer/arm64/ /chrome
cp /chrome/chrome_sandbox /usr/local/sbin/chrome-devel-sandbox
chown root:root /usr/local/sbin/chrome-devel-sandbox
chmod 4755 /usr/local/sbin/chrome-devel-sandbox
else
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
apt-get install -y ./google-chrome-stable_current_amd64.deb
Expand All @@ -48,3 +51,5 @@ unzip chromedriver_linux64.zip
chmod +x chromedriver
mv -f chromedriver /usr/local/bin/chromedriver
rm chromedriver_linux64.zip

rm -rf /chrome-installer
26 changes: 14 additions & 12 deletions build/egress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,24 @@ RUN apt-get update && \

# install chrome
COPY --from=livekit/chrome-installer:latest /chrome-installer /chrome-installer
RUN /chrome-installer/install-chrome "$TARGETPLATFORM" && \
rm -rf /chrome-installer
RUN /chrome-installer/install-chrome "$TARGETPLATFORM"

# setup
RUN adduser root pulse-access && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
mkdir -pv ~/.cache/xdgr
# clean up
RUN rm -rf /var/lib/apt/lists/*

# update env
ENV PATH=${PATH}:/chrome
ENV XDG_RUNTIME_DIR=$PATH:~/.cache/xdgr
# create egress user
RUN useradd -ms /bin/bash -g root -G sudo,pulse,pulse-access egress
RUN mkdir -pv home/egress/.cache/xdgr && \
chown -R egress /home/egress && \
chmod 777 /home/egress

# egress
# copy files
COPY --from=0 /workspace/egress /bin/
COPY build/egress/entrypoint.sh /

# run
COPY build/egress/entrypoint.sh /
USER egress
ENV PATH=${PATH}:/chrome
ENV XDG_RUNTIME_DIR=/home/egress/.cache/xdgr
ENV CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox
ENTRYPOINT ["/entrypoint.sh"]
8 changes: 3 additions & 5 deletions build/egress/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ set -euxo pipefail

export TMPDIR=/tmp/lkegress

# Cleanup to be "stateless" on startup, otherwise pulseaudio daemon can't start again
rm -rf /var/run/pulse /var/lib/pulse /root/.config/pulse

# Start pulseaudio as system wide daemon; for debugging it helps to start in non-daemon mode
pulseaudio -D --verbose --exit-idle-time=-1 --system --disallow-exit
# Start pulseaudio
rm -rf /var/run/pulse /var/lib/pulse /home/egress/.config/pulse
pulseaudio -D --verbose --exit-idle-time=-1 --disallow-exit

# cleanup old temporary files
if ! [ -z $TMPDIR ]; then
Expand Down
18 changes: 5 additions & 13 deletions build/test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,40 +50,32 @@ RUN apt-get update && \

# install chrome
COPY --from=livekit/chrome-installer:117.0.5874.0 /chrome-installer /chrome-installer
RUN /chrome-installer/install-chrome "$TARGETPLATFORM" && \
rm -rf /chrome-installer && \
cp /chrome/chrome_sandbox /usr/local/sbin/chrome-devel-sandbox && \
chown root:root /usr/local/sbin/chrome-devel-sandbox && \
chmod 4755 /usr/local/sbin/chrome-devel-sandbox
RUN /chrome-installer/install-chrome "$TARGETPLATFORM"

# clean up
RUN rm -rf /var/lib/apt/lists/*

# install rtsp server
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCH=arm64v8; else ARCH=amd64; fi && \
wget https://github.com/aler9/rtsp-simple-server/releases/download/v0.17.6/rtsp-simple-server_v0.17.6_linux_${ARCH}.tar.gz && \
tar -zxvf rtsp-simple-server_v0.17.6_linux_${ARCH}.tar.gz && \
rm rtsp-simple-server_v0.17.6_linux_${ARCH}.tar.gz

# clean up
RUN rm -rf /var/lib/apt/lists/*

# create egress user
RUN useradd -ms /bin/bash -g root -G sudo,pulse,pulse-access egress
RUN mkdir -pv home/egress/.cache/xdgr && \
chown -R egress /home/egress && \
chmod 777 /home/egress

# copy files, scripts, and binaries
# copy files
COPY test/ /workspace/test/
COPY --from=0 /workspace/egress /bin/
COPY --from=0 /workspace/test.test .
COPY build/test/entrypoint.sh .

# start rtsp server as root
CMD ["./rtsp-simple-server &"]

# run tests
USER egress
ENV PATH=${PATH}:/chrome
ENV XDG_RUNTIME_DIR=/home/egress/.cache/xdgr
ENV RTSP_LOGDESTINATIONS=file
ENV CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox
ENTRYPOINT ["./entrypoint.sh"]
4 changes: 2 additions & 2 deletions build/test/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
set -exo pipefail

# Start pulseaudio as system wide daemon; for debugging it helps to start in non-daemon mode
# Start pulseaudio
rm -rf /var/run/pulse /var/lib/pulse /home/egress/.config/pulse
pulseaudio -D --verbose --exit-idle-time=-1 --disallow-exit

# Run RTSP server
#./rtsp-simple-server &
./rtsp-simple-server > /dev/null 2>&1 &

# Run tests
if [[ -z ${GITHUB_WORKFLOW+x} ]]; then
Expand Down
2 changes: 1 addition & 1 deletion magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func Integration(configFile string) error {

func Build() error {
return mageutil.Run(context.Background(),
"docker pull livekit/chrome-installer",
fmt.Sprintf("docker pull livekit/chrome-installer:%s", chromiumVersion),
fmt.Sprintf("docker pull livekit/gstreamer:%s-dev", gstVersion),
"docker pull livekit/egress-templates",
"docker build -t livekit/egress:latest -f build/egress/Dockerfile .",
Expand Down
4 changes: 2 additions & 2 deletions test/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func (r *Runner) testWebFile(t *testing.T) {
EgressId: utils.NewGuid(utils.EgressPrefix),
Request: &rpc.StartEgressRequest_Web{
Web: &livekit.WebEgressRequest{
Url: webUrl,
// VideoOnly: true,
Url: webUrl,
VideoOnly: true,
FileOutputs: []*livekit.EncodedFileOutput{fileOutput},
},
},
Expand Down

0 comments on commit 51ad700

Please sign in to comment.