# Use the official Node.js image based on Debian Bullseye Slim as the base image | |
FROM node:18-bullseye-slim | |
# Update the package list and install git | |
RUN apt-get update && \ | |
apt-get install -y git | |
# Clone the repository from the provided GitHub URL into the /app directory | |
RUN git clone https://github.com/cg-dot/oai-reverse-proxy.git /app | |
# Set the working directory to /app | |
WORKDIR /app | |
# Change ownership of the /app directory to user with UID 1000 and group with GID 1000 | |
RUN chown -R 1000:1000 /app | |
# Switch to the user with UID 1000 | |
USER 1000 | |
# Install npm dependencies | |
RUN npm install | |
# Copy the Dockerfile, greeting.md, and any .env files to the current working directory | |
COPY Dockerfile greeting.md* .env* ./ | |
# Run the build script defined in package.json | |
RUN npm run build | |
# Expose port 7860 to the outside world | |
EXPOSE 7860 | |
# Set environment variable NODE_ENV to production | |
ENV NODE_ENV=production | |
# Set Node.js options to limit the old space (heap) size | |
ENV NODE_OPTIONS="--max-old-space-size=12882" | |
# Define the command to start the application | |
CMD [ "npm", "start" ] |