This commit is contained in:
parent
6bbb3accb4
commit
d66fd0c441
66
Dockerfile
66
Dockerfile
@ -1,49 +1,63 @@
|
|||||||
FROM python:3.11-slim-bullseye AS build
|
FROM python:3.11-slim-bookworm AS build
|
||||||
|
|
||||||
# Install dependencies
|
# Install build 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/*
|
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
|
||||||
|
|
||||||
# Create build user and working directory
|
|
||||||
RUN useradd -d /bot --system build
|
|
||||||
RUN mkdir /bot && chown build:build /bot
|
|
||||||
USER build
|
USER build
|
||||||
|
|
||||||
# Download and extract PandoraBox.zip
|
|
||||||
WORKDIR /bot
|
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
|
# 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
|
# Install Python dependencies and prepare bot
|
||||||
WORKDIR /bot/repo
|
WORKDIR /bot/repo
|
||||||
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
RUN pip install --no-cache-dir --upgrade pip \
|
||||||
RUN python tools/ttsdk_downloader.py && python tools/compile_locales.py
|
&& pip install --no-cache-dir -r requirements.txt \
|
||||||
|
&& python tools/ttsdk_downloader.py \
|
||||||
|
&& python tools/compile_locales.py \
|
||||||
|
&& chmod -R 0755 /bot/repo
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Set permissions for all files in /bot/repo
|
FROM python:3.11-slim-bookworm
|
||||||
RUN chmod -R 0755 /bot/repo
|
|
||||||
|
|
||||||
FROM python:3.11-slim-bullseye
|
|
||||||
|
|
||||||
# Install runtime dependencies
|
# 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/*
|
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 with pip
|
# Install yt-dlp
|
||||||
RUN pip install --no-cache-dir yt-dlp
|
RUN pip install --no-cache-dir yt-dlp
|
||||||
|
|
||||||
# Create runtime user
|
# Create runtime user
|
||||||
RUN useradd --system -ms /bin/bash ttbot
|
RUN useradd --system -ms /bin/bash ttbot
|
||||||
|
|
||||||
USER ttbot
|
USER ttbot
|
||||||
|
|
||||||
# Set working directory and copy files
|
|
||||||
WORKDIR /home/ttbot
|
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
|
# 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
|
RUN chmod -R 0755 /home/ttbot
|
||||||
|
|
||||||
# Remove .git directory
|
# Clean up unnecessary files
|
||||||
RUN rm -rf .git
|
RUN rm -rf .git __pycache__ *.pyc *.pyo
|
||||||
|
|
||||||
# Command to run the bot
|
# 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"]
|
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"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user