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

Enhancement - DCCB as Docker Container #14

Open
fahrenhe1t opened this issue Sep 30, 2021 · 3 comments
Open

Enhancement - DCCB as Docker Container #14

fahrenhe1t opened this issue Sep 30, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@fahrenhe1t
Copy link

fahrenhe1t commented Sep 30, 2021

It would be cool if the DiscordCurrentlyCastingBot was created as a Docker container. Easy to manage port access and configuration. Should have the ability to set up a bind volume so database and config is stored on host machine, and is retained between reboots and upgrades. Thanks for your consideration!

@dopeghoti
Copy link
Owner

Sounds like a good excuse for me to finally get off my duff and learn how to Docker (:
I'll certainly look into it!

@dopeghoti dopeghoti added the enhancement New feature or request label Oct 5, 2021
@fahrenhe1t
Copy link
Author

fahrenhe1t commented Jul 8, 2022

I got DiscordCurrentlyCastingBot to work as a Docker container on my home server. I cloned your project to a folder, and filled out the .env with my server/channel info. Then I use this Dockerfile to create the Docker image:

FROM python:3.7.13-alpine3.16

LABEL Maintainer="dopeghoti"

WORKDIR /opt/DiscordCurrentlyCastingBot/

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY bot.py ./
COPY channeldb.py ./
COPY currentlycastingbot-pm2.json ./

CMD [ "python", "./bot.py" ]

Then I build the docker image with: docker build -t discordcurrentlycastingbot:1.1 .

Then I created a docker-compose.yml file to run it. The environment variables in the docker-compose file get passed to the container from the .env file the user creates in the same folder:

---
version: "3"
services:
  dccb:
    image: discordcurrentlycastingbot:1.1
    container_name: discordcurrentlycastingbot
    environment:
      PUID: 1000
      PGID: 1000
      TZ: US/Mountain
      DISCORD_TOKEN: "${DISCORD_TOKEN}"
      DISCORD_GUILD: "${DISCORD_GUILD}"
      DISCORD_PREFIX: "${DISCORD_PREFIX}"
      DISCORD_MONITOR: "${DISCORD_MONITOR}"
      DISCORD_CONTROL: "${DISCORD_CONTROL}"
      TWITCH_CLIENTID: "${TWITCH_CLIENTID}"
      TWITCH_SECRET: "${TWITCH_SECRET}"
      CHANNELS: "${CHANNELS}"
      WATCH_LENGTH: "${WATCH_LENGTH}"
    volumes:
      - ./config/${CHANNELS}:/opt/DiscordCurrentlyCastingBot/${CHANNELS}
    restart: unless-stopped

It maps the database to a bind volume so the data persists between restarts.
Then I run the docker container, and it's verified working on my end: docker compose up -d --force-recreate

Maybe you could create the official image on your end and upload it to the github container repo (ghcr.io) or hub.docker.com?

@dopeghoti
Copy link
Owner

Thanks for this! I'll fiddle around with it and do a little testing, and if it flies as well as I imagine it will, shall incorporate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants