Skip to content

Commit

Permalink
Update install script, rename directories, update dependencies (#261)
Browse files Browse the repository at this point in the history
Maintenance PR:

- updates the installation script, removing a redundant prompt and
allowing users to optionally disable/enable the reverse proxy
- reorganizes repository so source code is now under `src/` instead of
`cadence/`, which was confusing before
- updates Go dependencies

Behind this PR, the
[Installation](https://github.com/kenellorando/cadence/wiki/Installation)
wiki document has been updated, and a new
[Troubleshooting](https://github.com/kenellorando/cadence/wiki/Troubleshooting)
page containing observed errors and suggested fixes has been created.
  • Loading branch information
kenellorando authored May 8, 2024
2 parents 598a4be + 76b09be commit eca4f37
Show file tree
Hide file tree
Showing 29 changed files with 104 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: cadence/server/
working-directory: src/server/
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ build-init:
docker buildx create --platform linux/arm/v7,linux/amd64 --use --name multiarch

build-cadence:
docker buildx build --push --platform linux/arm/v7,linux/amd64 --tag kenellorando/cadence:latest --tag kenellorando/cadence:$(VERSION) --file ./cadence/cadence.Dockerfile ./cadence/
docker buildx build --push --platform linux/arm/v7,linux/amd64 --tag kenellorando/cadence:latest --tag kenellorando/cadence:$(VERSION) --file ./src/cadence.Dockerfile ./src/

build-cadence_icecast2:
docker buildx build --push --platform linux/arm/v7,linux/amd64 --tag kenellorando/cadence_icecast2:latest --tag kenellorando/cadence_icecast2:$(VERSION) --file ./cadence/icecast2.Dockerfile ./cadence/
docker buildx build --push --platform linux/arm/v7,linux/amd64 --tag kenellorando/cadence_icecast2:latest --tag kenellorando/cadence_icecast2:$(VERSION) --file ./src/icecast2.Dockerfile ./src/

build-cadence_liquidsoap:
docker buildx build --push --platform linux/arm/v7,linux/amd64 --tag kenellorando/cadence_liquidsoap:latest --tag kenellorando/cadence_liquidsoap:$(VERSION) --file ./cadence/liquidsoap.Dockerfile ./cadence/
docker buildx build --push --platform linux/arm/v7,linux/amd64 --tag kenellorando/cadence_liquidsoap:latest --tag kenellorando/cadence_liquidsoap:$(VERSION) --file ./src/liquidsoap.Dockerfile ./src/

build-all: build-cadence build-cadence_icecast2 build-cadence_liquidsoap
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

**Cadence** (or *CadenceRadio*) is an all-in-one internet radio suite.

The project ships with *Icecast* and *Liquidsoap* working out-of-the-box, made complete with a *Cadence API* providing library search, song request, album artwork, and real-time stream information in a browser UI. Install and deploy in minutes.
The project ships *Icecast* and *Liquidsoap* working out-of-the-box, made complete by a *Cadence API* providing song request, library search, album artwork, and real-time stream information in a browser UI.

**See a live demo on [cadenceradio.com](https://cadenceradio.com/)!**

<img src="https://user-images.githubusercontent.com/17265041/219263637-6971ce33-209a-4eb5-b67e-547f271dc3c8.png" width="600" >

## 🏃 Get Started

An interactive installation script is provided. Users familiar with Docker can be up and running in ~5 minutes. Alternate installation methods, including manual configuration and Kubernetes deployments, are respectively described on the [Installation Guide](https://github.com/kenellorando/cadence/wiki/Installation) and in [cadence-k8s](https://github.com/kenellorando/cadence-k8s).
An interactive installation script is provided. Users familiar with Docker can be up and running in ~5 minutes.

### Server Preparation

Expand All @@ -26,9 +26,11 @@ $ chmod +x ./install.sh
$ ./install.sh
```

You will be prompted to provide the absolute path to a directory containing your music, a stream hostname, a rate limit timeout, a service password, and optional DNS. If you need help figuring out what values to use, refer to the [Installation Guide](https://github.com/kenellorando/cadence/wiki/Installation#interactive-prompt-guide). Your radio stack will automatically launch and Cadence's web UI will become accessible at `localhost:8080`.
You will be prompted to provide an absolute path to a directory containing music, a stream hostname, a rate limit timeout, a service password, and optional reverse proxy configuration. If you need help figuring out what values to use, refer to the [Installation Guide](https://github.com/kenellorando/cadence/wiki/Installation#interactive-prompt-guide).

After initial installation, simply run `docker compose pull` to check for container updates, then `docker compose up` to start your station again. Run `./install.sh` again at any time to reconfigure. If you make your own changes locally to Cadence's code, run `docker compose up --build` to build and run.
Your radio stack will automatically launch and Cadence's web UI will become accessible at `localhost:8080`.

After initial installation, simply run `docker compose pull` to check for container updates, then `docker compose up` to start your station again. Run `./install.sh` again at any time to reconfigure. If you make changes to code locally, run `docker compose up --build` to build and run.

## 🔬 Technical Details

Expand All @@ -40,7 +42,7 @@ After initial installation, simply run `docker compose pull` to check for contai

</details>

If you're interested in implementation details, [Cadence: Self-Hosted Web Radio Suite](https://kenellorando.notion.site/Cadence-Self-Hosted-Web-Radio-Suite-d1f0184b5eeb4882a3d6f78d582b2de6) does a dive into how a typical *Icecast/Liquidsoap* web radio works and the value Cadence provides.
If you're interested in implementation details, [this blog post](https://cuddle.fish/posts/2022-11-08-cadence) does a dive into how a basic *Icecast/Liquidsoap* web radio works and the value Cadence provides.

### API Reference for Custom Clients
Cadence's GitHub Wiki also hosts an [API Reference](https://github.com/kenellorando/cadence/wiki/API-Reference) with complete request/response details, useful for anyone developing custom scripts or clients for their station.
Expand Down
19 changes: 0 additions & 19 deletions cadence/server/go.mod

This file was deleted.

26 changes: 0 additions & 26 deletions cadence/server/go.sum

This file was deleted.

2 changes: 1 addition & 1 deletion config/cadence.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ POSTGRES_PASSWORD=CADENCE_PASS_EXAMPLE

# Development
CSERVER_DEVMODE=0
CSERVER_VERSION=5.4.3
CSERVER_VERSION=5.4.4
CSERVER_ROOTPATH=/cadence/server/

# Service Addresses
Expand Down
2 changes: 1 addition & 1 deletion config/icecast.xml.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<admin-password>CADENCE_PASS_EXAMPLE</admin-password>
</authentication>

<hostname>CADENCE_HOST_EXAMPLE</hostname>
<hostname>CADENCE_STREAM_HOST_EXAMPLE</hostname>

<listen-socket>
<port>8000</port>
Expand Down
4 changes: 2 additions & 2 deletions config/nginx.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ http {
# This server forwards requests to the Icecast service.
server {
listen 80;
server_name CADENCE_STREAM_DNS_EXAMPLE;
server_name CADENCE_STREAM_HOST_EXAMPLE;
access_log off;
location / {
proxy_pass http://icecast2:8000/;
Expand All @@ -16,7 +16,7 @@ http {
# This server forwards requests to the API/UI server.
server {
listen 80;
server_name CADENCE_WEB_DNS_EXAMPLE;
server_name CADENCE_WEB_HOST_EXAMPLE;
access_log off;
# Server-sent event API needs special configuration to get through the proxy.
location /api/radiodata/sse {
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:

redis:
Expand All @@ -21,7 +20,7 @@ services:

icecast2:
build:
dockerfile: ./cadence/icecast2.Dockerfile
dockerfile: ./src/icecast2.Dockerfile
image: kenellorando/cadence_icecast2:latest
container_name: icecast2
restart: always
Expand All @@ -35,13 +34,13 @@ services:

liquidsoap:
build:
dockerfile: ./cadence/liquidsoap.Dockerfile
dockerfile: ./src/liquidsoap.Dockerfile
image: kenellorando/cadence_liquidsoap:latest
container_name: liquidsoap
restart: always
volumes:
- ./config/liquidsoap.liq:/etc/liquidsoap/cadence.liq
- /music:/music
- /music/:/music/
depends_on:
- icecast2
expose:
Expand All @@ -52,7 +51,7 @@ services:

cadence:
build:
context: ./cadence
context: ./src/
dockerfile: ./cadence.Dockerfile
image: kenellorando/cadence
container_name: cadence
Expand All @@ -62,7 +61,7 @@ services:
env_file:
- ./config/cadence.env
volumes:
- /music:/music
- /music/:/music/
depends_on:
- icecast2
- liquidsoap
Expand All @@ -73,6 +72,7 @@ services:
external_services:

nginx:
profiles: ["nginx"]
image: nginx:latest
volumes:
- ./config/nginx.conf:/etc/nginx/nginx.conf
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:

redis:
Expand All @@ -21,7 +20,7 @@ services:

icecast2:
build:
dockerfile: ./cadence/icecast2.Dockerfile
dockerfile: ./src/icecast2.Dockerfile
image: kenellorando/cadence_icecast2:latest
container_name: icecast2
restart: always
Expand All @@ -35,7 +34,7 @@ services:

liquidsoap:
build:
dockerfile: ./cadence/liquidsoap.Dockerfile
dockerfile: ./src/liquidsoap.Dockerfile
image: kenellorando/cadence_liquidsoap:latest
container_name: liquidsoap
restart: always
Expand All @@ -52,7 +51,7 @@ services:

cadence:
build:
context: ./cadence
context: ./src/
dockerfile: ./cadence.Dockerfile
image: kenellorando/cadence
container_name: cadence
Expand All @@ -73,6 +72,7 @@ services:
external_services:

nginx:
profiles: ["nginx"]
image: nginx:latest
volumes:
- ./config/nginx.conf:/etc/nginx/nginx.conf
Expand Down
71 changes: 37 additions & 34 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
#!/bin/bash

echo "[1/5] Music Directory Target"
echo "Set the absolute path of a directory containing audio files (e.g. mp3, flac)"
echo "meant for radio play. Only files at the directory base will be seen, not those"
echo "in nested subdirectories."
echo "Example: /music/"
echo "***************************************************************"
echo "NOTE: If you need help determining configuration values to use,"
echo "installation documentation is available on GitHub:"
echo "https://github.com/kenellorando/cadence/wiki/Installation"
echo "***************************************************************"
echo ""
echo "[1/5] Absolute Path to Music"
echo "Set an absolute path to a directory containing audio files (e.g. mp3, flac)"
echo "to be played on the radio. The target is not recursively searched."
read -p " Music path: " CADENCE_PATH
echo "================================================================================"
echo ""
echo "[2/5] Stream Host Address"
echo "Set the stream host address for Cadence Icecast. This may be a DNS name, public"
echo "IP, or private IP. Set this to localhost:8000 if your Cadence instance is meant"
echo "for local use only."
echo "Example: localhost:8000"
read -p " Stream address: " CADENCE_HOST
echo "================================================================================"
echo "Set the stream host address. This may be a DNS name, public IP, or private IP."
echo "Use localhost:8000 if your Cadence instance is meant for local use only."
read -p " Stream address: " CADENCE_STREAM_HOST
echo ""
echo "[3/5] Rate Limiter Timeout"
echo "Set a rate limit timeout in integer seconds. This prevents the same listener"
echo "from requesting songs within the configured timeframe. Set to 0 to disable."
echo "Example: 180"
read -p " Rate limit: " CADENCE_RATE
echo "================================================================================"
echo ""
echo "[4/5] Radio Service Password"
echo "Set a secure, unique service password. Input is hidden."
read -s -p " Password: " CADENCE_PASS
echo ""
echo "================================================================================"
echo "[5/5] Domain Names - LEAVE BLANK TO SKIP"
echo "OPTIONAL: if you are an advanced administrator routing DNS to your Cadence"
echo "stack, provide your domain names here. You will be prompted for two domains: one"
echo "for Cadence Icecast, one for Cadence web UI. Subdomains are acceptable."
read -p " Cadence Audio Stream Domain: " CADENCE_STREAM_DNS
read -p " Cadence Web UI Domain: " CADENCE_WEB_DNS

if [ -z "$CADENCE_STREAM_DNS" ]
then
CADENCE_STREAM_DNS=stream.cadenceradio.com
fi
echo ""
echo "[5/5] Enable Reverse Proxy?"
echo "Do you want to enable a reverse proxy? Skip if you are broadcasting locally only"
echo "or have your own reverse proxy configured. Skip if you do not know what this means."
read -p " [y/N]: " ENABLE_REVERSE_PROXY

if [ -z "$CADENCE_WEB_DNS" ]
if [[ "$ENABLE_REVERSE_PROXY" =~ ^([yY])$ ]]
then
CADENCE_WEB_DNS=cadenceradio.com
echo "Please provide the domain name you will use for Cadence UI."
read -p " Web UI Domain: " CADENCE_WEB_HOST
else
echo "No reverse proxy will be configured."
fi

cp ./config/cadence.env.example ./config/cadence.env
Expand All @@ -52,16 +49,22 @@ sed -i 's|CADENCE_PASS_EXAMPLE|'"$CADENCE_PASS"'|g' ./config/cadence.env
sed -i 's|CADENCE_PASS_EXAMPLE|'"$CADENCE_PASS"'|g' ./config/icecast.xml
sed -i 's|CADENCE_PASS_EXAMPLE|'"$CADENCE_PASS"'|g' ./config/liquidsoap.liq
sed -i 's|CADENCE_RATE_EXAMPLE|'"$CADENCE_RATE"'|g' ./config/cadence.env
sed -i 's|CADENCE_HOST_EXAMPLE|'"$CADENCE_HOST"'|g' ./config/icecast.xml
sed -i 's|CADENCE_STREAM_HOST_EXAMPLE|'"$CADENCE_STREAM_HOST"'|g' ./config/icecast.xml
sed -i 's|CADENCE_PATH_EXAMPLE|'"$CADENCE_PATH"'|g' ./config/cadence.env
sed -i 's|CADENCE_PATH_EXAMPLE|'"$CADENCE_PATH"'|g' ./config/liquidsoap.liq
sed -i 's|CADENCE_STREAM_DNS_EXAMPLE|'"$CADENCE_STREAM_DNS"'|g' ./config/nginx.conf
sed -i 's|CADENCE_WEB_DNS_EXAMPLE|'"$CADENCE_WEB_DNS"'|g' ./config/nginx.conf
sed -i 's|CADENCE_STREAM_HOST_EXAMPLE|'"$CADENCE_STREAM_HOST"'|g' ./config/nginx.conf
sed -i 's|CADENCE_WEB_HOST_EXAMPLE|'"$CADENCE_WEB_HOST"'|g' ./config/nginx.conf
sed -i 's|CADENCE_PATH_EXAMPLE|'"$CADENCE_PATH"'|g' ./docker-compose.yml

echo "========================================="
echo ""
echo "Configuration completed."
echo "If it does not begin automatically, run 'docker compose up' to start Cadence."

docker compose down
docker compose pull
docker compose up

if [[ "$ENABLE_REVERSE_PROXY" =~ ^([yY])$ ]]
then
docker compose --profile nginx up
else
docker compose up
fi
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN ln -s /usr/bin/dpkg-split /usr/sbin/dpkg-split && \
RUN apt clean all
RUN apt update
RUN apt install liquidsoap=1.4.3-3 -y
RUN apt autoremove
RUN apt autoremove --purge
EXPOSE 1234
USER liquidsoap
CMD [ "liquidsoap", "-t", "/etc/liquidsoap/cadence.liq" ]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions src/server/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module github.com/kenellorando/cadence

go 1.21

require (
github.com/Jeffail/gabs v1.4.0
github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8
github.com/fsnotify/fsnotify v1.7.0
github.com/lib/pq v1.10.9
github.com/redis/go-redis/v9 v9.5.1
gopkg.in/antage/eventsource.v1 v1.0.0-20150318155416-803f4c5af225
)

require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
golang.org/x/sys v0.20.0 // indirect
)
22 changes: 22 additions & 0 deletions src/server/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo=
github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8 h1:OtSeLS5y0Uy01jaKK4mA/WVIYtpzVm63vLVAPzJXigg=
github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8/go.mod h1:apkPC/CR3s48O2D7Y++n1XWEpgPNNCjXYga3PPbJe2E=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8=
github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/antage/eventsource.v1 v1.0.0-20150318155416-803f4c5af225 h1:xy+AV3uSExoRQc2qWXeZdbhFGwBFK/AmGlrBZEjbvuQ=
gopkg.in/antage/eventsource.v1 v1.0.0-20150318155416-803f4c5af225/go.mod h1:SiXNRpUllqhl+GIw2V/BtKI7BUlz+uxov9vBFtXHqh8=
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit eca4f37

Please sign in to comment.