add env to specify bot version, update readme

This commit is contained in:
josh 2024-04-11 17:24:38 -05:00
parent d0a3d1f17e
commit e169bfedd2
3 changed files with 41 additions and 24 deletions

View file

@ -8,10 +8,12 @@ RUN install_packages openjdk-11-jre-headless wget curl grep \
STOPSIGNAL SIGTERM STOPSIGNAL SIGTERM
ENV BOT_VERSION latest
COPY run_bot.sh /app/run_bot.sh COPY run_bot.sh /app/run_bot.sh
RUN chmod 700 /app/run_bot.sh RUN chmod +x /app/run_bot.sh
WORKDIR /app WORKDIR /app
VOLUME /config VOLUME /config
CMD ["./run_bot.sh"] CMD ["./run_bot.sh"]

View file

@ -1,31 +1,25 @@
# JMusicBot Docker # JMusicBot Docker
[![Release](https://img.shields.io/github/release/jagrosh/MusicBot?color=g&style=for-the-badge)](https://github.com/jagrosh/MusicBot/releases/latest) [![Release](https://img.shields.io/github/release/jagrosh/MusicBot?color=g&style=for-the-badge)](https://github.com/jagrosh/MusicBot/releases/latest)
[![Docker Hub Pulls](https://img.shields.io/docker/pulls/yojoshb/jmusicbot?color=blue&style=for-the-badge)](https://hub.docker.com/r/yojoshb/jmusicbot)
![Supports amd64 Architecture](https://img.shields.io/badge/amd64-yes-blueviolet.svg?style=for-the-badge) ![Supports amd64 Architecture](https://img.shields.io/badge/amd64-yes-blueviolet.svg?style=for-the-badge)
![Supports arm64 Architecture](https://img.shields.io/badge/arm64-yes-blueviolet.svg?style=for-the-badge) ![Supports arm64 Architecture](https://img.shields.io/badge/arm64-yes-blueviolet.svg?style=for-the-badge)
Docker container for the latest version of [JMusicBot](https://github.com/jagrosh/MusicBot) A simple Docker container for [JMusicBot](https://github.com/jagrosh/MusicBot)
## Usage ## Usage
Place your **config.txt**, **Playlists** folder, and **serversettings.json** file (if you have one) in `yourpath/toconfig` to map it to the container. If you need to access the container you can hop into it and get a shell using: - 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.
- You can specify a JMusicBot version using the environment value `BOT_VERSION`. By default it will use the latest version so you do not have to include the value if you don't want to.
```bash ### Docker examples
docker exec -it jmusicbot /bin/bash - Using docker cli
```
---
### Docker CLI
```bash ```bash
docker run -dit \ docker run -dit \
--name=jmusicbot \ --name=jmusicbot \
-v /yourpath/toconfig:/config \ -v /your/path/to/config:/config \
--restart=unless-stopped \ --restart=unless-stopped \
ghcr.io/yojoshb/jmusicbot-docker ghcr.io/yojoshb/jmusicbot-docker
``` ```
### Docker Compose - Using docker compose
```bash ```bash
--- ---
version: "3" version: "3"
@ -33,7 +27,22 @@ services:
jmusicbot: jmusicbot:
image: ghcr.io/yojoshb/jmusicbot-docker image: ghcr.io/yojoshb/jmusicbot-docker
container_name: jmusicbot container_name: jmusicbot
environment:
- BOT_VERSION=0.3.9 # You can leave this out if you just want to run the latest version
volumes: volumes:
- /yourpath/toconfig:/config - /your/path/to/config:/config
restart: unless-stopped restart: unless-stopped
``` ```
---
#### Debugging
- If you need to access the container you can hop into it and get a shell using:
```bash
docker exec -it jmusicbot /bin/bash
```
- Or read the logs if your having issues
```bash
docker logs jmusicbot
```

View file

@ -1,11 +1,17 @@
#!/bin/sh #!/bin/bash
echo "Starting JMusicBot" # Set the default version to latest
VER_DEFAULT=$(curl --silent "https://api.github.com/repos/jagrosh/MusicBot/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
VER=$(curl --silent "https://api.github.com/repos/jagrosh/MusicBot/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")') # If the ENV is not explicitly set, use the sourced ENV from the Dockerfile
if [ $BOT_VERSION == "latest" ]; then
if [ ! -f JMusicBot-$VER.jar ]; then BOT_VERSION=$VER_DEFAULT
wget https://github.com/jagrosh/MusicBot/releases/download/$VER/JMusicBot-$VER.jar
fi fi
java -Dnogui=true -Dconfig=/config/config.txt -jar JMusicBot-$VER.jar echo -e "Downloading JMusicBot $BOT_VERSION"
if [ ! -f JMusicBot-$BOT_VERSION.jar ]; then
wget https://github.com/jagrosh/MusicBot/releases/download/$BOT_VERSION/JMusicBot-$BOT_VERSION.jar
fi
echo -e "Starting JMusicBot $BOT_VERSION"
java -Dnogui=true -Dconfig=/config/config.txt -jar JMusicBot-$BOT_VERSION.jar