From ad0ff69c2edc5df38590d58a1009d7ff5c02c3ac Mon Sep 17 00:00:00 2001 From: "Git Commiter for 96-fromsofia.net" <2a9-7cc@96-fromsofia.net> Date: Mon, 27 Feb 2023 01:00:58 +0000 Subject: [PATCH] First commit --- Dockerfile | 24 ++++++++++++++++++++++++ README.txt | 28 ++++++++++++++++++++++++++++ firefox-container | 9 +++++++++ start-firefox.sh | 3 +++ xcookie | 2 ++ 5 files changed, 66 insertions(+) create mode 100644 Dockerfile create mode 100644 README.txt create mode 100755 firefox-container create mode 100755 start-firefox.sh create mode 100644 xcookie diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..74e84ac --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# Use the latest alpine ISO +FROM alpine:latest + +# Copy the static xcookie file and add the start-firefox.sh script +COPY xcookie /tmp/ +ADD start-firefox.sh / +RUN chmod +x /start-firefox.sh + +# Add the necessary packages +# alsa-utils: for sound +# xauth: to insert the host's X11 cookie on the container +# firefox: our browser +# ttf-liberation: so we have fonts in FX +RUN apk add alsa-utils xauth firefox ttf-liberation + +# Create a user and group firefox. Add the user to groups firefox; audio; video. +RUN adduser firefox -D ; addgroup firefox firefox ; addgroup firefox audio ; addgroup firefox video + +# Create the asoundrc on the newly created user and insert the X11 cookie +RUN su -c 'echo -e "defaults.pcm.card 1;\ndefaults.pcm.device 0;\ndefaults.ctl.card 1;" > ~/.asoundrc' firefox +RUN su -c "xauth add $(cat /tmp/xcookie)" firefox + +# Start the thingz +CMD [ "/bin/sh", "/start-firefox.sh" ] diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..b55af2b --- /dev/null +++ b/README.txt @@ -0,0 +1,28 @@ +# 0) This setup is intended for Desktop use by your local user and not root. +# It will spawn a docker container that will use your Xsession to run the firefox browser +# Your user is assumed to have permission to run and build containers + +# 1) Go into the source directory of this app 'firefox' and copy it into your docker environment: +# You can use your own path but will need to adjust the below lines and any affected dependant files accordingly +$ cp . /var/lib/docker/configs/firefox/ +$ cd /var/lib/docker/configs/firefox/ + +# 2) Configure the host environment for the container before starting it +# Run 'xauth list' on the Docker host as the user that will run the container (not root, unless root runs X on your system) +# Copy the whole line that was produced by the above command and save it into the xcookie in the source directory of this app + +# 3) Build your container +$ docker build -t . firefox + +# 4) Create the below directories within /var/lib/docker/configs/pass/data +# If using a different path to store your containers configurations and data files you will need to modify the paths in the 'firefox-container' script too +$ mkdir -p /var/lib/docker/configs/pass/data/{cache,mozilla} +# Create a directory to keep the downloads of your container locally: +$ mkdir -p /home/$USER/Downloads/firefox-container + +# 5) Start your container with: +$ firefox-container + +# 6) Optionally you can move the start-pass script somewhere inside of your path +$ sudo cp firefox-container /usr/loca/bin +$ sudo chmod -v 0755 /usr/loca/bin/firefox-container diff --git a/firefox-container b/firefox-container new file mode 100755 index 0000000..2679913 --- /dev/null +++ b/firefox-container @@ -0,0 +1,9 @@ +docker run --rm -it \ + --net=host \ + -v /tmp/.X11-unix \ + -v /home/$USER/Downloads/firefox-container:/home/firefox/Downloads \ + -v /var/lib/docker/configs/firefox/data/cache:/home/firefox/.cache \ + -v /var/lib/docker/configs/firefox/data/mozilla:/home/firefox/.mozilla \ + -e DISPLAY=$DISPLAY \ + --device=/dev/snd \ + firefox diff --git a/start-firefox.sh b/start-firefox.sh new file mode 100755 index 0000000..139f5ee --- /dev/null +++ b/start-firefox.sh @@ -0,0 +1,3 @@ +#!/bin/sh +chgrp -R audio /dev/snd +su -c "firefox" firefox diff --git a/xcookie b/xcookie new file mode 100644 index 0000000..139597f --- /dev/null +++ b/xcookie @@ -0,0 +1,2 @@ + +