| # Use the Node.js base image. | |
| FROM node:20-slim | |
| # Install system dependencies. | |
| # The --no-install-recommends flag prevents a lot of unnecessary packages from being installed, which can cause issues. | |
| RUN apt-get update && apt-get install -y --no-install-recommends libheif-dev libavif-dev libheif-examples | |
| # Set the working directory. | |
| WORKDIR /usr/src/app | |
| # Copy the dependency files. | |
| COPY package*.json ./ | |
| # Install Node.js dependencies. | |
| RUN npm install | |
| RUN npm install -g pm2 | |
| # Copy the rest of the application files. | |
| COPY . . | |
| # Expose the port your app runs on. | |
| EXPOSE 7860 | |
| # Command to run the application using PM2 to spin up 4 workers. | |
| CMD [ "pm2-runtime", "start", "server.js", "-i", "4" ] |