FROM node:18-alpine

WORKDIR /app

# Copy package files and install production dependencies
COPY package*.json ./
RUN npm install --production

# Copy server code
COPY server.js ./

# Copy the pre-built frontend files
COPY dist ./dist

# Create a data directory to store JSON files locally
RUN mkdir -p data

# Expose port
EXPOSE 3001

# Start the server
CMD ["npm", "start"]
