How to Deploy a Web + API Monorepo
Next.js frontend and Flask API from the same repo, deployed as two apps.
Repo structure
my-project/
├── web/ # Next.js frontend
│ ├── Dockerfile
│ ├── package.json
│ └── ...
├── api/ # Flask API
│ ├── Dockerfile
│ ├── requirements.txt
│ ├── app.py
│ └── ...
└── README.md
Each subdirectory has its own Dockerfile. PromptShip builds from the directory you specify with root_dir.
How do I deploy both?
Step 1: Create the frontend app
create_app(
name: "myapp-web",
github_repo: "github.com/me/my-project"
)
configure_app(app_name: "myapp-web", root_dir: "web")
Step 2: Create the API app (same repo, different root_dir)
create_app(
name: "myapp-api",
github_repo: "github.com/me/my-project"
)
configure_app(app_name: "myapp-api", root_dir: "api")
Step 3: Attach a database to the API
attach_postgres(app_name: "myapp-api", environment: "dev", tier: "pg-1")
Step 4: Deploy both
deploy_app(app_name: "myapp-web", branch: "main")
deploy_app(app_name: "myapp-api", branch: "main")
Results:
- Frontend:
https://myapp-web-dev.promptship.dev - API:
https://myapp-api-dev.promptship.dev
Custom domains: Point app.example.com to your frontend and api.example.com to your API using set_domain.
How does root_dir work?
When you set root_dir: "web", PromptShip looks for the Dockerfile inside web/ and uses that directory as the Docker build context. The same repo can power any number of apps with different root directories.
