teamtalkbot/Dockerfile
Umiko f331b10358
Some checks are pending
Build-nightly / docker (push) Waiting to run
first commit.
2025-04-13 14:44:48 +07:00

52 lines
1.9 KiB
Docker

FROM python:3.11-slim-bullseye AS build
# Install dependencies
RUN apt update && apt upgrade -y && apt install -y --no-install-recommends gettext p7zip-full python3-httpx libmpv-dev curl git-core && apt clean && rm -rf /var/lib/apt/lists/*
# Create build user and working directory
RUN useradd -d /bot --system build
RUN mkdir /bot && chown build:build /bot
USER build
# Download and extract PandoraBox.zip
WORKDIR /bot
RUN curl -L -o PandoraBox.zip "https://www.dropbox.com/scl/fi/w59od6p43v474cdqfllt1/PandoraBox.zip?rlkey=sghktp7rbuxknbz9b3v9lqfii&dl=1"
RUN 7z x PandoraBox.zip -o/bot/repo
# Install Python dependencies and prepare bot
WORKDIR /bot/repo
RUN pip install --no-cache-dir --upgrade -r requirements.txt
RUN python tools/ttsdk_downloader.py && python tools/compile_locales.py
# Replace yt.py with a custom version
RUN curl -L -o /bot/repo/bot/services/yt.py "https://www.dropbox.com/scl/fi/eq1fdfp2k7whfbhklwazn/yt.py?rlkey=emggs6flhwpoje6sagmjpeljn&dl=1"
# Set permissions for all files in /bot/repo
RUN chmod -R 0755 /bot/repo
FROM python:3.11-slim-bullseye
# Install runtime dependencies
RUN apt update && apt upgrade -y && apt install -y --no-install-recommends libmpv-dev pulseaudio && apt clean && rm -rf /var/lib/apt/lists/*
# Install yt-dlp with pip
RUN pip install --no-cache-dir yt-dlp
# Create runtime user
RUN useradd --system -ms /bin/bash ttbot
USER ttbot
# Set working directory and copy files
WORKDIR /home/ttbot
COPY --from=build --chown=ttbot /bot/repo .
COPY --from=build --chown=ttbot /bot/.local ./.local
# Set permissions for all files in /home/ttbot
RUN chmod -R 0755 /home/ttbot
# Remove .git directory
RUN rm -rf .git
# Command to run the bot
CMD ["sh", "-c", "rm -rf /tmp/* && pulseaudio --daemon --exit-idle-time=-1 && sleep 2 && ./TTMediaBot.sh -c data/config.json --cache data/TTMediaBotCache.dat --log data/TTMediaBot.log"]