Git Product home page Git Product logo

devops-for-web-development's Introduction

GitHub issues GitHub forks GitHub stars GitHub license

DevOps for Web Development

This is the code repository for DevOps for Web Development, published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.

Instructions and Navigation

All of the code is organized into folders. Each folder starts with a number followed by the application name. For example, Chapter02.

Code Snippet:

 <properties>
        <jpa.database>MYSQL</jpa.database>
        <jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
        <jdbc.url>jdbc:mysql://localhost:3306/petclinic?useUnicode=true</jdbc.url>
        <jdbc.username>root</jdbc.username>
        <jdbc.password>petclinic</jdbc.password>
    </properties>

Chapter 1:

You can find all the necessary code here for the chapter 1.

Chapter 2:

java -jar jenkins.war --httpPort=9999
java -jar jenkins.war --httpsPort=8888
java -jar slave.jar -jnlpUrl http://192.168.1.34:8080/computer/TestServer/slave-agent.jnlp -secret 65464e02c58c85b192883f7848ad2758408220bed2f3af715c01c9b01cb72f9b

Sonar.properties *Required metadata *

sonar.projectKey=java-sonar-runner-simple 
sonar.projectName=Simple Java project analyzed with the SonarQube Runner 
sonar.projectVersion=1.0

Comma-separated paths to directories with sources (required) onar.sources=src

Language sonar.language=java **Encoding of the source files ** sonar.sourceEncoding=UTF-8

Chapter 3:

echo 'Hello from Pipeline Demo'
stage 'Compile'
build 'PetClinic-Compile'
stage 'Test'
build 'PetClinic-Test'

echo 'Hello from Pipeline Demo'
stage 'Compile'
node {
  git url: 'https://github.com/mitesh51/spring-petclinic.git'
  def mvnHome = tool 'Maven3.3.1'
  sh "${mvnHome}/bin/mvn -B compile"
}
stage 'Test'
node('WindowsNode') {
  git url: 'https://github.com/mitesh51/spring-petclinic.git'
  def mvnHome = tool 'WindowsMaven'
  bat "${mvnHome}\\bin\\mvn -B verify"
  step([$class: 'ArtifactArchiver', artifacts: '**/target/*.war', fingerprint: true])  
  step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
}

Create a user with name admin and assign password and roles as below. 
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="cloud@123" roles="manager-script" />
Now, we need to add Tomcat's admin user that we created in the Maven setting file.
<servers>
<server>
  <id>tomcat-development-server</id>
  <username>admin</username>
  <password>password</password>
</server>
</servers>

Find Tomcat Plugin block in Pom.xml and add following details. Make sure that Server Name is same that we provided in settings.xml of Maven as Id:

<plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <server>tomcat-development-server</server>
			<url>http://192.168.1.35:9999/manager/text</url>
			<warFile>target\petclinic.war</warFile>
			<path>/petclinic</path>
                </configuration>
 </plugin>

Chapter 4:

rpm -ivh chef-12.9.41-1.el6.x86_64.rpm 
knife bootstrap 192.168.1.37 -x root -P cloud@123 -N tomcatserver
knife node run_list add tomcatserver"role[vtomcat]"

Chapter 5:

docker run -p 8180:8080 -d --name devopstomcat1devopstomcatnew

Chapter 6:

knife ec2 server create -I ami-1ecae776 -f t2.micro -N DevOpsVMonAWS --aws-access-key-id '< Your Access Key ID >' --aws-secret-access-key '< Your Secret Access Key >' -S book --identity-file book.pem --ssh-user ec2-user -r role[v-tomcat]

knife azure server create --azure-dns-name 'distechnodemo' --azure-vm-name 'dtserver02' --azure-vm-size 'Small' -N DevOpsVMonAzure2 --azure-storage-account 'classicstorage9883' --bootstrap-protocol 'cloud-api' --azure-source-image '5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS-67-20160310' --azure-service-location 'Central US' --ssh-user 'dtechno' --ssh-password 'cloud@321' -r role[v-tomcat] --ssh-port 22

Chapter 7:

FROM tomcat:8.0

MAINTAINER Mitesh<[email protected]>

COPY tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml

Chapter 8:

java -jar newrelic.jar install

Chapter 9:

ssh -t -t [email protected] "ifconfig; rvm use 2.1.0; knife ec2 server create -I ami-1ecae776 -f t2.micro -N DevOpsVMonAWS1 --aws-access-key-id '<YOUR ACCESS KEY ID>' --aws-secret-access-key '<YOUR SECRET ACCESS KEY>' -S book --identity-file book.pem --ssh-user ec2-user -r role[v-tomcat]"

ssh -t -t [email protected] "ifconfig; rvm use 2.1.0; knife ec2 server create -I ami-1ecae776 -f t2.micro -N DevOpsVMonAWS1 --aws-access-key-id '<YOUR ACCESS KEY ID>' --aws-secret-access-key '<YOUR SECRET ACCESS KEY>' -S book --identity-file book.pem --ssh-user ec2-user -r role[v-tomcat]"

java -jar slave.jar -jnlpUrl http://192.168.1.35:8080/computer/TestServer/slave-agent.jnlp -secret 65464e02c58c85b192883f7848ad2758408220bed2f3af715c01c9b01cb72f9b

ssh  -i /home/mitesh/book.pem -o StrictHostKeyChecking=no -t -t [email protected] "sudo usermod -a -G tomcat ec2-user; sudo chmod -R g+w /var/lib/tomcat6/webapps; sudo service tomcat6 stop;" 
scp  -i /home/mitesh/book.pem /home/mitesh/target/*.war [email protected]:/var/lib/tomcat6/webapps
ssh  -i /home/mitesh/book.pem -o StrictHostKeyChecking=no -t -t [email protected] "sudo service tomcat6 start"

node('Master') {
   // Mark the code checkout 'stage'
   stage 'Checkout'

   // Get code for PetClinic Application from a GitHub repository
   git url: 'https://github.com/mitesh51/spring-petclinic.git'

   // Get the maven tool.
   // This ' Maven3.3.1' maven tool must be configured in the global  configuration.           
   def mvnHome = tool 'Maven3.3.1'

   // Mark the code Compile 'stage'....
   stage 'Compile'
   // Run the maven build
   sh "${mvnHome}/bin/mvn clean compile"

   // Mark the code for Unit test execution and package 'stage'....
   stage 'Test&Package'
   sh "${mvnHome}/bin/mvn clean package"

   // Mark the code Cloud provisioning 'stage' where instance is allocated in Amazon EC2
// Once Instance is available, Chef will be used for Configuration Management
// knife ec2 plugin will be used for instance provisioning in the AWS cloud
   stage 'Cloud Provisioning'
   sh "ssh -t -t [email protected] 'ifconfig; rvm use 2.1.0; knife ec2 server create -I ami-1ecae776 -f t2.micro -N DevOpsVMonAWS9 --aws-access-key-id xxxxxxxxxxxxxxxxxxxx --aws-secret-access-key xxxxxxxxxxxxxxxxxxxxxxxxxxxxx -S book --identity-file book.pem --ssh-user ec2-user -r role[v-tomcat]'"
}

Related DevOps Products:

Suggestions and Feedback

Click here if you have any feedback or suggestions.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781786465702

devops-for-web-development's People

Contributors

packt-itservice avatar packtutkarshr avatar vishalmewadapackt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.