# Start from an official, lightweight Node.js image
FROM node:22-alpine

# This is the folder inside the container where our code will live
WORKDIR /app

# Copy just these two files first (not all our code yet) - this lets Docker
# reuse the "npm install" step from cache if only our code changes later,
# making rebuilds much faster
COPY package.json package-lock.json ./
RUN npm install

# Now copy the rest of our backend code into the container
COPY . .

# Generate the Prisma Client inside the container (it needs to match this
# container's exact environment, not just copy what's on your Windows machine)
ENV DATABASE_URL="postgresql://placeholder:placeholder@localhost:5432/placeholder"
RUN npx prisma generate

# Tell Docker this container listens on port 4000
EXPOSE 4000

# The actual command that starts the server when the container runs
CMD ["node", "index.js"]