# Use an official Node.js runtime as a parent image FROM node:18-slim # Set the working directory in the container WORKDIR /app # Copy package.json and package-lock.json to the working directory COPY package*.json ./ # Install app dependencies # Using --production flag to install only production dependencies # Playwright needs special handling to download browsers # We need to install dependencies first to make sure Playwright downloads its browsers. RUN npm install --production # Copy the rest of the application source code to the working directory COPY . . # Switch to root to install packages and set up the environment USER root # Install proxychains-ng for transparent proxying RUN apt-get update && apt-get install -y --no-install-recommends proxychains-ng && rm -rf /var/lib/apt/lists/* # Copy the entrypoint script and make it executable COPY entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh # Create a directory for proxychains configuration for the 'node' user RUN mkdir -p /home/node/.proxychains && chown -R node:node /home/node/.proxychains # Grant execute permission to the proxy server binary for the root user RUN chmod +x /app/src/proxy/chrome_proxy_server_linux_amd64 # Change ownership of the app directory to the node user RUN chown -R node:node /app # Switch to a non-root user for security USER node # Make port 7860 available to the world outside this container EXPOSE 7860 # Use the entrypoint script to start the application ENTRYPOINT ["/app/entrypoint.sh"] # Define the default command to run the app (will be passed to the entrypoint) CMD ["npm", "start"]