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

36 lines
881 B
Bash

#!/bin/sh
set -e
echo "Starting entrypoint script..."
echo "Git version: $(git --version)"
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..."
echo "Git version: $(git --version)"
# Run the Medusa CLI generator silently with the desired options:
npx create-medusa-app@latest my-medusa-app \
--db-url "$DATABASE_URL" \
--no-browser \
--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.
echo "Starting Medusa server..."
exec npm run build
exec npm start