teto_ai/Dockerfile.dev

51 lines
1.7 KiB
Text

# --- Stage 1: Install node_modules ---
FROM node:20-slim as dependencies
WORKDIR /opt/bot
COPY package*.json ./
RUN npm install --no-audit --no-fund
# --- Stage 2: Development Build ---
FROM node:20-slim
# Install system dependencies for Discord and virtual display
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl ca-certificates sudo \
# ── Discord runtime deps ──────────────────
libatomic1 libnotify4 libnspr4 libnss3 libxss1 libgbm1 \
libgconf-2-4 libxtst6 libgtk-3-0 \
# ── GUI / audio / misc ───────────────────
xvfb pulseaudio openbox \
tigervnc-standalone-server tigervnc-common fonts-liberation \
x11vnc \
&& rm -rf /var/lib/apt/lists/*
# Download and install Discord
WORKDIR /opt/preinstall
RUN curl -L https://discord.com/api/download/stable?platform=linux -o discord.deb && \
dpkg -i discord.deb || apt-get -f install -y
# Create a non-root user
RUN useradd --create-home --shell /bin/bash bot && \
adduser bot sudo && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# Set up the bot directory
WORKDIR /opt/bot
# Copy pre-installed node_modules from the 'dependencies' stage
COPY --from=dependencies /opt/bot/node_modules ./node_modules
# Copy entrypoint and set permissions
COPY entry.sh .
RUN chmod +x /opt/bot/entry.sh
# The rest of the source code will be mounted as a volume
# Set ownership and user
RUN chown -R bot:bot /opt/bot
USER bot
# Set environment and entrypoint
ENV DISPLAY=:99
RUN mkdir -p /run/dbus
ENTRYPOINT dbus-daemon --system --fork --nofork --address unix:/run/dbus/system_bus_socket & exec /opt/bot/entry.sh "$@"