First commit

This commit is contained in:
Git Commiter for 96-fromsofia.net 2023-02-27 01:00:58 +00:00
commit ad0ff69c2e
5 changed files with 66 additions and 0 deletions

24
Dockerfile Normal file
View File

@ -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" ]

28
README.txt Normal file
View File

@ -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

9
firefox-container Executable file
View File

@ -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

3
start-firefox.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
chgrp -R audio /dev/snd
su -c "firefox" firefox

2
xcookie Normal file
View File

@ -0,0 +1,2 @@