# All-in-one image with PostgreSQL and Next.js FROM node:20-bookworm # Install PostgreSQL RUN apt-get update && apt-get install -y \ postgresql-15 \ postgresql-client-15 \ sudo \ && rm -rf /var/lib/apt/lists/* # Set up PostgreSQL USER postgres RUN /etc/init.d/postgresql start && \ psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" && \ psql --command "ALTER DATABASE postgres OWNER TO docker;" # Switch back to root USER root # Configure PostgreSQL to allow connections RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/15/main/pg_hba.conf && \ echo "listen_addresses='*'" >> /etc/postgresql/15/main/postgresql.conf # Create app directory WORKDIR /app # Copy package files COPY package*.json ./ # Install dependencies RUN npm ci # Copy application files COPY . . # Build the Next.js application RUN npm run build # Copy startup script COPY <