diff --git a/Dockerfile b/Dockerfile index 773a337..d1bce7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM tomcat -ADD target/addressbook.war /usr/local/tomcat/webapps +FROM tomcat:8.5 +ADD target/addressbook.war /usr/local/tomcat/webapps/addressbook.war EXPOSE 8080 -CMD /usr/local/tomcat/bin/catalina.sh run +CMD ["catalina.sh", "run"] diff --git a/README.md b/README.md index ecea866..f2dbe10 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Addressbook Tutorial V2.9 - +hello This tutorial teaches you some of the basic concepts in [Vaadin Framework](https://vaadin.com). It is meant to be a fast read for learning how to get started - not an example on how application should be @@ -34,6 +34,7 @@ To get the project up and running in IDEA, do: You should now have a Jetty server running on localhost:8080. Navigate to http://localhost:8080 to play with the application + Importing in NetBeans 8 -------------------- These instructions were tested on NetBeans 8.0.2. You can get it from https://www.netbeans.org diff --git a/ansible-deploy-playbook-QA.yaml b/ansible-deploy-playbook-QA.yaml new file mode 100644 index 0000000..2b76f43 --- /dev/null +++ b/ansible-deploy-playbook-QA.yaml @@ -0,0 +1,22 @@ +--- +- name: Check and deploy Docker container + hosts: QA + become: true + + tasks: + - name: Check if container is running + command: docker ps -q --filter "name=addressbook" + register: container_check + failed_when: false + changed_when: false + + - name: Stop and remove container if running + command: docker rm -f addressbook + when: container_check.stdout != "" + + - name: Remove image if exists + command: docker pull devopsclass2022/address-app + ignore_errors: true + + - name: Deploy new container + command: docker run -itd -p 7000:8080 --name addressbook devopsclass2022/address-app \ No newline at end of file diff --git a/ansible-deploy-playbook-Staging.yaml b/ansible-deploy-playbook-Staging.yaml new file mode 100644 index 0000000..16033a6 --- /dev/null +++ b/ansible-deploy-playbook-Staging.yaml @@ -0,0 +1,22 @@ +--- +- name: Check and deploy Docker container + hosts: staging + become: true + + tasks: + - name: Check if container is running + command: docker ps -q --filter "name=addressbook" + register: container_check + failed_when: false + changed_when: false + + - name: Stop and remove container if running + command: docker rm -f addressbook + when: container_check.stdout != "" + + - name: Remove image if exists + command: docker pull devopsclass2022/address-app + ignore_errors: true + + - name: Deploy new container + command: docker run -itd -p 7000:8080 --name addressbook devopsclass2022/address-app \ No newline at end of file diff --git a/ansible-docker-deploy-playbook.yaml b/ansible-docker-deploy-playbook.yaml new file mode 100644 index 0000000..2b76f43 --- /dev/null +++ b/ansible-docker-deploy-playbook.yaml @@ -0,0 +1,22 @@ +--- +- name: Check and deploy Docker container + hosts: QA + become: true + + tasks: + - name: Check if container is running + command: docker ps -q --filter "name=addressbook" + register: container_check + failed_when: false + changed_when: false + + - name: Stop and remove container if running + command: docker rm -f addressbook + when: container_check.stdout != "" + + - name: Remove image if exists + command: docker pull devopsclass2022/address-app + ignore_errors: true + + - name: Deploy new container + command: docker run -itd -p 7000:8080 --name addressbook devopsclass2022/address-app \ No newline at end of file diff --git a/ansible-inv b/ansible-inv new file mode 100644 index 0000000..e69de29 diff --git a/java-app-target.yaml b/java-app-target.yaml new file mode 100644 index 0000000..4dc9285 --- /dev/null +++ b/java-app-target.yaml @@ -0,0 +1,17 @@ +--- +- hosts: all +# become: yes + tasks: +#### copy a file + - name: copy file + copy: + src: /var/lib/jenkins/workspace/ansible-jenkins-int/target/addressbook.war + dest: /tmp + - name: Run Docker container + become: true + docker_container: + name: my_container + image: my_image:latest + state: started + ports: + - "9000:80" diff --git a/jenkinsfile b/jenkinsfile new file mode 100644 index 0000000..92750ec --- /dev/null +++ b/jenkinsfile @@ -0,0 +1,66 @@ +pipeline { + agent any + + environment { + + DOCKERHUB_CREDENTIALS= credentials('docker-hub-credentials') + + } + + stages { + stage('compile') { + steps { + echo 'Compiling Stage' + git 'https://github.com/awsdevopsclass2022/DevOpsClassCodes-aug.git' + sh 'mvn compile' + } + } + stage('test') { + steps { + echo 'Testing Stage' + sh 'mvn test' + } + } + stage('package') { + steps { + echo 'Package Stage' + sh 'mvn package' + } + } + stage('Docker Build') { + steps { + echo 'Docker docker build stage' + sh 'docker build -t devopsclass2022/address-app:${JOB_NAME}-${BUILD_NUMBER} .' + //sh 'docker login -u devopsclass2022 -p Done24Money@' + // sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' + + } + } + + + stage('Docker Login') { + steps { + + //sh 'docker login -u devopsclass2022 -p Done24Money@' + sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' + + } + } + + + + stage('Push Image to Dockerhub') { + steps { + echo 'Docker Registry' + sh 'docker push devopsclass2022/address-app:${JOB_NAME}-${BUILD_NUMBER}' + } + } + + stage('Clean Up Docker Image') { + steps { + sh 'docker rmi devopsclass2022/address-app:${JOB_NAME}-${BUILD_NUMBER}' + } + } + } + +} diff --git a/jenkinsfile-16th-april b/jenkinsfile-16th-april new file mode 100644 index 0000000..ba76db7 --- /dev/null +++ b/jenkinsfile-16th-april @@ -0,0 +1,50 @@ +pipeline { + agent any + + stages { + stage('checkout') { + steps { + echo 'I am doing a git clone' + git 'https://github.com/awsdevopsclass2022/DevOpsClassCodes-aug.git' + } + } + + stage('compile') { + steps { + sh 'mvn compile' + } + } + + stage('test') { + steps { + sh 'mvn test' + } + } + + stage('package') { + steps { + sh 'mvn package' + } + } + + stage('docker build') { + steps { + sh 'docker build -t devopsclass2022/address-book:${JOB_NAME}-${BUILD_NUMBER} .' + } + } + + stage('docker login') { + steps { + sh 'docker login -u devopsclass2022 -p Done24Money@ ' + } + } + + stage('docker push') { + steps { + sh 'docker push devopsclass2022/address-book:${JOB_NAME}-${BUILD_NUMBER} ' + } + } + + + } +} \ No newline at end of file diff --git a/jenkinsfile-ansible b/jenkinsfile-ansible new file mode 100644 index 0000000..1ffc9cf --- /dev/null +++ b/jenkinsfile-ansible @@ -0,0 +1,90 @@ +pipeline { + agent any + + // environment { + + // //DOCKERHUB_CREDENTIALS= credentials('docker-hub-credentials') + + // } + + stages { + stage('compile') { + steps { + echo 'Compiling Stage' + git url: 'https://github.com/awsdevopsclass2022/DevOpsClassCodes-aug.git' + sh 'mvn compile' + } + } + stage('test') { + steps { + echo 'Testing Stage' + sh 'mvn test' + } + } + stage('package') { + steps { + echo 'Package Stage' + sh 'mvn package' + } + } + stage('Docker Build') { + steps { + echo 'Docker docker build stage' + sh 'docker build -t devopsclass2022/address-app .' + //sh 'docker login -u devopsclass2022 -p Done24Money@' + // sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' + + } + } + + + stage('Docker Login') { + steps { + + sh 'docker login -u devopsclass2022 -p Done24Money@' + // sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin' + + } + } + + + stage('Push Image to Dockerhub') { + steps { + echo 'Docker Registry' + sh 'docker push devopsclass2022/address-app' + } + } + + stage('Clean Up Docker Image') { + steps { + sh 'docker rmi devopsclass2022/address-app' + } + } + + stage('Deployment to QA (Ansible)') { + + // when { + // expression { env.BRANCH_NAME == 'orig/development' } + // } + steps { + //sh 'ansible-playbook ansible-docker-deploy-playbook.yaml' + sh "echo 'today@1234' | su -c 'ansible-playbook ansible-deploy-playbook-QA.yaml' devops" + } + } + + stage('Deployment to Staging') { + + // when { + // expression { env.BRANCH_NAME == 'master' } + // } + + steps { + //sh 'ansible-playbook ansible-docker-deploy-playbook.yaml' + sh "echo 'today@1234' | su -c 'ansible-playbook ansible-deploy-playbook-Staging.yaml' devops" + } + } + + + } + +} diff --git a/src/main/java/com/edurekademo/tutorial/addressbook/AddressbookUI.java b/src/main/java/com/edurekademo/tutorial/addressbook/AddressbookUI.java index 0649c5f..a6d0bfc 100644 --- a/src/main/java/com/edurekademo/tutorial/addressbook/AddressbookUI.java +++ b/src/main/java/com/edurekademo/tutorial/addressbook/AddressbookUI.java @@ -39,6 +39,7 @@ public class AddressbookUI extends UI { TextField filter = new TextField(); Grid contactList = new Grid(); Button newContact = new Button("New contact"); + // Button finalContact = new Button("New contact") // ContactForm is an example of a custom component class ContactForm contactForm = new ContactForm(); @@ -76,10 +77,10 @@ private void configureComponents() { contactList .setContainerDataSource(new BeanItemContainer<>(Contact.class)); - contactList.setColumnOrder("firstName", "lastName", "email"); - contactList.removeColumn("id"); + contactList.setColumnOrder("firstName", "lastName", "email", "phone"); + contactList.removeColumn("id"); contactList.removeColumn("birthDate"); - contactList.removeColumn("phone"); + // contactList.removeColumn("phone"); contactList.setSelectionMode(Grid.SelectionMode.SINGLE); contactList.addSelectionListener( e -> contactForm.edit((Contact) contactList.getSelectedRow())); @@ -100,6 +101,7 @@ private void configureComponents() { private void buildLayout() { HorizontalLayout actions = new HorizontalLayout(filter, newContact); actions.setWidth("100%"); + filter.setWidth("100%"); actions.setExpandRatio(filter, 1);