FROM python:3.11-slim-bookworm AS build # Install build dependencies RUN apt update && apt install -y --no-install-recommends \ gettext \ p7zip-full \ python3-httpx \ libmpv-dev \ curl \ git \ && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Create bot directory and user RUN useradd -m -d /bot --system build USER build WORKDIR /bot # Download and extract the bot source RUN curl -L "https://git.techlabs.lol/radiant_code/teamtalkbot/archive/master.zip" -o PandoraBox.zip \ && 7z x PandoraBox.zip -o/bot \ && mv /bot/teamtalkbot /bot/repo \ && rm PandoraBox.zip # Install Python dependencies and prepare bot WORKDIR /bot/repo RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt \ && python tools/ttsdk_downloader.py \ && python tools/compile_locales.py \ && chmod -R 0755 /bot/repo # ---------------------------------------------------------------------------------- FROM python:3.11-slim-bookworm # Install runtime dependencies RUN apt update && apt install -y --no-install-recommends \ libmpv-dev \ pulseaudio \ && apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Install yt-dlp RUN pip install --no-cache-dir yt-dlp # Create runtime user RUN useradd --system -ms /bin/bash ttbot USER ttbot WORKDIR /home/ttbot # Copy bot files from build stage COPY --from=build --chown=ttbot:ttbot /bot/repo ./ COPY --from=build --chown=ttbot:ttbot /bot/.local ./.local # Set permissions RUN chmod -R 0755 /home/ttbot # Clean up unnecessary files RUN rm -rf .git __pycache__ *.pyc *.pyo # 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"]