# Use the official AlmaLinux image as base FROM almalinux:latest # Install wget, unzip, chromium, and other dependencies RUN yum install -y wget unzip epel-release RUN yum install -y chromium pango libXcomposite libXcursor libXdamage libXext libXi libXtst cups-libs libXScrnSaver libXrandr xorg-x11-utils gcc-c++ make libXt xdg-user-dirs xorg-x11-server-Xvfb xdotool python39 && \ yum clean all && \ rm -rf /var/cache/yum # Set up a new user named "user" with user ID 1000 and create the working directory RUN useradd -m -u 1000 -s /bin/bash user && \ mkdir -p /work && \ chown -R user:user /work # Symbolic link for libnss3 RUN ln -s /usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/libnss3.so RUN curl -sL https://rpm.nodesource.com/setup_18.x | bash - RUN yum install -y nodejs RUN npm install pm2@latest -g RUN npm install colors@1.4.0 -g # Switch to the "user" user USER user # Set the working directory in the container WORKDIR /work # Set environment variables ENV CHROME_BIN="/usr/bin/chromium-browser" \ PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true" \ PM2_HOME=/work/.pm2 # Copy source code and install.sh into the container COPY --chown=user ./source /work/source # Run the install.sh script # RUN chmod +x ./source/install.sh && \ # ./source/install.sh WORKDIR /work/source # Install global npm packages RUN npm install # Set a build argument for NODE_NAME ARG NODE_NAME ENV NODE_NAME=${NODE_NAME} # Rename .env.prod to .env and replace NODE_NAME RUN mv /work/source/.env.prod /work/source/.env \ && sed -i "s/{NODE_NAME}/${NODE_NAME}/g" /work/source/.env # Expose the port the app runs on EXPOSE 7860 # Execute the application with PM2 CMD xvfb-run --server-args="-screen 0 1024x768x24" pm2-runtime start server.js && pm2 save