Skip to content

Latest commit

 

History

History
140 lines (123 loc) · 4.68 KB

deploy_cloud.md

File metadata and controls

140 lines (123 loc) · 4.68 KB

how to apply your application

  • get back to your working directory.

  • add these snipets into your pom.xml

      	<plugin>
      		<groupId>org.apache.maven.plugins</groupId>
      		<artifactId>maven-dependency-plugin</artifactId>
      		<version>2.3</version>
      		<executions>
      			<execution>
      				<phase>package</phase>
      				<goals><goal>copy</goal></goals>
      				<configuration>
      					<artifactItems>
      						<artifactItem>
      							<groupId>org.eclipse.jetty</groupId>
      							<artifactId>jetty-runner</artifactId>
      			        <version>9.3.8.v20160314</version>
      							<destFileName>jetty-runner.jar</destFileName>
      						</artifactItem>
      					</artifactItems>
      				</configuration>
      			</execution>
      		</executions>
      	</plugin>
      	<plugin>
      		<groupId>org.eclipse.jetty</groupId>
      		<artifactId>jetty-maven-plugin</artifactId>
      		<version>9.3.8.v20160314</version>
      	</plugin>
     <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-servlet</artifactId>
        <version>9.3.8.v20160314</version>
      </dependency>
      <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-webapp</artifactId>
        <version>9.3.8.v20160314</version>
      </dependency>
  • mvn package and run as java -jar target/dependency/jetty-runner.jar target/*.war

  • if successful in local, commit github

  • git commit

  • git push origin deploytogoogle

create Google Computing Platform account

Create GCP PROJECT

Following instructions are same as this page

  • open GCP console https://console.cloud.google.com
  • click [▽] in top of bar
  • click [+]
  • input project name (ex. interview-gami)
  • click [create]
  • wait a second (would take a few seconds)
  • select your project in top of bar

set budget

  • select Menu (〓) , then Billing & alerts
    • Create BUDGET
    • set ammount of money like this

Create an Instance

  • Select Menu (〓) , then click Compute Engine
  • wait a second
  • select VM instances
  • Create an instance
    • Fill in like this
    • select micro in Machine type <- if select other type, you have to pay some money
      • micro is free as you can see
    • select ubuntu 16.04
    • select Allow HTTP in Firewall
    • paste your id_rsa.pub SSH keys and add item
  • click [create]
  • wait a second

Access instance

  • click your instance in "VM instances" view to goto "VM instance detail"
  • Remember external IP
  • open terminal
    • ssh YOUR_EXTERNAL IP

setup machine and run server

  • type following commands
sudo apt-get update
sudo apt install -y openjdk-8-jdk maven
git clone https://github.com/YOUR_NAME/YOUR_REPOSITORY
cd YOUR_REPOSITORY
git checkout deploytogoogle
mvn package
sudo java -jar target/dependency/jetty-runner.jar  -—port 80  target/*.war
  • VM instances -> your instance -> Click "External IP (10…)"
    • open http://{PASTE EXTERNAL_IP}/interview/Java

set up dynamic DNS on your instance

  • create an account https://www.noip.com/sign-up
  • log in https://my.noip.com/#!/
  • add quick dns
    • input myhost
    • add hostname
  • click Dynamic DNS [Free] in a left pane
  • click your created dns
  • input your external IP of the instance onto IPv4 Address
  • open YOUR_DDNS.ddns.com/interview/Java
    • it can take a few minutes to update

terminate

  • Go to VM instances and select your instance then click [DELETE]

Run sample application locally