Prompt file imported from gisioraelvis/medusajs-dtc-docker-starter (
.github/prompts/backend-seed.prompt.md). Copyright stays with the author.
Run the full backend setup sequence for this Medusa project. Perform each step in order:
-
Run database migrations (from
apps/backend):cd apps/backend && pnpm medusa db:migrate -
Seed the database:
pnpm seedIf the seed script fails with "already seeded" or a unique-constraint error, that's fine — continue.
-
Create an admin user (use the email/password from the argument if provided, otherwise default to
admin@example.com/supersecret):- Docker:
docker compose exec medusa sh -c "cd /server/apps/backend && pnpm medusa user -e <email> -p <password>" - Local:
cd apps/backend && pnpm medusa user -e <email> -p <password>
- Docker:
-
Retrieve the publishable API key — query the database and print it:
- Docker:
docker compose exec postgres psql -U postgres -d medusa-store -c "SELECT value FROM api_key WHERE title ILIKE '%publishable%' LIMIT 1;" - Local:
psql -U postgres -d medusa-store -c "SELECT value FROM api_key WHERE title ILIKE '%publishable%' LIMIT 1;"
- Docker:
-
Set the key in
apps/storefront/.env:NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_... -
Restart the storefront (Docker only):
docker compose up storefront -d
After completing all steps, confirm what was done and print the publishable key so it can be verified.