Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 25, 2020 02:41 am GMT

Deploy Next JS app on AWS Amplify within 5 minutes with CI/CD

You can deploy static apps/website on AWS using S3 or Amplify. I prefer AWS Amplify and in this tutorial, I am going to quickly show you how you can deploy your Next.js app on AWS Amplify within 5 minutes with CI/CD.

I assume you already have next.js app ready, if not please clone this sample app.

Step 1:

From the AWS console, go to "AWS Amplify"
Alt Text

Once you are on the AWS Amplify homepage, select "Get started"
Alt Text

After that, under the "Deliver" section, click "Get started"
Alt Text

Step 2:

Select GitHub and then click "Continue" - it will ask you to authorize Github, if you need help please read step 1 of my previous article
Alt Text

Step 3:

Select repo, branch and then click "Next"
Alt Text

Step 4:

AWS Amplify will generate a build script for you automatically, but you will need to change it a little. Click on the "Edit" and change the build and artifacts sections:
Alt Text

The final build settings should look like this:

version: 1frontend:  phases:    preBuild:      commands:        - yarn install    build:      commands:        - yarn run export  artifacts:    baseDirectory: out    files:      - '**/*'  cache:    paths:      - node_modules/**/*
Enter fullscreen mode Exit fullscreen mode

Once you have updated the build settings, click "Save"
Alt Text

Click "Next"
Alt Text

Step 5:

Click "Save and deploy"
Alt Text

That's it. Once all the stages have been passed, you can click the link and see your app in action.
Alt Text

To test whether CI/CD (technically only CD) is working, make changes to your app and push them to your repo. They should be live after all the stages have passed.

Notes:

  • If you are not using yarn, please change the build settings accordingly (with npm)
  • We are using (Next.js static export)[https://nextjs.org/docs/advanced-features/static-html-export]
  • You can use the same procedure for hosting any front-end/static app (React, Vue, Angular, etc.) - even you can deploy Nuxt.js app
  • If you don't want to use static exports and need SSR then read this

Original Link: https://dev.to/mubbashir10/host-next-js-app-on-aws-within-5-minutes-with-ci-cd-1o0a

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To