From bab3916a436a8081ce9703e49ac4964b7efc0b2a Mon Sep 17 00:00:00 2001 From: Florent Huck Date: Mon, 2 Dec 2024 21:19:58 +0100 Subject: [PATCH 1/3] Next.js config example aligned with project:init result + name of the app --- sites/upsun/src/get-started/stacks/nextjs.md | 48 +++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/sites/upsun/src/get-started/stacks/nextjs.md b/sites/upsun/src/get-started/stacks/nextjs.md index 17544b4181..10c30416ea 100644 --- a/sites/upsun/src/get-started/stacks/nextjs.md +++ b/sites/upsun/src/get-started/stacks/nextjs.md @@ -24,13 +24,13 @@ To create your Next.js app, follow these steps. To fast track the process, run the following commands: ```bash {location="Terminal"} - npx create-next-app@latest + npx create-next-app@latest myapp ``` 2. To initialize the local Git repository and commit local files, run the following commands: ```bash {location="Terminal"} - cd my-app + cd myapp git init git add . git commit -m "Init Next.js application." @@ -81,7 +81,7 @@ title=Using the Console 2. Click **Create from scratch**. 3. Fill in details like the project name and [region](/development/regions.md). - + {{% note %}} You can define resources for your project later on, after your first push. @@ -171,7 +171,7 @@ They are located in a `.{{% vendor/cli %}}/` folder at the root of your source c and structured in a similar way to this: ```txt -my-express-app +myapp ├── .{{% vendor/cli %}} │ └── config.yaml ├── [.environment] @@ -184,19 +184,35 @@ To generate these files, run the following command at the root of your project: {{% vendor/cli %}} project:init ``` -Follow the prompts. +Follow the prompts, and you should result in such a config file. ```yaml {configFile="apps"} applications: - myapp: - type: "nodejs:20" - hooks: - build: | - set -eux - npm run build - web: - commands: - start: npm run start -- -p $PORT + myapp: + source: + root: "/" + type: "nodejs:{{% latest "nodejs" %}}" + mounts: + "/.npm": + source: "storage" + source_path: "npm" + hooks: + build: | + set -eux + npm i + npm run build + web: + commands: + start: npm run start -p $PORT + upstream: + socket_family: tcp + locations: + "/": + passthru: true + +routes: + "https://{all}/": { type: upstream, upstream: "myapp:http" } + "http://{all}/": { type: redirect, to: "https://{all}/" } ``` As an example, above is the minimum configuration needed to deploy a Next.js application on {{% vendor/name %}} without any services. @@ -305,7 +321,7 @@ To make changes to your project, follow these steps: --- a/views/index.jade +++ b/views/index.jade @@ -2,4 +2,4 @@ extends layout - + block content h1= title - p Welcome to #{title} @@ -337,7 +353,7 @@ To make changes to your project, follow these steps: {{% vendor/cli %}} environment:delete feat-a git fetch --prune ``` - + Note that deploying to production is fast because the image built for the `feat-a` environment is reused. For a long running branch, to keep the code up-to-date with the main branch, use `git merge main` or `git rebase main`. From 95f4232e4ca5be4a18f854074a022e2ce4b7ab7f Mon Sep 17 00:00:00 2001 From: Florent Huck Date: Tue, 3 Dec 2024 09:03:01 +0100 Subject: [PATCH 2/3] replace {all} by {default} --- sites/upsun/src/get-started/stacks/nextjs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sites/upsun/src/get-started/stacks/nextjs.md b/sites/upsun/src/get-started/stacks/nextjs.md index 10c30416ea..fdc613dd5a 100644 --- a/sites/upsun/src/get-started/stacks/nextjs.md +++ b/sites/upsun/src/get-started/stacks/nextjs.md @@ -211,8 +211,8 @@ applications: passthru: true routes: - "https://{all}/": { type: upstream, upstream: "myapp:http" } - "http://{all}/": { type: redirect, to: "https://{all}/" } + "https://{default}/": { type: upstream, upstream: "myapp:http" } + "http://{default}/": { type: redirect, to: "https://{default}/" } ``` As an example, above is the minimum configuration needed to deploy a Next.js application on {{% vendor/name %}} without any services. From aa7c604d75af5ae2c51889541b9842f6d8086be3 Mon Sep 17 00:00:00 2001 From: Florent Huck Date: Wed, 4 Dec 2024 15:03:29 +0100 Subject: [PATCH 3/3] indentation issue on snippet --- sites/upsun/src/get-started/stacks/nextjs.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sites/upsun/src/get-started/stacks/nextjs.md b/sites/upsun/src/get-started/stacks/nextjs.md index fdc613dd5a..55bbbba24c 100644 --- a/sites/upsun/src/get-started/stacks/nextjs.md +++ b/sites/upsun/src/get-started/stacks/nextjs.md @@ -193,9 +193,9 @@ applications: root: "/" type: "nodejs:{{% latest "nodejs" %}}" mounts: - "/.npm": - source: "storage" - source_path: "npm" + "/.npm": + source: "storage" + source_path: "npm" hooks: build: | set -eux