Apalah / Dockerfile
Forgets's picture
Update Dockerfile
fd79714 verified
FROM node:20-slim
# 1. Install dependencies sistem nu diperlukeun ku Chrome & Xvfb
RUN apt update && apt install -y \
wget \
gnupg \
ca-certificates \
xvfb \
procps \
fonts-liberation \
libappindicator3-1 \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libxss1 \
libnss3 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm1 \
libasound2 \
libpangocairo-1.0-0 \
libgtk-3-0 \
&& wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& apt install -y ./google-chrome-stable_current_amd64.deb \
&& rm google-chrome-stable_current_amd64.deb \
&& apt clean && rm -rf /var/lib/apt/lists/*
# 2. Set environment variables sangkan Chrome nyaho kudu lumpat ka mana
ENV DISPLAY=:99
ENV CHROME_PATH=/usr/bin/google-chrome-stable
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
# 3. Setup folder gawé
WORKDIR /A
# 4. Jieun folder cache sarta bikeun idzin akses (keur Hugging Face)
RUN mkdir -p /A/Api /A/cache && chmod -R 777 /A
# 5. Copy package heula sangkan build leuwih gancang (caching)
COPY package.json ./
RUN npm install
# 6. Copy sakabéh script (Api.js, folder Api/, js js liana)
COPY . .
# 7. Port standar Hugging Face
EXPOSE 7860
# 8. Jalankeun Xvfb sarta aplikasi Node.js
# - rm -f /tmp/.X99-lock: nyingkahan error mun aya sésa sési display nu macét
# - Xvfb :99: nyiptakeun virtual display
# - npm start: ngajalankeun Api.js
CMD rm -f /tmp/.X99-lock && \
Xvfb :99 -screen 0 1024x768x24 & \
export DISPLAY=:99 && \
npm start