Skip to content

Commit 88429d6

Browse files
committed
Init
0 parents  commit 88429d6

File tree

9 files changed

+762
-0
lines changed

9 files changed

+762
-0
lines changed

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
32+
# local env files
33+
.env*.local
34+
35+
# vercel
36+
.vercel
37+
38+
# typescript
39+
*.tsbuildinfo
40+
next-env.d.ts

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM node:18-alpine AS base
2+
3+
# Stage 1: Install dependencies
4+
FROM base AS deps
5+
WORKDIR /app
6+
COPY package.json pnpm-lock.yaml ./
7+
RUN pnpm install --frozen-lockfile
8+
9+
# Stage 2: Build the application
10+
FROM base AS builder
11+
WORKDIR /app
12+
COPY --from=deps /app/node_modules ./node_modules
13+
COPY . .
14+
RUN pnpm run build
15+
16+
# Stage 3: Production server
17+
FROM base AS runner
18+
WORKDIR /app
19+
ENV NODE_ENV=production
20+
COPY --from=builder /app/.next/standalone ./
21+
COPY --from=builder /app/.next/static ./.next/static
22+
23+
EXPOSE 3000
24+
CMD ["node", "server.js"]

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Deploy Next.js to Google Cloud Run
2+
3+
This is a Next.js template which can be deployed to [Google Cloud Run](https://cloud.google.com/run/docs).
4+
5+
## Deploying to Google Cloud Run
6+
7+
This template can be used to deploy your Next.js application as a Docker container.
8+
9+
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/docs/install) so you can use `gcloud` on the command line.
10+
1. Run `gcloud auth login` to log in to your account.
11+
1. [Create a new project](https://cloud.google.com/run/docs/quickstarts/build-and-deploy) in Google Cloud Run (e.g. `nextjs-docker`). Ensure billing is turned on.
12+
1. Build your container image using Cloud Build: `gcloud builds submit --tag gcr.io/PROJECT-ID/helloworld --project PROJECT-ID`. This will also enable Cloud Build for your project.
13+
1. Deploy to Cloud Run: `gcloud run deploy --image gcr.io/PROJECT-ID/helloworld --project PROJECT-ID --platform managed --allow-unauthenticated`. Choose a region of your choice.
14+
15+
- You will be prompted for the service name: press Enter to accept the default name, `helloworld`.
16+
- You will be prompted for [region](https://cloud.google.com/run/docs/quickstarts/build-and-deploy#follow-cloud-run): select the region of your choice, for example `us-central1`.
17+
18+
For more information, see the Next.js [deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying#self-hosting).
19+
20+
## Learn More
21+
22+
To learn more about Next.js, take a look at the following resources:
23+
24+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
25+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
26+
27+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

app/layout.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Metadata } from 'next';
2+
3+
export const metadata: Metadata = {
4+
title: 'Next.js on Google Cloud Run',
5+
description: 'Deploy your Next.js application to Google Cloud Run',
6+
};
7+
8+
export default function RootLayout({
9+
children,
10+
}: Readonly<{
11+
children: React.ReactNode;
12+
}>) {
13+
return (
14+
<html lang="en">
15+
<body>{children}</body>
16+
</html>
17+
);
18+
}

app/page.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function Home() {
2+
return (
3+
<main>
4+
<div>Next.js on Google Cloud Run</div>
5+
</main>
6+
);
7+
}

next.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { NextConfig } from 'next';
2+
3+
const nextConfig: NextConfig = {
4+
output: 'standalone',
5+
};
6+
7+
export default nextConfig;

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "next dev --turbo",
5+
"build": "next build",
6+
"start": "node .next/standalone/server.js"
7+
},
8+
"dependencies": {
9+
"react": "19.0.0-rc-cd22717c-20241013",
10+
"react-dom": "19.0.0-rc-cd22717c-20241013",
11+
"next": "15.0.0-canary.196"
12+
},
13+
"devDependencies": {
14+
"typescript": "^5",
15+
"@types/node": "^20",
16+
"@types/react": "^18",
17+
"@types/react-dom": "^18"
18+
}
19+
}

0 commit comments

Comments
 (0)