Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Dockerize project #2

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker-compose.yml
Dockerfile
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ indent_size = 4

[*.rs]
indent_size = 2

[*.yml]
indent_size = 2
indent_style = space
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM rust:1.76-bookworm

RUN \
apt update && \
apt install -y pulseaudio && \
apt-get clean autoclean && \
rm -rf /var/lib/{apt,dpkg,cache,log}/ && \
mkdir /app && chown 1000:1000 /app

WORKDIR /app
USER 1000

COPY --chown=1000:1000 . /app

RUN cargo install --path .

ENTRYPOINT ["/app/target/release/scope-tui"]
CMD ["pulse"]
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ The audio buffer size directly impacts resource usage, latency and refresh rate

To change audio buffer size, the PulseAudio client must be restarted. Because of this, such option is configurable only at startup.

## Docker Compose

Included is a simple `Dockerfile` to build the project, and an accompanying `docker-compose.yml` to orchestrate starting the container with the proper volume mounts and environment variables.

Also included is a helper shell script to launch the container, attach to the container instance, and destroy the container on exiting.

```sh
docker compose up -d
docker attach scope_tui
docker compose down

# OR

./docker_start.sh
```

## Controls
* Use `q` or `CTRL+C` to exit
* Use `s` to toggle scatter mode
Expand Down Expand Up @@ -104,6 +120,7 @@ Some features I plan to work on and would like to add:
* [x] Multiple channels
* [x] Spectroscope
* [x] File source
* [x] Dockerize
* [ ] Mac audio sources
* [ ] Windows audio sources
* [ ] Improve file audio source
Expand Down
7 changes: 7 additions & 0 deletions compose_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

docker compose up -d

docker attach scope_tui

docker compose down
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3.8"

services:
scope_tui:
container_name: scope_tui
# command: ["--scatter", "pulse"] # Example of customizing options
image: scope_tui
build: .
stdin_open: true
tty: true
environment:
- PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native
volumes:
- ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native
- ~/.config/pulse/cookie:/.config/pulse/cookie
4 changes: 4 additions & 0 deletions docker_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

docker build -t scope_tui:latest . &&
docker run --rm -it --name scope_tui -e "PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native" -v "${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native" -v "$HOME/.config/pulse/cookie:/.config/pulse/cookie" scope_tui