GithubHelp home page GithubHelp logo

maven-hello-world's Introduction

Quickstart

Prerequisites

Getting started locally

Bootstrap required environment with a help of Docker

docker pull maven
docker run -it --rm --name my-maven-project -v `pwd`:/src maven /bin/bash

Generate simple web application

mvn archetype:generate \
	-DarchetypeGroupId=org.apache.maven.archetypes \
	-DarchetypeArtifactId=maven-archetype-webapp \
	-DarchetypeVersion=1.3 \
	-DgroupId=com.mycompany.app \
	-DartifactId=my-webapp \
	-DinteractiveMode=false

Create war file /src/my-webapp/target/my-webapp.war

mvn war:war

Serve web application (default port is :8080)

$ cd /src/my-webapp
$ mvn clean install tomcat7:run-war

Run on a specific port

$ mvn tomcat7:run-war -Dmaven.tomcat.port=8181

Customize message

$ export message="My custom greetings"

Launch infrastructure

Create file terraform/variables.tf and fill with your data. For this example ami-0ac019f4fcb7cb7e6 and t1.micro instance type were used.

$ cd terraform
$ terraform init
$ terraform apply

This will launch and instance and output it's IP to Ansible inventory in order to provision that later.

Deploy

$ ansible-galaxy install geerlingguy.docker
$ cd ansible
$ ansible-playbook -v deploy.yml

You service will be launched within docker container with a command similar to this one

$ sudo docker run -it --rm  \
	-p 8181:8080 \
	-v `pwd`/webapps:/usr/local/tomcat/webapps/ 
	tomcat:8.0 /bin/bash

Ansible will output IP address of target instance, so visit

http://<instance-ip>:8181/mywebapp/

to check your application app and running.

Cleanup

$ terraform destroy
$ terraform destroy -target aws_instance.mywebapp

maven-hello-world's People

Contributors

bmwant avatar pdurbin avatar

Watchers

 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.