Continuous Integration and Deployment

Continuous Integration and Deployment

Travis setup

sudo: required
services:
  - docker

before_install:
  -docker build -t dsouzareuben79964/docker-react -f Dockerfile.dev .

script:
  - docker run -e CI=true dsouzareuben79964/docker-react npm run test

"sudo: required" indicates that sudo (superuser) permissions are required for the build.

"services" Specifies the services needed for the build. In this case, it's Docker.

"before_install" This is a script that runs before the installation. Here, it's used to build a Docker image based on the provided Dockerfile. The -t flag is used to tag the image, and the -f flag is used to specify the Dockerfile.

"docker run" This command runs a command in a new container. "npm run test" This is the command to run your tests.

Now push these files into the repository

Then go to Travis CI

Elastic Beanstalk

changes to be made in Travis.yml

sudo: required
language: generic

services:
  - docker

before_install:
  - docker build -t dsouzareuben79964/docker-react -f Dockerfile.dev .

script:
  - docker run -e CI=true dsouzareuben79964/docker-react npm run test

deploy:
   provider: elasticbeanstalk
   region: "eu-north-1"
   app: "docker-project"
   env: "Docker-project-env"
   bucket_name: "elasticbeanstalk-eu-north-1-604863143682"
   bucket_path: "docker-project"
   on:
      branch: master

provider: elasticbeanstalk: Specifies that you are using Elastic Beanstalk as the deployment provider.

region: "eu-north-1": Specifies the AWS region where the Elastic Beanstalk environment is located. In this case, it's "eu-north-1" (Stockholm region).

app: "docker-project": Specifies the name of the Elastic Beanstalk application. It looks like the application is named "docker-project."

env: "Docker-project-env": Specifies the name of the Elastic Beanstalk environment. It seems to be named "Docker-project-env."

bucket_name: "elasticbeanstalk-eu-north-1-604863143682": Specifies the name of the S3 bucket where the deployment artifacts are stored. In Elastic Beanstalk, this is typically the bucket used to store application versions.

bucket_path: "docker-project": Specifies the path within the S3 bucket where the deployment artifacts are stored. In this case, it's under the path "docker-project."

on: branch: master: Specifies that the deployment should be triggered when changes are pushed to the "master" branch of your version control system (like Git). This means that the deployment process will be automatically initiated when code changes are detected on the master branch.

Did you find this article valuable?

Support Reuben's blog by becoming a sponsor. Any amount is appreciated!