This is a skill for building Next.js App Router + Better Auth + PostgreSQL with Docker and deploying to Cloud Run.
Target Stack
- Framework: Next.js (App Router, TypeScript)
- Authentication: Better Auth
- DB: PostgreSQL 16
- Package manager: pnpm
- Infrastructure: Docker / Docker Compose、Google Cloud Run、Cloud SQL、Secret Manager
Reference Documents
Detailed procedures are split into the following reference files.
| File | Content |
|---|---|
references/local-setup.md |
Building the local development environment (Docker Compose + app Dockerization) |
references/cloud-run-deploy.md |
Deploying to Cloud Run (using Cloud SQL + Secret Manager) |
Which One to Refer To
- Want to build the local environment →
references/local-setup.mdRead - I want to deploy to Cloud Run →
references/cloud-run-deploy.mdRead - Want to do both →
local-setup.mdCompletecloud-run-deploy.mdthen proceed to
Summary of Environment Variable Switching
Keep track of the variables whose values change depending on the execution environment.
| Variable Name | Local Direct Execution | Docker Compose (app container) | Cloud Run |
|---|---|---|---|
DATABASE_URL host |
localhost |
db |
Cloud SQL Unix socket |
BETTER_AUTH_URL |
http://localhost:3000 |
http://localhost:3000 |
Cloud Run service URL |
INTERNAL_API_BASE_URL |
http://localhost:3000 |
http://app:3000 |
Cloud Run service URL |