Skip to content

Commit

Permalink
feat: Instant Project Online (#1494)
Browse files Browse the repository at this point in the history
* Instant Fork & Run

* Instant Fork & Run

* fix readme typo

* Update .env.example

* Update README.md

* Update README.md

---------

Co-authored-by: adiiittt <[email protected]>
Co-authored-by: Sargam <[email protected]>
  • Loading branch information
3 people authored Oct 20, 2024
1 parent d2cb0f3 commit fc637b5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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/cms?schema=public"
NEXTAUTH_URL="http://localhost:3000"
APPX_AUTH_KEY="AUTH_SECRET"
NEXTAUTH_SECRET="NEXTAUTH_SECRET"
Expand Down
37 changes: 24 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.sh
# Runs the setup script file
./setup.sh
```

# Traditional Docker Setup

(Optional) Start a PostgreSQL database using Docker:

```bash
docker run -d \
Expand All @@ -35,45 +51,40 @@ 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.

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
Expand Down
31 changes: 31 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fc637b5

Please sign in to comment.