Add Dockerfile and run config, rename hello to defaultcontroller

This commit is contained in:
Marcel Schwarz 2020-03-16 02:01:07 +01:00
parent 92c519ee5b
commit 61450da84a
6 changed files with 53 additions and 5 deletions

View File

@ -0,0 +1,21 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build Jar" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="bootJar" />
</list>
</option>
<option name="vmOptions" value="" />
</ExternalSystemSettings>
<GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
<method v="2" />
</configuration>
</component>

View File

@ -0,0 +1,16 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build and Run on Docker" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="buildCliOptions" value="" />
<option name="command" value="" />
<option name="containerName" value="pwgen-spring" />
<option name="entrypoint" value="" />
<option name="imageTag" value="pwgen" />
<option name="commandLineOptions" value="-p 80:80" />
<option name="sourceFilePath" value="Dockerfile" />
</settings>
</deployment>
<method v="2" />
</configuration>
</component>

View File

@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PwgenApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<configuration default="false" name="Run PwgenApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="passwordgenerator.main" />
<option name="SPRING_BOOT_MAIN_CLASS" value="de.icaotix.pwgen.PwgenApplication" />
<option name="ALTERNATIVE_JRE_PATH" />

10
Dockerfile Normal file
View File

@ -0,0 +1,10 @@
FROM gradle:jdk11 AS build
WORKDIR /root
COPY . .
RUN ["gradle", "bootJar"]
FROM openjdk:13-jdk-alpine
WORKDIR /root
COPY --from=build /root/build/libs/*.jar app.jar
EXPOSE 80
ENTRYPOINT ["java","-jar","app.jar"]

View File

@ -1,14 +1,14 @@
package de.icaotix.pwgen;
package de.icaotix.controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
@RestController
public class HelloController {
public class DefaultController {
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
return "Greetings from Spring Boot, also from a Docker Container!";
}
}

View File

@ -2,8 +2,9 @@ package de.icaotix.pwgen;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@SpringBootApplication(scanBasePackages = {"de.icaotix"})
public class PwgenApplication {
public static void main(String[] args) {