From 0bf5d7db2c0d4323ddf72082df52ca2140344d4f Mon Sep 17 00:00:00 2001 From: adiiittt Date: Sun, 20 Oct 2024 16:47:07 +0530 Subject: [PATCH 1/6] Instant Fork & Run --- .env.example | 2 +- README.md | 32 +++++++++++++++++++++++++------- setup.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 8 deletions(-) create mode 100755 setup.sh diff --git a/.env.example b/.env.example index 7f47ba24d..9d4288dfb 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,7 @@ NEXT_PUBLIC_BASE_URL_LOCAL=http://127.0.0.1:3000 ADMIN_SECRET="ADMIN_SECRET" JWT_SECRET="JWT_SECRET" # DONT CHANGE FOR RUNNING WITH DOCKER -DATABASE_URL="postgresql://postgres:postgres@db:5432/cms?schema=public" +DATABASE_URL="postgresql://myuser:mypassword@localhost:5432/mydatabase?schema=public" NEXTAUTH_URL="http://localhost:3000" APPX_AUTH_KEY="AUTH_SECRET" NEXTAUTH_SECRET="NEXTAUTH_SECRET" diff --git a/README.md b/README.md index 1f68ff6c8..59a3f0624 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,24 @@ git clone https://github.com/code100x/cms.git ```bash cd cms ``` +# Instant Docker Setup -3. (Optional) Start a PostgreSQL database using Docker: +> [!NOTE] +> Your Docker Demon should be online + +1. Running Script for Instant setup + +``` +# Gives permission to execute a setup file +chmod +x setup.h + +# Runs the setup script file +./setup.h +``` + +# Traditional Docker Setup + +1. (Optional) Start a PostgreSQL database using Docker: ```bash docker run -d \ @@ -35,20 +51,22 @@ docker run -d \ -p 5432:5432 \ postgres -``` +``` -The connection URL for this setup will be: -``` -DATABASE_URL=postgresql://myuser:mypassword@localhost:5432/mydatabase?schema=public -``` -4. Create a .env file: +1. Create a .env file: - Copy `.env.example` and rename it to `.env`. - Configure the `DATABASE_URL` with your PostgreSQL connection string. +The connection URL for this setup will be: + +``` +DATABASE_URL=postgresql://myuser:mypassword@localhost:5432/mydatabase?schema=public +``` + 5. Install dependencies: ```bash diff --git a/setup.sh b/setup.sh new file mode 100755 index 000000000..703d48eff --- /dev/null +++ b/setup.sh @@ -0,0 +1,31 @@ +# Copies .env.example and changes it to .env so that future commands can find the env file +cp .env.example .env + + +# Start PostgreSQL container +docker run -d \ + --name cms-db \ + -e POSTGRES_USER=myuser \ + -e POSTGRES_PASSWORD=mypassword \ + -e POSTGRES_DB=mydatabase \ + -p 5432:5432 \ + postgres + +# Wait for the PostgreSQL container to be ready +echo "Waiting for PostgreSQL to be ready..." +sleep 10 + +# Install dependencies +pnpm install + +# Run Prisma migrations +pnpm run prisma:migrate + +# Generate Prisma client +pnpm prisma generate + +# Seed the database +pnpm run db:seed + +# Start the development server +pnpm run dev From 094b80d7ad917ed06277175c49adaa8ed8722806 Mon Sep 17 00:00:00 2001 From: adiiittt Date: Sun, 20 Oct 2024 16:57:42 +0530 Subject: [PATCH 2/6] Instant Fork & Run --- README.md | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 59a3f0624..2caad68f8 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ chmod +x setup.h # Traditional Docker Setup -1. (Optional) Start a PostgreSQL database using Docker: + (Optional) Start a PostgreSQL database using Docker: ```bash docker run -d \ @@ -59,39 +59,32 @@ postgres - Copy `.env.example` and rename it to `.env`. - - Configure the `DATABASE_URL` with your PostgreSQL connection string. -The connection URL for this setup will be: - -``` -DATABASE_URL=postgresql://myuser:mypassword@localhost:5432/mydatabase?schema=public -``` - -5. Install dependencies: +2. Install dependencies: ```bash pnpm install ``` -6. Run database migrations: +3. Run database migrations: ```bash pnpm run prisma:migrate ``` -7. Generate prisma client +4. Generate prisma client ```bash pnpm prisma generate ``` -8. Seed the database: +5. Seed the database: ```bash pnpm run db:seed ``` -9. Start the development server: +6. Start the development server: ```bash pnpm run dev From 2bddf41b6cd133ff8ac0fe6f6bca8c1cb72e1799 Mon Sep 17 00:00:00 2001 From: "Mr.Paradox" Date: Sun, 20 Oct 2024 11:51:49 +0000 Subject: [PATCH 3/6] fix readme typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2caad68f8..5d621f098 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ cd cms ``` # Gives permission to execute a setup file -chmod +x setup.h +chmod +x setup.sh # Runs the setup script file ./setup.h From 7cc30a07a6593ea7cfbde77ec304df0e49060d34 Mon Sep 17 00:00:00 2001 From: Sargam Date: Mon, 21 Oct 2024 00:17:19 +0530 Subject: [PATCH 4/6] Update .env.example --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 9d4288dfb..1a8fe7f37 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,7 @@ NEXT_PUBLIC_BASE_URL_LOCAL=http://127.0.0.1:3000 ADMIN_SECRET="ADMIN_SECRET" JWT_SECRET="JWT_SECRET" # DONT CHANGE FOR RUNNING WITH DOCKER -DATABASE_URL="postgresql://myuser:mypassword@localhost:5432/mydatabase?schema=public" +DATABASE_URL="postgresql://myuser:mypassword@localhost:5432/cms?schema=public" NEXTAUTH_URL="http://localhost:3000" APPX_AUTH_KEY="AUTH_SECRET" NEXTAUTH_SECRET="NEXTAUTH_SECRET" From d5fcfd1f77adde0bb281e67ee937c439d34bdc45 Mon Sep 17 00:00:00 2001 From: Sargam Date: Mon, 21 Oct 2024 00:20:49 +0530 Subject: [PATCH 5/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d621f098..81a0e36c3 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ cd cms chmod +x setup.sh # Runs the setup script file -./setup.h +./setup.sh ``` # Traditional Docker Setup From 98b96be020ad43019c6bc402b68444a944fff3d8 Mon Sep 17 00:00:00 2001 From: Sargam Date: Mon, 21 Oct 2024 00:20:53 +0530 Subject: [PATCH 6/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 81a0e36c3..4e1573251 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ chmod +x setup.sh # Traditional Docker Setup - (Optional) Start a PostgreSQL database using Docker: +(Optional) Start a PostgreSQL database using Docker: ```bash docker run -d \