From ada3650bfd39764f5df5b94d58fd0551dbfe91d3 Mon Sep 17 00:00:00 2001 From: Jonathan Pulsifer Date: Fri, 16 Jan 2026 19:31:02 -0400 Subject: [PATCH] Refactor docker-compose.yaml to enable Next.js service and update README for clearer setup instructions. Added Prisma Studio command to package.json and adjusted tsconfig for improved compatibility. --- README.md | 57 ++++++++++++++++++++++++--------------------- docker-compose.yaml | 28 +++++++--------------- package.json | 4 ++-- tsconfig.json | 19 +++++++++++---- 4 files changed, 55 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 8e5afc1..ae18de7 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,58 @@ # Next.js Prisma Starter -This is a simple Next.js template that incorporates [Prisma](https://prisma.io/) as the Object-Relational Mapping (ORM) tool. The following instructions guide you on how to effectively use this template. +A Next.js template using [Prisma](https://prisma.io/) as the ORM. -## Step-by-step Usage Guide +## Getting Started -### Step 1: Clone and Install Dependencies - -The first step is to clone this repository and install dependencies. This can be done in a couple ways: +### 1. Install Dependencies ```bash -pnpm create next-app --example https://github.com/moonpay/devops-challenge - -# or - -git clone https://github.com/moonpay/devops-challenge -cd devops-challenge pnpm install ``` -### Step 2: Set Up Environment Variables +### 2. Set Up Environment Variables -Once you've cloned the project, you need to configure the environment variables. Start by creating a `.env` file by copying the provided `.env.example` file in this directory. You can do this using the command: +Create a `.env` file with your database connection: ```bash -cp .env.example .env +echo 'POSTGRES_PRISMA_URL=postgres://postgres:postgres@localhost:5432/currencies?schema=public' > .env ``` -Please note that the `.env` file is ignored by Git for security reasons. +### 3. Start the Database -### Step 3: Start the Database and Seed Data +```bash +docker compose up -d postgres +``` -Next, you need to start the database and seed the data. You can do this by running the following command: +### 4. Seed the Database ```bash -docker run --rm --name postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=currencies -p 5432:5432 -d postgres:17-alpine - pnpm db:seed +``` -# or - -docker compose up -d +### 5. Start Development Server -pnpm db:seed +```bash +pnpm dev ``` -### Step 4: Start Development Server +The app will be available at [http://localhost:3000](http://localhost:3000). + +## Useful Commands -Finally, you are ready to run the Next.js development server. Execute the following command in your terminal: +| Command | Description | +|---------|-------------| +| `pnpm dev` | Start the development server | +| `pnpm build` | Build for production | +| `pnpm db:seed` | Push schema and seed the database | +| `pnpm db:studio` | Open Prisma Studio to inspect the database | + +## Docker + +To run the full stack with Docker: ```bash -pnpm dev +docker compose up -d ``` -Once this command runs successfully, the project is up and ready. You might be missing some components (like a Dockerfile), but you can add them as you go. +This starts both PostgreSQL and the Next.js app (once we have a Dockerfile) diff --git a/docker-compose.yaml b/docker-compose.yaml index c8d4d97..a447847 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,4 +1,3 @@ -# compose for postgres, pgadmin, and nextjs services: postgres: image: postgres:17-alpine @@ -12,24 +11,15 @@ services: volumes: - postgres:/var/lib/postgresql/data - # pgadmin: - # image: dpage/pgadmin4 - # restart: always - # environment: - # PGADMIN_DEFAULT_EMAIL: admin@example.com - # PGADMIN_DEFAULT_PASSWORD: admin - # ports: - # - 5050:80 - - # nextjs: - # build: . - # restart: always - # environment: - # POSTGRES_PRISMA_URL: postgres://postgres:postgres@postgres:5432/currencies?schema=public - # ports: - # - 3000:3000 - # depends_on: - # - postgres + nextjs: + build: . + restart: always + environment: + POSTGRES_PRISMA_URL: postgres://postgres:postgres@postgres:5432/currencies?schema=public + ports: + - 3000:3000 + depends_on: + - postgres volumes: postgres: diff --git a/package.json b/package.json index 44111ee..c5f2b1e 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "build": "prisma generate && next build", "db:schema:push": "prisma generate && prisma db push", "db:seed": "prisma generate && prisma db push && prisma db seed", - "start": "next start", - "lint": "next lint" + "db:studio": "prisma studio", + "start": "next start" }, "dependencies": { "@prisma/client": "6.16.3", diff --git a/tsconfig.json b/tsconfig.json index 6c59e59..31327ba 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,11 @@ { "compilerOptions": { "target": "es5", - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -12,7 +16,7 @@ "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve", + "jsx": "react-jsx", "incremental": true, "plugins": [ { @@ -20,7 +24,9 @@ } ], "paths": { - "@/*": ["./*"] + "@/*": [ + "./*" + ] } }, "include": [ @@ -28,7 +34,10 @@ "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", - "prisma/seed.ts" + "prisma/seed.ts", + ".next/dev/types/**/*.ts" ], - "exclude": ["node_modules"] + "exclude": [ + "node_modules" + ] }