phases: It contains commands that AWS CodeBuild will run during each phase of the build.
install: This represents the commands that AWS CodeBuild will run during installation. It is recommended to use the install phase only for installing packages in the build environment, for example:
pre_build: This represents the commands that AWS CodeBuild will run before the build.
build: This contains the commands that AWS CodeBuild will run during the build. For example:
build: commands: - echo Build started on `date` - mvn install
post_build: This contains the commands that AWS CodeBuild will run after the build. For example, you might use Maven to package the build artifacts into a JAR or WAR file.
artifacts: This represents the information about where AWS CodeBuild can find the build output and how AWS CodeBuild will prepare it so that it can be uploaded to the Amazon S3 output bucket.
That was all about how we can write the buildspec.yml file according to our need. Now, let's write a buildspec.yml file for our NodeJS application. This time, we are using the npm tool to build the application.
Before proceeding, make sure you clone the code from GitHub (https://github.com/awsstar/CB-NodeJS-BS.git ) and create a new repository in CodeCommit and migrate the GitHub code to the newly created CodeCommit repository.
Let's take a look at the BuildSpec.yml file that we will be checking in with the application code: