initial commit

This commit is contained in:
Christoffer Nissen
2022-01-05 21:56:51 +00:00
commit 0a50720f6b
9 changed files with 581 additions and 0 deletions

51
Dockerfile Normal file
View File

@@ -0,0 +1,51 @@
FROM debian:latest
LABEL author=stifstof
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -qy curl ca-certificates sudo libxkbfile1
RUN apt-get install -y \
curl \
fonts-noto-color-emoji \
libsecret-1-0 \
pulseaudio \
gnupg2 \
&& curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - \
&& sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/ms-teams stable main" > /etc/apt/sources.list.d/teams.list' \
&& apt-get -y update \
&& apt-get -y install teams
RUN apt-get install -y \
gvfs-bin \
libglib2.0-bin \
trash-cli \
kde-cli-tools \
libatspi2.0-0 \
xdg-utils \
libxtst6 \
libxss1 \
libnss3 \
libnotify4 \
git \
libayatana-appindicator3-1 \
libgtk-3-0 \
libpci-dev \
firefox-esr \
wget \
libgl1 \
mesa-utils \
libgl1-mesa-glx
# Grab the client .deb
# Install the client .deb
COPY docker-scripts/xdg-open /usr/local/bin/
COPY host-scripts/ /var/cache/teams/
COPY docker-scripts/entrypoint.sh /sbin/entrypoint.sh
RUN chmod 755 /sbin/entrypoint.sh
# Cleanup
RUN rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["/sbin/entrypoint.sh"]

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 mdouchement
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

31
Makefile Normal file
View File

@@ -0,0 +1,31 @@
launch:
teams-wrapper teams
teams-wrapper-two teams
kill-containers:
docker kill teams || docker kill teams-two # if error try kill other instance before exit
docker kill teams-two
build:
docker build . -t stifstof/teams-desktop:latest
install:
docker run -it --rm \
--volume /usr/local/bin:/target \
stifstof/teams-desktop:latest install
uninstall:
docker run -it --rm \
--volume /usr/local/bin:/target \
stifstof/teams-desktop:latest uninstall
# convenience jobs
reinstall:
make uninstall
make build
make install
create-empty-config-folders:
mkdir ~/.config/Microsoft
mkdir ~/.config/MicrosoftTwo

95
Old/README.md Normal file
View File

