Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Instant Project Online #1494

Merged
merged 6 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading