-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kaj
committed
Feb 2, 2019
0 parents
commit bf950ea
Showing
7 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM ubuntu:18.04 | ||
MAINTAINER Guy Taylor <thebigguy.co.uk@gmail.com> | ||
|
||
RUN apt-get update && apt-get install --yes gnupg ca-certificates lsb-release apt-transport-https | ||
|
||
RUN echo "deb https://debian.snips.ai/$(lsb_release -cs) stable main" > /etc/apt/sources.list.d/snips.list \ | ||
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F727C778CCB0A455 \ | ||
&& apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install --yes sudo unzip systemd pulseaudio-utils openssh-server alsa-utils nano curl unzip python-pip git snips-platform-voice snips-tts snips-template snips-skill-server snips-watch | ||
|
||
RUN echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config | ||
|
||
RUN echo "root:snips" | chpasswd | ||
|
||
COPY pulse-client.conf /etc/pulse/client.conf | ||
COPY run.sh /run.sh | ||
|
||
RUN chmod +x /run.sh | ||
|
||
# run | ||
CMD ["/bin/bash","-l","-c","sh /run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
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 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. | ||
|
||
For more information, please refer to <http://unlicense.org/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Docker PulseAudio Example | ||
Snips in a docker container with audio via PulseAudio. This is based on [docker-pulseaudio-example](https://github.com/TheBiggerGuy/docker-pulseaudio-example) and [snips-docker](https://github.com/dYalib/snips-docker). Since this is using PulseAudio, be sure that you have a running configuration. | ||
|
||
## Dangers! | ||
This docker container is running a full fledged SSH server (OpenSSH) in order to work with `sam`. Also it works `priviledged` meaning it has wide access to your system. Also it is big. Both facts are reasons, why I won't make this container availabe on docker hub. ONLY use this container for testing! | ||
|
||
## Building | ||
```bash | ||
./buid_image.sh | ||
``` | ||
|
||
## Running | ||
```bash | ||
./run.sh | ||
``` | ||
|
||
## Snips explanation | ||
This is meant to simulate a Snips setup which can be addressed by `sam`. After building and running the container, it will show up when `sam devices` is run (the magic lies in the mac address of the container). You can then connect to it by running `sam connect IP-GOES-HERE` (user: root, password: snips) and init it by running `sam init`. Once inited setup the audio using `sam setup audio`. Then login to the console using `sam login` and install your assistant by running `sam install assistant -i ID-GOES-HERE`. Use `sam watch` to watch Snips. | ||
|
||
## PulseAudio explanation | ||
Getting a PulseAudio app to work within a Docker container is harder than it looks. This example is designed to produce the smallest working configuration that can be used in your own containers. | ||
|
||
To be clear this is designed so the app within the Docker container does not run a PulseAudio server. Instead the app connects as a client directly to the hosts PulseAudio server and uses it's configuration/devices to output the sound. This is achieved by mapping the UNIX socket used by PulseAudio in the host into the container and configuring its use. | ||
|
||
BE AWARE: Since this is using the PulseAudio config of the root user (UID 0), this can still mess with your setup. If you do not want to use the PulseAudio daemon of the root user, change line 3 in `run_docker.sh` from `0` to `1000`. | ||
|
||
If you are using to root user in order to get it to work, you need to start the PulseAudio daemon (`sudo pulseaudio -D --system`). | ||
|
||
If you have troubles with sound, try deleting the `/root/.pulse` folder. | ||
|
||
## Contributing | ||
Feel free to fork this repository and submit PRs. Happy to work on them (in the end one good running setup is better than many barely running ones) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker build --tag 'snips-docker-audio:latest' . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Connect to the host's server using the mounted UNIX socket | ||
default-server = unix:/run/user/1000/pulse/native | ||
|
||
# Prevent a server running in the container | ||
autospawn = no | ||
daemon-binary = /bin/true | ||
|
||
# Prevent the use of shared memory | ||
enable-shm = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exec /sbin/init | ||
service ssh start | ||
sleep infinity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
docker run -d \ | ||
-v /dev/shm:/dev/shm \ | ||
-v /run/user/0/pulse:/run/user/1000/pulse \ | ||
-v /var/lib/dbus:/var/lib/dbus \ | ||
-v ~/.pulse:/home/root/.pulse \ | ||
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \ | ||
--privileged \ | ||
--mac-address b8:27:eb:ae:87:c6 \ | ||
snips-docker-audio |