Conversation
| @@ -0,0 +1,3 @@ | |||
| #!/bin/bash | |||
|
|
|||
| node server.js No newline at end of file | |||
There was a problem hiding this comment.
Two updates for this line:
server.jsis understandalonedirectory.- Adding
execto allow the nodejs process to receive SIGTERM for graceful shutdown.
exec node standalone/server.js
There was a problem hiding this comment.
server.js is at the root of the artifacts directory, so I updated to exec node server.js
$ pwd
aws-lambda-web-adapter/examples/nextjs-zip/.aws-sam/build/NextjsFunction
$ tree -I node_modules/
.
├── .next
├── node_modules
├── package.json
├── public
│ ├── favicon.ico
│ └── vercel.svg
├── run.sh
└── server.jsThere was a problem hiding this comment.
I built this example. The server.js was under standalone folder. If this is not intended, the build command in the Makefile should be checked.
[ec2-user@ip-172-31-42-124 nextjs-zip]$ ls -l .aws-sam/build/NextjsFunction/
total 4
-rw-rw-r-- 1 ec2-user ec2-user 44 Sep 2 15:28 run.sh
drwxrwxr-x 5 ec2-user ec2-user 90 Sep 2 15:28 standalone
There was a problem hiding this comment.
Hmm, I can't reproduce. You're running sam build from nextjs-zip directory?
There was a problem hiding this comment.
Yes. I run sam build from nextjs-zip directory on an ec2 instance. The OS is Amazon Linux 2. The shell is bash.
receive SIGTERM for graceful shutdown
| cp -r .next/static/ .next/standalone/.next/static | ||
|
|
||
| # Copy artifacts for deployment | ||
| cp -r .next/standalone/ $(ARTIFACTS_DIR) |
There was a problem hiding this comment.
Change this line to this: cp -r .next/standalone/. $(ARTIFACTS_DIR)
This works on both LInux and Macos.
There was a problem hiding this comment.
Please also look at other copy commands in the Makefile.
|
@julianbonilla This is a great example. Thanks for the contribution! |
Issue #, if available:
Description of changes:
Add an example for Next.js 12 using Zip package type.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.