# Use the official Node.js image
FROM node:22.12-alpine3.20

# Set the working directory
WORKDIR /usr/src/app

# Copy package.json and package-lock.json
# COPY package*.json ./
# Copy only package.json and generate package-lock.json on the fly
COPY package.json ./

# Install the dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Set the NODE_ENV variable
ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV}

# Expose the port the app runs on
EXPOSE 8000

# Define the command to run the app
CMD ["node", "server.js"]