diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d31f762 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM gradle:jdk17-jammy as build +WORKDIR /home/gradle/ModeratorElection +COPY . /home/gradle/ModeratorElection +RUN ./gradlew -Dvaadin.productionMode=true -Dvaadin.force.production.build=true -Pproduction clean war + +FROM tomcat:11.0 +COPY --from=build home/gradle/ModeratorElection/build/libs/ModeratorElection-plain.war /usr/local/tomcat/webapps/ROOT.war \ No newline at end of file diff --git a/build.gradle b/build.gradle index 5d5d62a..a61faa7 100644 --- a/build.gradle +++ b/build.gradle @@ -10,6 +10,7 @@ plugins { id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'java' id 'com.vaadin' + id 'war' } repositories { @@ -32,6 +33,7 @@ dependencies { testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } + providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' } dependencyManagement { @@ -40,6 +42,10 @@ dependencyManagement { } } +war { + enabled=true +} + test{ useJUnitPlatform() } \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..09e1616 --- /dev/null +++ b/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker image build . -t moderator \ No newline at end of file diff --git a/src/main/java/com/ModeratorElection/MEApplication.java b/src/main/java/com/ModeratorElection/MEApplication.java index 7fe20e2..81ffe80 100644 --- a/src/main/java/com/ModeratorElection/MEApplication.java +++ b/src/main/java/com/ModeratorElection/MEApplication.java @@ -2,9 +2,17 @@ package com.ModeratorElection; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.boot.builder.SpringApplicationBuilder; @SpringBootApplication -public class MEApplication { +public class MEApplication extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(MEApplication.class); + } + public static void main(String[] args) { SpringApplication.run(MEApplication.class, args); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b80472e..d1cf4f8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -6,6 +6,6 @@ spring.mustache.check-template-location = false vaadin.launch-browser=true # To improve the performance during development. # For more information https://vaadin.com/docs/latest/integrations/spring/configuration#special-configuration-parameters -vaadin.allowed-packages = com.vaadin,org.vaadin,dev.hilla,com.example.application +vaadin.allowed-packages = com.vaadin,org.vaadin,dev.hilla,com.ModeratorElection.ModeratorElection.ModeratorElectionApplication spring.jpa.defer-datasource-initialization = true membernames=${MEMBERNAMES:Micha,Ansgar,Clemens,Mattis,Erik,Mirco}