@@ -0,0 +1,95 @@
# Old README
This project is fully inspired of [mdouchement](https://github.com/mdouchement) [zoom.us](https://github.com/gfa01/slack-desktop)'s containerization.
# Introduction
`Dockerfile` to create a [Docker](https://www.docker.com/) container image with [Slack](http://www.slack.com) for Linux with support for audio/video calls.
The image uses [X11](http://www.x.org) and [Pulseaudio](http://www.freedesktop.org/wiki/Software/PulseAudio/) unix domain sockets on the host to enable audio/video support in Slack. These components are available out of the box on pretty much any modern linux distribution.
## Contributing
If you find this image useful here's how you can help:
- Send a pull request with your awesome features and bug fixes
- Help users resolve their [issues](../../issues?q=is%3Aopen+is%3Aissue).
# Getting started
## Installation
Automated builds of the image are available on [Dockerhub](https://hub.docker.com/r/gfa01/slack-desktop) and is the recommended method of installation.
```bash
docker pull gfa01/slack-desktop:latest
```
Alternatively you can build the image yourself.
```bash
docker build -t gfa01/slack-desktop github.com/gfa/docker-slack-desktop
```
With the image locally available, install the wrapper scripts using:
```bash
docker run -it --rm \
--volume /usr/local/bin:/target \
gfa01/slack-desktop:latest install
```
This will install a wrapper script to launch `slack`.
> **Note**
>
> If Slack is installed on the host then the host binary is launched instead of starting a Docker container. To force the launch of Slack in a container use the `slack-desktop-wrapper` script. For example, `slack-desktop-wrapper slack` will launch Slack inside a Docker container regardless of whether it is installed on the host or not.
## How it works
The wrapper scripts volume mount the X11 and pulseaudio sockets in the launcher container. The X11 socket allows for the user interface display on the host, while the pulseaudio socket allows for the audio output to be rendered on the host.
When the image is launched the following directories are mounted as volumes
- `${HOME}/.config/Slack`
- `XDG_DOWNLOAD_DIR` or if it is missing `${HOME}/Downloads`
This makes sure that your profile details are stored on the host and files received via Slack are available on your host in the appropriate download directory.
# Maintenance
## Upgrading
To upgrade to newer releases:
1. Download the updated Docker image:
```bash
docker pull gfa01/slack-desktop:latest
```
2. Run `install` to make sure the host scripts are updated.
```bash
docker run -it --rm \
--volume /usr/local/bin:/target \
gfa01/slack-desktop:latest install
```
## Uninstallation
```bash
docker run -it --rm \
--volume /usr/local/bin:/target \
gfa01/slack-desktop:latest uninstall
```
## Shell Access
For debugging and maintenance purposes you may want access the containers shell. If you are using Docker version `1.3.0` or higher you can access a running containers shell by starting `bash` using `docker exec`:
```bash
docker exec -it slack-desktop bash
```

48
README.md Normal file
View File

@@ -0,0 +1,48 @@
# Microsoft Teams in Docker
This projects objective is to provide Microsoft Teams as a docker image to enable multiple accounts to be used simultaniously.
The Makefile contains the relevant commands to use the application. The project works with two accounts, but can be extended to any number of accounts (not tested).
Teams is not the most stable application, so you can expect to get familiar with the two first commands in the Maefile:
Makefile
- launch
- kill-containers
- install
- uninstall
- build
# 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
You can find the README from the project which this is based on in the folder Old/
## To get up and running
Ensure you have two Microsoft configurations in ~/.config, mine are named Microsoft and MicrosoftTwo
Either use the images i pushed to dockerhub by directly running
```
make install
make launch
```
and two Microsoft Teams applications should appear on your screen.
Do you wish to modify the image, you can change the image name in the scripts in the scripts/ folder.
## Uninstall
Simply run
```
make kill-containers
make uninstall
```
Remmember to kill the containers with

78
docker-scripts/entrypoint.sh Executable file
View File

@@ -0,0 +1,78 @@
#!/bin/bash
set -e
set -x
USER_UID=${USER_UID:-1000}
USER_GID=${USER_GID:-1000}
TEAMS_DESKTOP_USER=cn
install_teams_desktop() {
echo "Installing teams-wrapper..."
install -m 0755 /var/cache/teams/teams-wrapper /target/
install -m 0755 /var/cache/teams/teams-wrapper-two /target/
echo "Installing teams..."
ln -sf teams-wrapper /target/teams
}
uninstall_teams_desktop() {
echo "Uninstalling teams-wrapper..."
rm -rf /target/teams-wrapper
rm -rf /target/teams-wrapper-two
echo "Uninstalling teams..."
rm -rf /target/teams
}
create_user() {
# create group with USER_GID
if ! getent group ${TEAMS_DESKTOP_USER} >/dev/null; then
groupadd -f -g ${USER_GID} ${TEAMS_DESKTOP_USER} >/dev/null 2>&1
fi
# create user with USER_UID
if ! getent passwd ${TEAMS_DESKTOP_USER} >/dev/null; then
adduser --disabled-login --uid ${USER_UID} --gid ${USER_GID} \
--gecos 'Teams' ${TEAMS_DESKTOP_USER} >/dev/null 2>&1
fi
chown ${TEAMS_DESKTOP_USER}:${TEAMS_DESKTOP_USER} -R /home/${TEAMS_DESKTOP_USER}
}
grant_access_to_video_devices() {
for device in /dev/video*; do
if [[ -c $device ]]; then
VIDEO_GID=$(stat -c %g $device)
VIDEO_GROUP=$(stat -c %G $device)
if [[ ${VIDEO_GROUP} == "UNKNOWN" ]]; then
VIDEO_GROUP=teamsvideo
groupadd -g ${VIDEO_GID} ${VIDEO_GROUP}
fi
usermod -a -G ${VIDEO_GROUP} ${TEAMS_DESKTOP_USER}
break
fi
done
}
launch_teams_desktop() {
cd /home/${TEAMS_DESKTOP_USER}
sudo -HEu ${TEAMS_DESKTOP_USER} PULSE_SERVER=/run/pulse/native $@
# exec sudo -HEu ${TEAMS_DESKTOP_USER} PULSE_SERVER=/run/pulse/native QT_GRAPHICSSYSTEM="native" $@
tail -f /home/${TEAMS_DESKTOP_USER}/.config/Microsoft/Microsoft\ Teams/logs/teams-startup.log
}
case "$1" in
install)
install_teams_desktop
;;
uninstall)
uninstall_teams_desktop
;;
teams)
create_user
grant_access_to_video_devices
echo "$1"
launch_teams_desktop $@
;;
*)
exec $@
;;
esac

