diff --git a/Makefile b/Makefile index c6f2659..f7d42f1 100644 --- a/Makefile +++ b/Makefile @@ -16,12 +16,12 @@ build-no-cache: install: ${CONTAINER_ENGINE} run -it --rm --privileged \ - --volume ./bin:/target \ + --volume ${PWD}/bin:/target \ docker.io/stifstof/teams-desktop:latest install uninstall: ${CONTAINER_ENGINE} run -it --rm --privileged \ - --volume ./bin:/target \ + --volume ${PWD}/bin:/target \ docker.io/stifstof/teams-desktop:latest uninstall # convenience jobs @@ -44,11 +44,11 @@ create-empty-config-folders: add-to-path: export PATH=$PATH:/home/cn/Documents/git/TeamsInDocker/bin -podman: +podman_runtime: rm -f .env echo "CONTAINER_ENGINE=podman" >> .env -docker: +docker_runtime: rm -f .env echo "CONTAINER_ENGINE=docker" >> .env diff --git a/README.md b/README.md index 5ea145f..4d53b5e 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ This projects objective is to provide Microsoft Teams as a container to enable m Currently the project supports Docker and Podman. Select which runtime you want with the convenient make targets: Makefile (System setup) -- docker -- podman +- docker_runtime +- podman_runtime - current_runtime The default runtime is Docker. Select podman with "make podman" and confirm with "make current_runtime". @@ -23,6 +23,10 @@ Makefile - uninstall - build +# Supported Container Runtimes + +Podman has been added as an alternative to Docker, to enable use on systems without root access. When using Podman, the container user's root will only have the permission of the user executing podman, and the container user will have UID > 10000 as per best practice recommendations. + # Old Readme This project is inspired from te works of gfa01/slack-desktop, but instead for Microsoft Teams. The old README explains the use of PulseAudio and XServer well diff --git a/host-scripts/teams-wrapper b/host-scripts/teams-wrapper index 7c62d81..a82d595 100755 --- a/host-scripts/teams-wrapper +++ b/host-scripts/teams-wrapper @@ -9,16 +9,23 @@ IMAGE_NAME="docker.io/stifstof/teams-desktop:latest" CONTAINER_NAME="teams" CONFIG_PATH="${HOME}/.config/Microsoft" +########## Script + # Container runtime (docker or podman) CONTAINER_ENGINE="${CONTAINER_ENGINE}" +# Local .env +if [ -f "/home/$LOCAL_COMPUTER_USERNAME/Documents/git/TeamsInDocker/.env" ]; then + # Load Environment Variables + export $(cat /home/$LOCAL_COMPUTER_USERNAME/Documents/git/TeamsInDocker/.env | grep -v '#' | awk '/=/ {print $1}') + # For instance, will be example_kaggle_key + echo $CONTAINER_ENGINE +fi if [ -z "$CONTAINER_ENGINE" ] then - echo "\$CONTAINER_ENGINE is empty. Defaulting to podman" - CONTAINER_ENGINE="podman" + echo "\$CONTAINER_ENGINE is empty. Defaulting to docker" + CONTAINER_ENGINE="docker" fi -########## Script - PATH=/home/cn/Documents/git/TeamsInDocker/bin:/usr/sbin:/usr/bin:/sbin:/bin TEAMS_DESKTOP_USER=${LOCAL_COMPUTER_USERNAME} XSOCK=/home/$TEAMS_DESKTOP_USER/X/teamsOne/.X11-unix @@ -63,6 +70,12 @@ cleanup_stopped_teams_desktop_instances() { done } +prepare_extra_arguments() { + if [ "$CONTAINER_ENGINE" == "docker" ]; then + TEAMS_EXTRA_CONTAINER_ARGUMENTS+="--privileged" + fi +} + prepare_container_env_parameters() { ENV_VARS+=" --env=USER_UID=${USER_UID}" ENV_VARS+=" --env=USER_GID=${USER_GID}" @@ -131,6 +144,7 @@ cleanup_stopped_teams_desktop_instances prepare_container_env_parameters prepare_container_volume_parameters prepare_container_device_parameters +prepare_extra_arguments echo "Starting ${prog}..." set -o xtrace @@ -141,8 +155,8 @@ ${SUDO} ${CONTAINER_ENGINE} run -d \ --shm-size=4g \ --device /dev/dri \ --device /dev/snd \ + ${TEAMS_EXTRA_CONTAINER_ARGUMENTS} \ ${ENV_VARS} \ ${VIDEO_DEVICES} \ ${VOLUMES} \ - ${TEAMS_EXTRA_CONTAINER_ARGUMENTS} \ ${IMAGE_NAME} ${prog} $@ >/dev/null diff --git a/host-scripts/teams-wrapper-two b/host-scripts/teams-wrapper-two index 96993fd..c4c5c75 100644 --- a/host-scripts/teams-wrapper-two +++ b/host-scripts/teams-wrapper-two @@ -9,16 +9,23 @@ IMAGE_NAME="docker.io/stifstof/teams-desktop:latest" CONTAINER_NAME="teams-two" CONFIG_PATH="${HOME}/.config/MicrosoftTwo" +########## Script + # Container runtime (docker or podman) CONTAINER_ENGINE="${CONTAINER_ENGINE}" +# Local .env +if [ -f "/home/$LOCAL_COMPUTER_USERNAME/Documents/git/TeamsInDocker/.env" ]; then + # Load Environment Variables + export $(cat /home/$LOCAL_COMPUTER_USERNAME/Documents/git/TeamsInDocker/.env | grep -v '#' | awk '/=/ {print $1}') + # For instance, will be example_kaggle_key + echo $CONTAINER_ENGINE +fi if [ -z "$CONTAINER_ENGINE" ] then - echo "\$CONTAINER_ENGINE is empty. Defaulting to podman" - CONTAINER_ENGINE="podman" + echo "\$CONTAINER_ENGINE is empty. Defaulting to docker" + CONTAINER_ENGINE="docker" fi -########## Script - PATH=/home/cn/Documents/git/TeamsInDocker/bin:/usr/sbin:/usr/bin:/sbin:/bin TEAMS_DESKTOP_USER=${LOCAL_COMPUTER_USERNAME} XSOCK=/home/$TEAMS_DESKTOP_USER/X/teamsTwo/.X11-unix @@ -63,6 +70,12 @@ cleanup_stopped_teams_desktop_instances() { done } +prepare_extra_arguments() { + if [ "$CONTAINER_ENGINE" == "docker" ]; then + TEAMS_EXTRA_CONTAINER_ARGUMENTS+="--privileged" + fi +} + prepare_container_env_parameters() { ENV_VARS+=" --env=USER_UID=${USER_UID}" ENV_VARS+=" --env=USER_GID=${USER_GID}" @@ -131,6 +144,7 @@ cleanup_stopped_teams_desktop_instances prepare_container_env_parameters prepare_container_volume_parameters prepare_container_device_parameters +prepare_extra_arguments echo "Starting ${prog}..." set -o xtrace @@ -141,8 +155,8 @@ ${SUDO} ${CONTAINER_ENGINE} run -d \ --shm-size=4g \ --device /dev/dri \ --device /dev/snd \ + ${TEAMS_EXTRA_CONTAINER_ARGUMENTS} \ ${ENV_VARS} \ ${VIDEO_DEVICES} \ ${VOLUMES} \ - ${TEAMS_EXTRA_CONTAINER_ARGUMENTS} \ ${IMAGE_NAME} ${prog} $@ >/dev/null