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://git.techlabs.lol/radiant_code/teamtalkbot/archive/master.zip" 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 # 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"]