├── .github └── workflows │ ├── docker-publish.yml │ └── dockerhub-description.yml ├── Dockerfile ├── README.md └── run_bot.sh /.github/workflows/docker-publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish Docker images 2 | # This workflow uses actions that are not certified by GitHub. 3 | # They are provided by a third-party and are governed by separate terms of service, privacy policy, and support documentation. 4 | 5 | on: 6 | workflow_dispatch: 7 | push: 8 | branches: [ "main" ] 9 | paths-ignore: 10 | - ".github/**" 11 | - "README.md" 12 | pull_request: 13 | branches: [ "main" ] 14 | 15 | env: 16 | REGISTRY: ghcr.io 17 | DOCKER_REGISTRY: docker.io 18 | # github.repository as / 19 | IMAGE_NAME: ${{ github.repository }} 20 | 21 | jobs: 22 | build: 23 | runs-on: ubuntu-latest 24 | permissions: 25 | contents: read 26 | packages: write 27 | steps: 28 | - name: Checkout repository 29 | uses: actions/checkout@v4 30 | 31 | - name: Set up QEMU 32 | uses: docker/setup-qemu-action@v3 33 | 34 | - name: Setup Docker buildx 35 | uses: docker/setup-buildx-action@v3 36 | 37 | - name: Log into registry ${{ env.REGISTRY }} 38 | if: github.event_name != 'pull_request' 39 | uses: docker/login-action@v3 40 | with: 41 | registry: ${{ env.REGISTRY }} 42 | username: ${{ github.actor }} 43 | password: ${{ secrets.GITHUB_TOKEN }} 44 | 45 | - name: Log into registry ${{ env.DOCKER_REGISTRY }} 46 | if: github.event_name != 'pull_request' 47 | uses: docker/login-action@v3 48 | with: 49 | registry: ${{ env.DOCKER_REGISTRY }} 50 | username: ${{ secrets.DOCKER_U }} 51 | password: ${{ secrets.DOCKER_P }} 52 | 53 | - name: Extract metadata 54 | id: meta 55 | uses: docker/metadata-action@v4 56 | with: 57 | flavor: latest=true 58 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 59 | 60 | - name: Build and push Docker image 61 | id: build-and-push 62 | uses: docker/build-push-action@v5 63 | with: 64 | context: . 65 | platforms: linux/amd64,linux/arm64 66 | push: ${{ github.event_name != 'pull_request' }} 67 | tags: | 68 | ${{ steps.meta.outputs.tags }} 69 | ${{ env.DOCKER_REGISTRY }}/${{ secrets.DOCKER_U }}/jmusicbot:latest 70 | labels: ${{ steps.meta.outputs.labels }} 71 | cache-from: type=gha 72 | cache-to: type=gha,mode=max 73 | -------------------------------------------------------------------------------- /.github/workflows/dockerhub-description.yml: -------------------------------------------------------------------------------- 1 | name: Update Docker Hub Description 2 | on: 3 | push: 4 | branches: 5 | - main 6 | paths: 7 | - README.md 8 | - .github/workflows/dockerhub-description.yml 9 | jobs: 10 | dockerHubDescription: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - name: Docker Hub Description 16 | uses: peter-evans/dockerhub-description@v4 17 | with: 18 | username: ${{ secrets.DOCKER_U }} 19 | password: ${{ secrets.DOCKER_P }} 20 | repository: yojoshb/jmusicbot 21 | short-description: ${{ github.event.repository.description }} 22 | enable-url-completion: true 23 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM bitnami/minideb:bullseye 2 | 3 | RUN install_packages openjdk-11-jre-headless wget curl grep \ 4 | && mkdir /app \ 5 | && mkdir -p /config/Playlists \ 6 | && ln -s /config/Playlists /app/Playlists \ 7 | && ln -s /config/serversettings.json /app/serversettings.json 8 | 9 | STOPSIGNAL SIGTERM 10 | 11 | ENV BOT_VERSION="latest" 12 | ENV BOT_GITHUB="jagrosh/MusicBot" 13 | 14 | COPY run_bot.sh /app/run_bot.sh 15 | RUN chmod +x /app/run_bot.sh 16 | 17 | WORKDIR /app 18 | VOLUME /config 19 | 20 | CMD ["./run_bot.sh"] 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JMusicBot Docker 2 | [![Release](https://img.shields.io/github/release/jagrosh/MusicBot?color=g&style=for-the-badge)](https://github.com/jagrosh/MusicBot/releases/latest) 3 | ![Supports amd64 Architecture](https://img.shields.io/badge/amd64-yes-blueviolet.svg?style=for-the-badge) 4 | ![Supports arm64 Architecture](https://img.shields.io/badge/arm64-yes-blueviolet.svg?style=for-the-badge) 5 | 6 | A simple Docker container for [JMusicBot](https://github.com/jagrosh/MusicBot). The container will start up, then download JMusicBot from the projects repository and run it. 7 | 8 | ## Usage 9 | - Place your **config.txt**, **Playlists** folder, and **serversettings.json** file (if you have one) in `/your/path/to/config`. This directory will be shared with the container. 10 | > Refer to the documentaion on how to [configure the bot](https://jmusicbot.com/setup/#3-configure-the-bot) 11 | - You can specify a JMusicBot version using the environment variable `BOT_VERSION`. By default the latest version will be downloaded so you don't have to include the variable if you want to use latest. 12 | > The version numbers you can use correspond to the [releases](https://github.com/jagrosh/MusicBot/releases) tag, not the release name. 13 | - Optionally, specify a JMusicBot repository to use by the environment variable `BOT_GITHUB`. This is ideal for using forks of the main repo when something breaks, and no fixes are yet available. It is recommended to set `updatealerts=false` in the bot config when using this option. By default this will be the official repository, `jagrosh/MusicBot`. 14 | > - [jagrosh/MusicBot](https://github.com/jagrosh/MusicBot) 15 | > - [SeVile/MusicBot](https://github.com/SeVile/MusicBot/) 16 | 17 | 18 | ### Docker examples 19 | - Using docker cli 20 | ```bash 21 | docker run -dit \ 22 | --name=jmusicbot \ 23 | -v /your/path/to/config:/config \ 24 | --restart=unless-stopped \ 25 | ghcr.io/yojoshb/jmusicbot-docker 26 | ``` 27 | 28 | - Using docker compose 29 | ```yaml 30 | --- 31 | services: 32 | jmusicbot: 33 | image: ghcr.io/yojoshb/jmusicbot-docker 34 | container_name: jmusicbot 35 | environment: 36 | - BOT_VERSION=0.3.9 # Optional. Will default to the 'latest' release 37 | - BOT_GITHUB=jagrosh/MusicBot # Optional. In the format {Owner}/{Repository} 38 | volumes: 39 | - /your/path/to/config:/config 40 | restart: unless-stopped 41 | ``` 42 | 43 | --- 44 | 45 | #### Debugging 46 | - If you need to access the container you can hop into it and get a shell using: 47 | ```bash 48 | docker exec -it jmusicbot /bin/bash 49 | ``` 50 | 51 | - Or read the logs: 52 | ```bash 53 | docker logs jmusicbot 54 | ``` 55 | -------------------------------------------------------------------------------- /run_bot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get latest or specified tag version 4 | if [ "$BOT_VERSION" == "latest" ]; then 5 | RELEASE_JSON=$(curl --silent "https://api.github.com/repos/${BOT_GITHUB}/releases/latest") 6 | else 7 | RELEASE_JSON=$(curl --silent "https://api.github.com/repos/${BOT_GITHUB}/releases/tags/${BOT_VERSION}") 8 | fi 9 | 10 | # Check if the release JSON was fetched successfully 11 | if [ -z "$RELEASE_JSON" ] || echo "$RELEASE_JSON" | grep -q '"message": "Not Found"'; then 12 | echo "Error: Could not find release for version '$BOT_VERSION'." 13 | echo "Possible release tags for ${BOT_GITHUB}:" 14 | curl --silent "https://api.github.com/repos/${BOT_GITHUB}/releases" | grep -Po '"tag_name":\s*"\K[^"]*' | head -n 10 15 | exit 1 16 | fi 17 | 18 | VERSION_TAG=$(echo "$RELEASE_JSON" | grep -Po '"tag_name":\s*"\K[^"]*') 19 | ASSET_NAME=$(echo "$RELEASE_JSON" | grep -Po '"name":\s*"\KJMusicBot[^"]*\.jar') 20 | DOWNLOAD_URL=$(echo "$RELEASE_JSON" | grep -Po '"browser_download_url":\s*"\Khttps://[^"]*JMusicBot[^"]*\.jar') 21 | 22 | if [ -z "$ASSET_NAME" ] || [ -z "$DOWNLOAD_URL" ]; then 23 | echo "Error: No matching asset found in release $VERSION_TAG." 24 | exit 1 25 | fi 26 | 27 | echo -e "Downloading JMusicBot $VERSION_TAG" 28 | if [ ! -f "$ASSET_NAME" ]; then 29 | if ! wget "$DOWNLOAD_URL" -O "$ASSET_NAME"; then 30 | echo "Error: Failed to download $ASSET_NAME." 31 | exit 1 32 | fi 33 | fi 34 | 35 | echo -e "Starting JMusicBot $VERSION_TAG" 36 | java -Dnogui=true -Dconfig=/config/config.txt -jar "$ASSET_NAME" --------------------------------------------------------------------------------