# backend/Dockerfile

# Base image: update to a newer stable Node major
# (using node:22-alpine to pick a recent stable runtime)
FROM node:24-alpine

# Set working directory
WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy source code
COPY . .

# Copy wait-for-it script
COPY wait-for-it.sh /wait-for-it.sh
RUN chmod +x /wait-for-it.sh

# Expose the port
EXPOSE 3000

# Start backend, waiting for Postgres
CMD ["/wait-for-it.sh", "db:5432", "--", "node", "src/index.js"]