Skip to content

fix: update setup.sh script for better error handling for Docker and … #1820

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
53 changes: 42 additions & 11 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,62 @@
# Copies .env.example and changes it to .env so that future commands can find the env file
cp .env.example .env
# Exit on any error
set -e

# Copy .env.example to .env
if ! cp .env.example .env; then
echo "Error: Failed to copy .env.example to .env."
exit 1
fi
echo "Copied .env.example to .env..."

# Start PostgreSQL container
docker run -d \
echo "Starting PostgreSQL container..."
if ! docker run -d \
--name cms-db \
-e POSTGRES_USER=myuser \
-e POSTGRES_PASSWORD=mypassword \
-e POSTGRES_DB=mydatabase \
-p 5432:5432 \
postgres
postgres; then
echo "Error: Failed to start PostgreSQL container."
exit 1
fi

# Wait for the PostgreSQL container to be ready
echo "Waiting for PostgreSQL to be ready..."
sleep 10
sleep 10 # You can adjust the sleep time if needed

# Install dependencies
pnpm install
# Install dependencies using pnpm
echo "Installing dependencies..."
if ! pnpm install; then
echo "Error: Failed to install dependencies."
exit 1
fi

# Run Prisma migrations
pnpm run prisma:migrate
echo "Running Prisma migrations..."
if ! pnpm run prisma:migrate; then
echo "Error: Prisma migration failed."
exit 1
fi

# Generate Prisma client
pnpm prisma generate
echo "Generating Prisma client..."
if ! pnpm prisma generate; then
echo "Error: Failed to generate Prisma client."
exit 1
fi

# Seed the database
pnpm run db:seed
echo "Seeding the database..."
if ! pnpm run db:seed; then
echo "Error: Database seeding failed."
exit 1
fi

# Start the development server
pnpm run dev
echo "Starting development server..."
if ! pnpm run dev; then
echo "Error: Failed to start the development server."
exit 1
fi