3
docker-scripts/xdg-open Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
echo "$@" > ~/.xdg.sock

127
host-scripts/teams-wrapper Executable file
View File

@@ -0,0 +1,127 @@
#!/bin/bash
### Application Configuration
SCRIPT_NAME="teams-wrapper"
LOCAL_COMPUTER_USERNAME=$(whoami)
# Docker config
IMAGE_NAME="stifstof/teams-desktop:latest"
CONTAINER_NAME="teams"
CONFIG_PATH="${HOME}/.config/Microsoft"
########## Script
PATH=/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TEAMS_DESKTOP_USER=${LOCAL_COMPUTER_USERNAME}
# do we need to use sudo to start docker containers?
(id -Gn | grep -q docker) || SUDO=sudo
USER_UID=$(id -u)
USER_GID=$(id -g)
XSOCK=/tmp/.X11-unix-teamsOne
XAUTH=/tmp/.docker.xauth-teamsOne
DOWNLOAD_DIR=$(xdg-user-dir DOWNLOAD)
if [ -z "${DOWNLOAD_DIR}" ]; then
DOWNLOAD_DIR="${HOME}/Downloads"
fi
list_commands() {
echo ""
echo "Launch teams using:"
echo " teams OR "
echo " teams-wrapper teams"
echo ""
exit 1
}
cleanup_stopped_teams_desktop_instances() {
echo "Cleaning up stopped teams-desktop instances..."
for c in $(${SUDO} docker ps -a -q); do
image="$(${SUDO} docker inspect -f {{.Config.Image}} ${c})"
if [ "${image}" == ${IMAGE_NAME} ]; then
running=$(${SUDO} docker inspect -f {{.State.Running}} ${c})
if [ "${running}" != "true" ]; then
${SUDO} docker rm "${c}" >/dev/null
fi
fi
done
}
prepare_docker_env_parameters() {
ENV_VARS+=" --env=USER_UID=${USER_UID}"
ENV_VARS+=" --env=USER_GID=${USER_GID}"
ENV_VARS+=" --env=DISPLAY=unix$DISPLAY"
ENV_VARS+=" --env=XAUTHORITY=${XAUTH}"
ENV_VARS+=" --env=TZ=$(date +%Z)"
}
prepare_docker_volume_parameters() {
touch ${XAUTH}
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f ${XAUTH} nmerge -
VOLUMES+=" --volume=${CONFIG_PATH}:/home/${TEAMS_DESKTOP_USER}/.config/Microsoft/"
VOLUMES+=" --volume=${XSOCK}:${XSOCK}"
VOLUMES+=" --volume=${XAUTH}:${XAUTH}"
VOLUMES+=" --volume=/run/user/${USER_UID}/pulse:/run/pulse"
if [ -d "${HOME}/tmp" ]; then
VOLUMES+=" --volume=${HOME}/tmp:/home/${TEAMS_DESKTOP_USER}/tmp"
fi
}
prepare_docker_device_parameters() {
# enumerate video devices for webcam support
VIDEO_DEVICES=
for device in /dev/video*; do
if [ -c $device ]; then
VIDEO_DEVICES="${VIDEO_DEVICES} --device $device:$device"
fi
done
}
prog=$(basename $0)
exec=$(which $prog)
if [[ ${prog} == ${SCRIPT_NAME} ]]; then
case ${1} in
teams)
prog=${1}
shift
;;
* | help)
list_commands
exit 1
;;
esac
elif [[ -n ${exec} ]]; then
# launch host binary if it exists
exec ${exec} $@
fi
cleanup_stopped_teams_desktop_instances
prepare_docker_env_parameters
prepare_docker_volume_parameters
prepare_docker_device_parameters
echo "Starting ${prog}..."
${SUDO} docker run -d \
--name ${CONTAINER_NAME} \
--privileged \
--device /dev/dri \
--device /dev/snd \
--cap-add=SYS_ADMIN \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
${ENV_VARS} \
${VIDEO_DEVICES} \
${VOLUMES} \
${TEAMS_EXTRA_DOCKER_ARGUMENTS} \
${IMAGE_NAME} ${prog} $@ >/dev/null

