medusa-js-2-docker/entrypoint.sh
2025-04-09 20:00:36 +10:00

36 lines
1.1 KiB
Bash

#!/bin/sh
set -e
PROJECT_DIR="/app/my-medusa-app"
# Check if the Medusa project has already been created.
if [ ! -d "$PROJECT_DIR" ]; then
echo "Medusa project not found. Running installation..."
# Run the Medusa CLI generator silently with the desired options:
# --db-url: Uses the provided DATABASE_URL to connect and run migrations.
# --no-browser: Skip opening the admin dashboard.
# --directory-path: Specify where to install the project.
# --seed: Seed the database with demo data.
npx create-medusa-app@latest my-medusa-app \
--db-url "$DATABASE_URL" \
--no-browser \
--directory-path "$PROJECT_DIR" \
--with-nextjs-starter
# Change into the project folder, install dependencies and build the app.
cd "$PROJECT_DIR"
npm install
npm run build
else
echo "Medusa project already exists. Skipping installation."
fi
# Change directory to the Medusa project folder.
cd "$PROJECT_DIR"
# Finally, start the Medusa server in development/production mode as desired.
# For example, here we run the development server:
echo "Starting Medusa server..."
exec npm start