# Image for the 1EL RS course

# user = abc, password = abc
# sudo: no password

# Build:
# docker build -t 1elrs .

# Run:
# docker run --rm --detach --publish 3000:3000 --publish 3001:3001 --env TITLE=RS --device /dev/snd:/dev/snd 1elrs:latest
# or, if you want to "mount" a host directory to the /home/abc/PersistentDir directory in the container:
# docker run --rm --detach --publish 3000:3000 --publish 3001:3001 --env TITLE=RS --volume YOUR_CHOICE_OF_PATH:/home/abc/PersistentDir:rw --device /dev/snd:/dev/snd 1elrs:latest
# and to use your host user id and host group id (XXXX is given by id -u and YYYY by id -g):
# docker run --rm --detach --publish 3000:3000 --publish 3001:3001 --env TITLE=RS --env PUID=XXXX --env PGID=YYYY --volume YOUR_CHOICE_OF_PATH:/home/abc/PersistentDir:rw --device /dev/snd:/dev/snd 1elrs:latest

# Connect to:
# Use a web browser and visit http://127.0.0.1:3000/

FROM	lscr.io/linuxserver/webtop:ubuntu-icewm

# Give the abc user a regular home and nice prompt
RUN	mkdir /home/abc && mkdir /home/abc/Downloads && mkdir /home/abc/PersistentDir && chown -R abc:abc /home/abc && usermod -d /home/abc abc
RUN	echo "PS1='\u@graoully:\w\$ '" >> /home/abc/.bashrc
RUN 	echo "alias ls='ls --color=auto'" >> /etc/bash.bashrc
ENV	HOME=/home/abc

# Install a few utilities
RUN	apt-get update && apt-get upgrade -y && \
	apt-get install -y zip unzip git gedit tree iputils-ping wget vim pip net-tools traceroute evince iproute2 curl xfce4-terminal hping3 dnsutils

# get rid of gedit warning messages
RUN	echo "#!/bin/bash" > /usr/bin/gedit-null && echo "/usr/bin/gedit \""\$\@\"" 2>/dev/null" >> /usr/bin/gedit-null && chmod 755 /usr/bin/gedit-null
RUN	echo "alias gedit=/usr/bin/gedit-null" >> /etc/bash.bashrc 

# Add Firefox profile
COPY	profiles.ini /home/abc/.mozilla/firefox/profiles.ini
COPY	prefs.js /home/abc/.mozilla/firefox/sip.default-release/prefs.js
COPY	favicons.sqlite /home/abc/.mozilla/firefox/sip.default-release/favicons.sqlite
COPY	places.sqlite /home/abc/.mozilla/firefox/sip.default-release/places.sqlite    
RUN	chown -R abc:abc /home/abc/.mozilla/ 

# Pour le son dans le container
# lancer le container avec l'option --device /dev/snd:/dev/snd
RUN	apt-get update && apt-get upgrade -y && \
	apt-get install -y alsa-base alsa-utils
RUN	sudo usermod -aG audio abc \
&& 	newgrp audio

# à l'installation la configuration de wireshark demande si les non-superusers ont le droit de capturer des paquets, le -y de l'apt install n'y peut rien
# solution : https://askubuntu.com/questions/1275842/install-wireshark-without-confirm
RUN	echo "wireshark-common wireshark-common/install-setuid boolean true" | debconf-set-selections && \
	DEBIAN_FRONTEND=noninteractive apt-get -y install wireshark

RUN	echo "export PATH=$PATH" > /etc/environment
# Clean up
RUN	apt-get autoremove -y && apt-get autoclean -y && apt-get clean -y
RUN	rm -rf \
	/tmp/* \
	/var/lib/apt/lists/* \
	/var/tmp/*