Compare commits

...

6 commits

Author SHA1 Message Date
b66ebe24fa Update docker compose usage 2025-04-21 17:38:47 +02:00
bd22ed218d Use correct prefix 2025-04-21 17:34:54 +02:00
afcda2a9e5 Remove image definition
This causes issues with other compose projects as the build container will use the image tag
2025-04-21 17:34:30 +02:00
cd32757a4f Remove unused handlers 2025-04-21 17:33:26 +02:00
c08670a8ba Use CMD directive for transmission 2025-04-21 17:33:01 +02:00
4259710626 Add MPD docker setup 2025-04-21 17:32:24 +02:00
15 changed files with 193 additions and 97 deletions

View file

@ -15,7 +15,7 @@ WORKDIR /app
VOLUME ["/app/config", "/app/downloads", "/app/incomplete_downloads"]
ENTRYPOINT /usr/bin/transmission-daemon \
CMD /usr/bin/transmission-daemon \
--config-dir /app/config \
--log-level info \
--foreground \

View file

@ -23,28 +23,6 @@
state: restarted
enabled: true
- name: restart radicale service
become: true
systemd:
name: radicale
state: restarted
enabled: true
daemon_reload: true
- name: restart syncthing service
become: true
systemd:
name: syncthing@sonny.service
state: restarted
enabled: true
- name: restart mpd service
become: true
systemd:
name: mpd
state: restarted
enabled: true
- name: restart certbot
become: true
systemd:

View file

@ -54,11 +54,13 @@
community.docker.docker_compose_v2:
project_src: '{{ jellyfin_app_dir }}'
pull: missing
state: stopped
- name: Remove dangling containers
community.docker.docker_compose_v2:
project_src: '{{ jellyfin_app_dir }}'
remove_orphans: true
state: stopped
- name: Start jellyfin
community.docker.docker_compose_v2:

View file

@ -1,71 +1,106 @@
# TODO: use docker setup
- name: create mpd directories
- name: Stop systemd mpd service
become: true
file:
ansible.builtin.systemd:
name: mpd
state: stopped
enabled: false
- name: Stop systemd mpd socket
become: true
ansible.builtin.systemd:
name: mpd.socket
state: stopped
enabled: false
- name: Remove previous configurations
become: true
ansible.builtin.file:
path: '{{ item.path }}'
state: absent
loop:
- path: '/etc/systemd/system/mpd.service.d'
- path: '/etc/systemd/system/mpd.socket.d'
- name: Create mpd directories
become: true
ansible.builtin.file:
path: '{{ item.path }}'
mode: '{{ item.mode }}'
owner: '{{ item.owner }}'
group: '{{ item.group }}'
mode: '0755'
state: directory
loop:
- {
path: '{{ ansible_env.HOME }}/.config/mpd',
mode: 755,
owner: 'sonny',
group: 'sonny',
}
- {
path: '/etc/systemd/system/mpd.service.d',
mode: 755,
owner: 'root',
group: 'root',
}
- {
path: '/etc/systemd/system/mpd.socket.d',
mode: 755,
owner: 'root',
group: 'root',
}
notify: restart mpd service
- path: '{{ mpd_config_dir }}'
owner: sonny
group: sonny
- name: copy mpd templates
- path: '{{ mpd_playlist_dir }}'
owner: sonny
group: sonny
- path: '{{ mpd_state_dir }}'
owner: sonny
group: sonny
- path: '{{ mpd_app_dir }}'
owner: root
group: root
- name: Copy mpd templates
become: true
template:
ansible.builtin.template:
src: '{{ item.src }}'
dest: '{{ item.dest }}'
mode: '{{ item.mode }}'
owner: '{{ item.owner }}'
group: '{{ item.group }}'
loop:
- {
src: 'templates/systemd/mpd/service.j2',
dest: '/etc/systemd/system/mpd.service.d/override.conf',
mode: 755,
owner: 'root',
group: 'root',
}
- {
src: 'templates/systemd/mpd/socket.j2',
dest: '/etc/systemd/system/mpd.socket.d/override.conf',
mode: 755,
owner: 'root',
group: 'root',
}
- {
src: 'templates/mpd.j2',
dest: '{{ ansible_env.HOME }}/.config/mpd/mpd.conf',
mode: 0640,
owner: 'sonny',
group: 'sonny',
}
notify: restart mpd service
- src: templates/mpd/config.j2
dest: '{{ mpd_config_dir }}/mpd.conf'
mode: '0640'
owner: sonny
group: sonny
- name: created mpd files
file:
- src: templates/mpd/dockerfile.j2
dest: '{{ mpd_app_dir }}/Dockerfile'
mode: '0755'
owner: sonny
group: sonny
- src: templates/mpd/docker-compose.j2
dest: '{{ mpd_app_dir }}/docker-compose.yml'
mode: '0755'
owner: sonny
group: sonny
- name: Create mpd files
ansible.builtin.file:
path: '{{ item }}'
mode: '0755'
state: touch
loop:
- '{{ ansible_env.HOME }}/.config/mpd/db'
- '{{ ansible_env.HOME }}/.config/mpd/state'
- '{{ ansible_env.HOME }}/.config/mpd/sticker.sql'
notify: restart mpd service
- '{{ mpd_config_dir }}/db'
- '{{ mpd_config_dir }}/sticker.sql'
- '{{ mpd_state_dir }}/state'
- name: Stop current containers
community.docker.docker_compose_v2:
project_src: '{{ mpd_app_dir }}'
state: stopped
- name: Build image
community.docker.docker_compose_v2:
project_src: '{{ mpd_app_dir }}'
build: always
state: stopped
- name: Remove dangling containers
community.docker.docker_compose_v2:
project_src: '{{ mpd_app_dir }}'
remove_orphans: true
state: stopped
- name: Start container
community.docker.docker_compose_v2:
project_src: '{{ mpd_app_dir }}'
state: present

