英文:
Deploy next js app to aws ec2 through codedeploy
问题
我创建了一个新的NextJS应用程序,没有进行任何更改,只有基本的样板文件、代码和文件夹。然后将其推送到CodeCommit存储库。已经有一个正常工作的CodePipeline,只是交换了源阶段。部署在第3步时失败,这是在创建替代实例并且目标组显示原始实例健康但新实例给出了403错误代码的地方。
对于appspec.yml文件,我已将源设置为/
,因为这是Next JS文档中提到的内容。我还尝试将其设置为pages/_app.js
和/app.js
,因为Fireship提到它们作为入口点。但都没有起作用,CodeDeploy一直失败。我与AWS支持团队进行了沟通,我们将问题缩小到Next JS引起的问题。
如果您也在运行NextJS应用程序并通过CodeDeploy和CodePipeline部署到EC2,您将源路径设置为什么?无论是在appspec中还是在目标组健康检查中。我是否需要像这个SO线程中提到的那样使用Docker和Kubernetes?或者失败是由其他需要检查的原因引起的?
英文:
I created a new NextJS app, no changes just the basic boilerplate files, code, and folders. and pushed it to a CodeCommit repo. Already had a working CodePipeline and just swapped Source stages. Deployments are failing on Step 3, where a replacement instance is created, and Target Group shows the original instance is healthy but new instances are given a 403 error code.
For the appspec.yml file, I've set the source to /
b/c that's what the Next JS docs said. I also tried setting it to pages/_app.js
and /app.js
b/c that's what Fireship mentioned as the entry. None have worked and codedeploy keeps failing. I talked to AWS Support and we narrowed it to Next JS causing the issue.
If you're also running a NextJS app and deploying it to EC2 through CodeDeploy and CodePipeline, what did you set the source path to? For both the appspec and Target Group health check. Do I need to use Docker and Kubernetes like this SO Thread? Or are the failures caused by something else I should check?
答案1
得分: -1
不使用EC2和CodeDeploy,而是按照此AWS文档使用Amplify来构建和部署您的NextJS应用程序。这是使用自定义域名的链接:https://docs.aws.amazon.com/amplify/latest/userguide/to-add-a-custom-domain-managed-by-amazon-route-53.html
英文:
Instead of using EC2 and CodeDeploy, follow this AWS Doc and use Amplify to build and deploy your NextJS app. This is the link for using a custom domain: https://docs.aws.amazon.com/amplify/latest/userguide/to-add-a-custom-domain-managed-by-amazon-route-53.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论