Created
February 26, 2018 15:42
-
-
Save madigan/a61b826d6bfecbc7fd9d4a766221096f to your computer and use it in GitHub Desktop.
Starter Template for a Java/Spring based Microservice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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