View File

@@ -0,0 +1,127 @@
#!/bin/bash
### Application Configuration
SCRIPT_NAME="teams-wrapper-two"
LOCAL_COMPUTER_USERNAME=$(whoami)
# Docker config
IMAGE_NAME="stifstof/teams-desktop:latest"
CONTAINER_NAME="teams-two"
CONFIG_PATH="${HOME}/.config/MicrosoftTwo"
########## Script
PATH=/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TEAMS_DESKTOP_USER=${LOCAL_COMPUTER_USERNAME}
# do we need to use sudo to start docker containers?
(id -Gn | grep -q docker) || SUDO=sudo
USER_UID=$(id -u)
USER_GID=$(id -g)
XSOCK=/tmp/.X11-unix-teamsTwo
XAUTH=/tmp/.docker.xauth-teamsTwo
DOWNLOAD_DIR=$(xdg-user-dir DOWNLOAD)
if [ -z "${DOWNLOAD_DIR}" ]; then
DOWNLOAD_DIR="${HOME}/Downloads"
fi
list_commands() {
echo ""
echo "Launch teams using:"
echo " teams OR "
echo " teams-wrapper teams"
echo ""
exit 1
}
cleanup_stopped_teams_desktop_instances() {
echo "Cleaning up stopped teams-desktop instances..."
for c in $(${SUDO} docker ps -a -q); do
image="$(${SUDO} docker inspect -f {{.Config.Image}} ${c})"
if [ "${image}" == ${IMAGE_NAME} ]; then
running=$(${SUDO} docker inspect -f {{.State.Running}} ${c})
if [ "${running}" != "true" ]; then
${SUDO} docker rm "${c}" >/dev/null
fi
fi
done
}
prepare_docker_env_parameters() {
ENV_VARS+=" --env=USER_UID=${USER_UID}"
ENV_VARS+=" --env=USER_GID=${USER_GID}"
ENV_VARS+=" --env=DISPLAY=unix$DISPLAY"
ENV_VARS+=" --env=XAUTHORITY=${XAUTH}"
ENV_VARS+=" --env=TZ=$(date +%Z)"
}
prepare_docker_volume_parameters() {
touch ${XAUTH}
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f ${XAUTH} nmerge -
VOLUMES+=" --volume=${CONFIG_PATH}:/home/${TEAMS_DESKTOP_USER}/.config/Microsoft/"
VOLUMES+=" --volume=${XSOCK}:${XSOCK}"
VOLUMES+=" --volume=${XAUTH}:${XAUTH}"
VOLUMES+=" --volume=/run/user/${USER_UID}/pulse:/run/pulse"
if [ -d "${HOME}/tmp" ]; then
VOLUMES+=" --volume=${HOME}/tmp:/home/${TEAMS_DESKTOP_USER}/tmp"
fi
}
prepare_docker_device_parameters() {
# enumerate video devices for webcam support
VIDEO_DEVICES=
for device in /dev/video*; do
if [ -c $device ]; then
VIDEO_DEVICES="${VIDEO_DEVICES} --device $device:$device"
fi
done
}
prog=$(basename $0)
exec=$(which $prog)
if [[ ${prog} == ${SCRIPT_NAME} ]]; then
case ${1} in
teams)
prog=${1}
shift
;;
* | help)
list_commands
exit 1
;;
esac
elif [[ -n ${exec} ]]; then
# launch host binary if it exists
exec ${exec} $@
fi
cleanup_stopped_teams_desktop_instances
prepare_docker_env_parameters
prepare_docker_volume_parameters
prepare_docker_device_parameters
echo "Starting ${prog}..."
${SUDO} docker run -d \
--name ${CONTAINER_NAME} \
--privileged \
--device /dev/dri \
--device /dev/snd \
--cap-add=SYS_ADMIN \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
${ENV_VARS} \
${VIDEO_DEVICES} \
${VOLUMES} \
${TEAMS_EXTRA_DOCKER_ARGUMENTS} \
${IMAGE_NAME} ${prog} $@ >/dev/null