Certainly! Below are the code snippets for each of the files you requested, based on the setup for a Next.js application with a PostgreSQL database using Docker Compose and Drizzle ORM.
Dockerfile
FROM node:18-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
CMD [ "npm", "run", "start" ]
docker-compose.yml
version: '3.8'
services:
web:
build: .
ports:
- "3000:3000"
depends_on:
- db
environment:
- DATABASE_URL=postgresql://user:password@db:5432/mydatabase
command: >
sh -c "npm run db:migrate && npm run build && npm run start"
db:
image: postgres:latest
restart: always
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: mydatabase
volumes:
- db-data:/var/lib/postgresql/data
volumes:
db-data:
.env
DATABASE_URL=postgresql://user:password@localhost:5432/mydatabase
Drizzle Config File (e.g., drizzle.config.js)
module.exports = {
schema: './src/db/schema.ts',
out: './drizzle',
connectionString: process.env.DATABASE_URL,
};
next.config.js
import type { NextConfig } from 'next';