DevOps Project
Objective and Approach | - Bridge the gap between production and development by containerizing the website ‘Explore California’ with Docker and Docker Compose - Unit and Integration testing using RSpec, Capybara and Selenium - Rapidly deploy a working instance of the website into the cloud (AWS S3) using Terraform - Build and deploy the website using CICD pipeline with Jenkins |
Impact | - All environments consistent using Docker/ Docker Compose - Deploys into production automated via Terraform - Production deploys 100% automated through CI |
Primary Technology: Docker, Docker Compose, RSpec, Capybara, Selenium, AWS S3, Terraform, Jenkins
sudo apt-get install docker-engine -y
vim Dockerfile
docker build --tag website .
docker run --publish 80:80 website
vim docker-compose.yml
o
docker-compose up
To write some automated tests for the website, we will use RSpec, Capybara, and Selenium.
RSpec is a Ruby-based testing framework. It is a domain-specific language or DSL.
Capybara is a tool that let's you use a web driver to create a browser and interact with the website.
Selenium is a web driver that spins up a real web browser and tests against whatever the web browser sees.
Create a folder spec. Create another folder unit within spec. Now, create a file page_spec.rb
vim spec/unit/page_spec.rb
vim rspec.docerfile
vim docker-compose.yml
docker-compose up -d website
docker-compose run -rm unit-tests
docker-compose config
docker-compose up -d website
vim page_spec.rb
vim page_spec.rb
docker-compose run -rm unit-tests
vim docker-compose.yml
docker-compose up -d website selenium
docker-compose run --rm unit-tests
vim terraform.Dockerfile
docker build -t terraform .
docker build -t terraform . -f terraform.Dockerfile
docker run --rm --interactive --tty --entrypoint sh terraform
docker build --tag terraform --file terraform.Dockerfile .
docker run --rm terraform
vim docker-compose.yml
docker-compose build terraform
docker-compose run --rm terraform
docker-compose run --rm terraform init
vim docker-compose.yml
To add AWS access keys
docker-compose run --rm terraform plan
docker-compose run --rm aws
docker-compose run --rm --entrypoint aws aws ec2 describe-instances
docker-compose run --rm --entrypoint aws aws s3 cp --recursive website/ s3://explorecalifornia.org
docker-compose run --rm terraform output
vim page_spec.rb
docker-compose run --rm terraform plan
docker-compose run --rm terraform apply
vim docker-compose.yml
docker-compose up -d selenium
docker-compose run --rm integration-tests
docker-compose run --rm aws aws s3 cp website/ s3://explorecalifornia.org --recursive
docker-compose run --rm aws aws s3 r website/ s3://explorecalifornia.org --recursive
docker-compose run --rm terraform destroy
vim jenkins.Dockerfile
vim docker-compose.yml
docker-compose up jenkins
git init
git checkout -b master
git add -A
git commit -m "Initialize repository"
docker-compose up jenkins