Skip to content

Latest commit

 

History

History
113 lines (79 loc) · 4.53 KB

README.md

File metadata and controls

113 lines (79 loc) · 4.53 KB

Application Build Coverage Vulnerabilities Quality Gate Status

nextjs-template

A template project to create NextJS skeleton with typescript

This is a Next.js project bootstrapped with create-next-app.

Build & Test

npm run build

Test

npm test

Run development server

npm run dev

Build and run docker container locally

The following commands build and run a production equivalent container

  1. Build the project
npm ci
npm run build
  1. Build the docker container
docker build . -t nextjs-template
  1. Run the docker container
docker run -d -p 3000:3000 -t nextjs-template:latest

Initial Project Setup

To set up the project by forking this project, then the following instructions need to be carried out. Please read these instructions carefully to ensure no steps are missed out.

SonarCloud

For code quality checks we use SonarCloud and the project must be setup in SonarCloud.

  1. Login to SonarCloud
  2. Click the + and then Analyze new project
  3. Select the GitHub project you have created with this template
  4. Click Setup
  5. Disable Automatic Analysis
  6. Update sonar-project.properties with the correct information for the project key and git repository

next.config.js

  1. Modify the basePath configuration to match the application. See Base Path documentation for more.

README.md

  1. Update the links to the badges
  2. Update all references for nextjs-template After cloning this template please do the following to ensure your project builds and deploys correctly

package.json

  • name
  • version
  • repository
  • description
  • license

Versions

We follow semantic versioning where possible. Generally we do not update versions unless there has been a breaking change in our service contracts.

The versions can be increased in the GitHub Action file when required.

Deployment

This project uses Terraform to deploy the service to the PreviewMe ECS cluster.

ECR repository Deployment

The following changes need to be made in the Terraform configuration.

  1. In deployment/ecr/backend.tf replace the workspace name to match the project name E.g: foo-ecr

ECS Deployment

The following steps need to be carried out for the Terraform configuration for the docker container to be deployed correctly.

  1. In deployment/service/backend.tf replace the workspace tags with the name of the project E.g: foo.
  2. In deployment/service/main.tf modify the locals.workspace variable to match your tag name in step 1.
  3. In deployment/service/variables.tf modify the default values to match the application.
  4. In deployment/service/networking.tf modify any configuration to match the application.
  5. Change to deployment/service folder and run terraform init to initialise the project.
    1. If prompted to create a workspace create the value ${application-name}-production. E.g: foo-production.
  6. Create a development workspace by running terraform workspace new ${application-name}-development E.g: foo-development.
  7. Update condition on the deploy-production job in build.yml to match the deploy-development when the service is production ready.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!