Skip to content

Instantly share code, notes, and snippets.

@madigan
Created February 26, 2018 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madigan/a61b826d6bfecbc7fd9d4a766221096f to your computer and use it in GitHub Desktop.
Save madigan/a61b826d6bfecbc7fd9d4a766221096f to your computer and use it in GitHub Desktop.
Starter Template for a Java/Spring based Microservice
package tech.otter.servicename;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class Application {
@RequestMapping("/")
public String home() {
return "The service is online!";
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id "org.springframework.boot" version "1.5.10.RELEASE"
id "com.palantir.docker" version "0.19.2"
}
// Used to push the image to docker
group 'ottertech'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'com.palantir.docker'
jar {
baseName = 'alibadguy'
version = '0.1.0'
}
docker {
name "${project.group}/${jar.baseName}"
files jar.archivePath
buildArgs(['JAR_FILE': "${jar.archiveName}"])
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
FROM openjdk:8-jdk-alpine
ARG JAR_FILE
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment