bycf / Dockerfile
lordofc's picture
Update Dockerfile
64f8316 verified
FROM node:20-slim
RUN apt-get update && apt-get install -y \
wget gnupg ca-certificates fonts-liberation libappindicator3-1 libasound2 \
libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 \
libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 \
libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 \
libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release \
xdg-utils libdrm2 unzip xvfb \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npx puppeteer browsers install chrome
# find actual chrome binary and bake it into image
RUN export CHROME_BIN=$(find /root/.cache/puppeteer/chrome -type f -name chrome | head -n 1) && \
echo "Chrome binary path: $CHROME_BIN" && \
echo "export CHROME_PATH=$CHROME_BIN" >> /root/.bashrc && \
echo "CHROME_PATH=$CHROME_BIN" >> /etc/environment && \
ln -sf $CHROME_BIN /usr/bin/chrome
ENV CHROME_PATH=/usr/bin/chrome
ENV PORT=7860
EXPOSE 7860
CMD xvfb-run --server-args="-screen 0 1280x720x24" node app.js