Starting heroku through heroku CLI (for beginners)

What is Heroku?

Heroku is a cloud platform that helps you build, serve, monitor, and scale your apps, allowing you to expedite the process of getting an idea and getting it up and running. It also frees you from infrastructure management issues. -Excerpt from Official Form Page

Supplementally, Heroku is a PaaS (Platform as a Service), which means that developers can distribute and operate applications if they concentrate only on application development. Since it is linked with GitHub, it can be deployed to git just by pushing, so it is a suitable platform for CI / CD. Currently, it supports languages such as Node.js, Java, PHP, Go.

Download Heroku-CLI

Heroku-CLI is a tool that makes it easier to work with Heroku apps on your terminal. You can download it here [https://devcenter.heroku.com/articles/heroku-cli). (** Please install git in advance. **) Please install according to your OS.

Command operation

Login

Repository Clone

The app is automatically generated on Heroku with heroku start. In this case, the app name will be randomly generated so you can change it later or create the app first and clone it with heroku git: clone -a [app name].

Source code commit

Let's raise the code that outputs "hello world" in PHP and Java.

PHP

index.php


<?php
echo 'hello world';

Java

DemoApplication.java


package com.example.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@SpringBootApplication
public class DemoApplication {

	@RequestMapping("/")
	@ResponseBody
	String home() {
		return "hello world";
	}

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

}

Heroku is a web application, so you can't just look at it with System.out.println (). I think it's better to use a web framework such as Spring.

git add . git commit -am "commit message" git push heroku master You can push the source to Heroku with the above command. The heroku open -a [app name] command will open your app in your browser. image.png You can also check it with the "Open app" button on the Heroku form page.

At the end

We've introduced how to easily deploy to Heroku. I think that serverless and cordless are steadily coming, so I think that wearing cloud services such as Heroku and AWS Elastic Beanstalk will be a great strength in the future. Thank you for visiting

Recommended Posts

Starting heroku through heroku CLI (for beginners)
Heroku CLI operation (command)
Scraping for beginners (Ruby)
Java debug execution [for Java beginners]
[Java] Basic statement for beginners
[For super beginners] DBUnit super introduction
(For beginners) [Rails] Install Devise
[For super beginners] Ant super introduction
More usable Enumerable for beginners
Java for beginners, data hiding
[For super beginners] Maven super introduction
Java application for beginners: stream