View file

@ -102,9 +102,24 @@
group: sonny
mode: '0755'
- name: Start container
- name: Stop current containers
community.docker.docker_compose_v2:
project_src: '{{ radicale_app_dir }}'
state: stopped
- name: Pull missing image
community.docker.docker_compose_v2:
project_src: '{{ radicale_app_dir }}'
build: always
state: stopped
- name: Remove dangling containers
community.docker.docker_compose_v2:
project_src: '{{ radicale_app_dir }}'
remove_orphans: true
state: stopped
- name: Start container
community.docker.docker_compose_v2:
project_src: '{{ radicale_app_dir }}'
state: present
build: always

View file

@ -66,11 +66,13 @@
community.docker.docker_compose_v2:
project_src: '{{ syncthing_app_dir }}'
pull: missing
state: stopped
- name: Remove dangling containers
community.docker.docker_compose_v2:
project_src: '{{ syncthing_app_dir }}'
remove_orphans: true
state: stopped
- name: Start container
community.docker.docker_compose_v2:

View file

@ -1,5 +1,3 @@
# {{ ansible_managed }}
#
# An example configuration file for MPD.
# Read the user manual for documentation: http://www.musicpd.org/doc/user/
# or /usr/share/doc/mpd/user-manual.html
@ -13,7 +11,15 @@
# be disabled and audio files will only be accepted over ipc socket (using
# file:// protocol) or streaming files over an accepted protocol.
#
music_directory "{{ mpd_music_dir }}"
music_directory "/app/music"
#
# This setting sets the MPD internal playlist directory. The purpose of this
# directory is storage for playlists created by MPD. The server will use
# playlist files not created by the server but only if they are in the MPD
# format. This setting defaults to playlist saving being disabled.
#
playlist_directory "/app/playlists"
#
# This setting sets the location of the MPD database. This file is used to
@ -22,8 +28,7 @@ music_directory "{{ mpd_music_dir }}"
# MPD to accept files over ipc socket (using file:// protocol) or streaming
# files over an accepted protocol.
#
# TODO: use variable for this, usable for task and this configuration
db_file "/home/sonny/.config/mpd/db"
db_file "/app/config/db"
#
# These settings are the locations for the daemon log files for the daemon.
@ -33,14 +38,12 @@ db_file "/home/sonny/.config/mpd/db"
log_level "secure"
#
# TODO: use variable for this, usable for task and this configuration
state_file "/home/sonny/.config/mpd/state"
state_file "/app/state/state"
#
# The location of the sticker database. This is a database which
# manages dynamic information attached to songs.
#
# TODO: use variable for this, usable for task and this configuration
sticker_file "/home/sonny/.config/mpd/sticker.sql"
sticker_file "/app/config/sticker.sql"
#
###############################################################################
@ -52,7 +55,7 @@ sticker_file "/home/sonny/.config/mpd/sticker.sql"
# initialization. This setting is disabled by default and MPD is run as the
# current user.
#
user "sonny"
# user "mpd"
#
# This setting sets the address for the daemon to listen on. Careful attention
@ -62,7 +65,7 @@ user "sonny"
# activation is in use.
#
# For network
bind_to_address "{{ vpn_listen_address }}"
bind_to_address "0.0.0.0"
#
# This setting is the TCP port that is desired for the daemon to get assigned
@ -97,7 +100,7 @@ audio_output {
name "HTTP high quality stream"
encoder "opus"
port "{{ mpd_http_stream_port }}"
bind_to_address "{{ vpn_listen_address }}"
bind_to_address "0.0.0.0"
bitrate "128000"
format "192000:24:2"
always_on "yes"
@ -110,7 +113,7 @@ audio_output {
name "HTTP mobile stream"
encoder "opus"
port "{{ mpd_http_mobile_stream_port }}"
bind_to_address "{{ vpn_listen_address }}"
bind_to_address "0.0.0.0"
bitrate "96000"
format "44100:16:2"
always_on "yes"
@ -118,7 +121,6 @@ audio_output {
max_clients "1"
}
#
# Character Encoding ##########################################################
#

View file

@ -0,0 +1,22 @@
# {{ ansible_managed }}
networks:
mpd-net:
ipam:
config:
- subnet: '{{ mpd_subnet }}'
services:
mpd:
build:
context: .
dockerfile: Dockerfile
volumes:
- {{ mpd_config_dir }}:/app/config
- {{ mpd_state_dir }}:/app/state
- {{ mpd_playlist_dir }}:/app/playlists
- {{ mpd_music_dir }}:/app/music
restart: always
networks:
mpd-net:
ipv4_address: '{{ mpd_app_ip }}'

View file

@ -0,0 +1,25 @@
# {{ ansible_managed }}
FROM alpine:latest
RUN apk --no-cache add \
mpd; \
RUN useradd \
--uid 1000 \
--guid 1000 \
--groups mpd \
--shell /sbin/nologin \
--no-create-home \
--no-user-group \
sonny
USER sonny
WORKDIR /app
RUN mkdir /app/config /app/state /app/playlists
EXPOSE {{ mpd_port }}/tcp {{ mpd_http_stream_port }}/tcp {{ mpd_http_mobile_stream_port }}/tcp
CMD ["/usr/bin/mpd", "--no-daemon", "--stdout", "/app/config/mpd.conf"]

View file

@ -9,3 +9,4 @@
{{ syncthing_nginx_ip }} {{ syncthing_domain }}
{{ radicale_nginx_ip }} {{ radicale_domain }}
{{ jellyfin_nginx_ip }} {{ jellyfin_domain }}
{{ mpd_app_ip }} {{ mpd_domain }}

View file

@ -61,9 +61,9 @@ table ip filter {
tcp dport 80 ip saddr {{ vpn_subnet }} ip daddr {{ radicale_nginx_ip }} accept comment "Radicale"
tcp dport {{ mpd_port }} ip saddr . ip daddr @vpn_set accept comment "MPD"
tcp dport {{ mpd_http_stream_port }} ip saddr . ip daddr @vpn_set accept comment "MPD HTTP stream"
tcp dport {{ mpd_http_mobile_stream_port }} ip saddr . ip daddr @vpn_set accept comment "MPD HTTP mobile stream"
tcp dport {{ mpd_port }} ip saddr {{ vpn_subnet }} ip daddr {{ mpd_app_ip }} accept comment "MPD"
tcp dport {{ mpd_http_stream_port }} ip saddr {{ vpn_subnet }} ip daddr {{ mpd_app_ip }} accept comment "MPD HTTP stream"
tcp dport {{ mpd_http_mobile_stream_port }} ip saddr {{ vpn_subnet }} ip daddr {{ mpd_app_ip }} accept comment "MPD HTTP mobile stream"
}
set vpn_media_set {
@ -83,6 +83,7 @@ table ip filter {
iifname {{ vpn_interface }} ip saddr {{ vpn_subnet }} ip daddr {{ transmission_nginx_ip }} accept
iifname {{ vpn_interface }} ip saddr {{ vpn_subnet }} ip daddr {{ syncthing_nginx_ip }} accept
iifname {{ vpn_interface }} ip saddr {{ vpn_subnet }} ip daddr {{ radicale_nginx_ip }} accept
iifname {{ vpn_interface }} ip saddr {{ vpn_subnet }} ip daddr {{ mpd_app_ip }} accept
iifname {{ vpn_media_interface }} ip saddr {{ vpn_media_subnet }} ip daddr {{ jellyfin_nginx_ip }} accept
}

View file

@ -8,7 +8,6 @@ networks:
services:
transmission:
image: alpine:latest
build:
context: .
dockerfile: Dockerfile

View file

@ -15,3 +15,7 @@ packages:
vpn_config_dir: '/etc/wireguard'
hostname: 'fudiggity'
xdg_config_dir: '/home/sonny/.config'
xdg_data_dir: '/home/sonny/.local/share'
xdg_state_dir: '/home/sonny/.local/state'

View file

@ -1 +1,6 @@
mpd_app_dir: '/srv/docker/mpd'
mpd_music_dir: '/home/sonny/music'
mpd_config_dir: '{{ xdg_config_dir }}/mpd'
mpd_playlist_dir: '{{ xdg_data_dir }}/mpd/playlists'
mpd_state_dir: '{{ xdg_state_dir }}/mpd'

View file

@ -25,9 +25,14 @@ vpn_media_port: 51903
vpn_media_interface: 'wg1'
vpn_media_domain: 'media-vpn.{{ domain_name }}'
mpd_domain: 'mpd.{{ domain_name }}'
mpd_listen_address: '0.0.0.0'
mpd_prefix: 24
mpd_subnet: '172.128.238.0/{{ mpd_prefix }}'
mpd_port: 21000
mpd_http_stream_port: 8000
mpd_http_mobile_stream_port: 8001
mpd_app_ip: '172.128.238.10'
forgejo_ip: '127.0.0.1'
forgejo_port: 3000
@ -71,6 +76,6 @@ transmission_nginx_ip: '172.16.238.10'
jellyfin_domain: 'jellyfin.{{ domain_name }}'
jellyfin_prefix: 24
jellyfin_subnet: '172.8.238.0/{{ transmission_prefix }}'
jellyfin_subnet: '172.8.238.0/{{ jellyfin_prefix }}'
jellyfin_web_port: 8096
jellyfin_nginx_ip: '172.8.238.10'