Skip to content

Commit

Permalink
#207 Fix startup
Browse files Browse the repository at this point in the history
  • Loading branch information
sklein94 committed Mar 29, 2023
1 parent 471135b commit c4b5efa
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN set -o errexit \
VOLUME ${SMEAGOL_HOME}
EXPOSE 8080

HEALTHCHECK CMD doguctl healthy smeagol || exit 1
HEALTHCHECK --interval=5s CMD doguctl healthy smeagol || exit 1

WORKDIR /app
CMD /startup.sh
4 changes: 1 addition & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>4.5.0.201609210915-r</version>
<version>6.5.0.202303070854-r</version>
</dependency>
</dependencies>
</plugin>
Expand Down Expand Up @@ -376,7 +376,5 @@
<cas-client.version>4.0.1</cas-client.version>
<java.version>11</java.version>
<jaxb.version>2.3.0</jaxb.version>
<!-- <tomcat.version>9.0.69</tomcat.version>-->
<!-- <groovy.version>2.5.14</groovy.version>-->
</properties>
</project>
10 changes: 10 additions & 0 deletions resources/app/application.yml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
stage: production
server:
servlet:
contextPath: /smeagol
homeDirectory: {{ .Env.Get "SMEAGOL_HOME" }}
scm:
url: https://{{ .Env.Get "FQDN" }}/scm
cas:
url: https://{{ .Env.Get "FQDN" }}/cas
serviceUrl: https://{{ .Env.Get "FQDN" }}
24 changes: 10 additions & 14 deletions resources/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,9 @@ create_truststore.sh "${TRUSTSTORE}" > /dev/null

# override setting from src/main/resources/application.yml
FQDN=$(doguctl config --global fqdn)
cat > /app/application.yml <<EOF
stage: production
server:
servlet:
contextPath: /smeagol
homeDirectory: ${SMEAGOL_HOME}
scm:
url: https://${FQDN}/scm
cas:
url: https://${FQDN}/cas
serviceUrl: https://${FQDN}/smeagol
EOF
export FQDN
export SMEAGOL_HOME
doguctl template /app/application.yml.tpl /app/application.yml

# configure logging behaviour using the etcd property logging/root <ERROR,WARN,INFO,DEBUG>

Expand All @@ -51,8 +42,11 @@ if [[ "$(doguctl config "container_config/memory_limit" -d "empty")" == "empty"
-Djava.net.preferIPv4Stack=true \
-Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
-Djavax.net.ssl.trustStorePassword=changeit \
-Dlogging.config=/app/logback.xml \
-jar /app/smeagol.war

# -Dlogging.config=/app/logback.xml \
# TODO

else
# Retrieve configurable java limits from etcd, valid default values exist
MEMORY_LIMIT_MAX_PERCENTAGE=$(doguctl config "container_config/java_max_ram_percentage")
Expand All @@ -63,8 +57,10 @@ else
-Djava.net.preferIPv4Stack=true \
-Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
-Djavax.net.ssl.trustStorePassword=changeit \
-Dlogging.config=/app/logback.xml \
-XX:MaxRAMPercentage="${MEMORY_LIMIT_MAX_PERCENTAGE}" \
-XX:MinRAMPercentage="${MEMORY_LIMIT_MIN_PERCENTAGE}" \
-jar /app/smeagol.war

# -Dlogging.config=/app/logback.xml \
# TODO
fi
8 changes: 3 additions & 5 deletions src/main/java/com/cloudogu/smeagol/ScmHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.http.ssl.SSLContexts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -61,10 +60,9 @@ protected static RestTemplate createRestTemplate(RestTemplateBuilder restTemplat
// disable cookie management to avoid scm-manager sessions
.disableCookieManagement();

if (stage == Stage.DEVELOPMENT) {
// TODO
// if (stage == Stage.DEVELOPMENT) {
// httpClientBuilder = disableSSLVerification(httpClientBuilder);
}
// }

HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClientBuilder.build());
Expand All @@ -79,7 +77,7 @@ protected static RestTemplate createRestTemplate(RestTemplateBuilder restTemplat
// SSLContext sslContext = createSSLContext(acceptingTrustStrategy);
//
// SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
// return httpClientBuilder .setSSLSocketFactory(csf);
// return httpClientBuilder.setSSLSocketFactory(csf);
// }

private static SSLContext createSSLContext(TrustStrategy acceptingTrustStrategy) {
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/cloudogu/smeagol/ServletInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
* Allows for being deployed as a war into an external container
*/
public class ServletInitializer extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Smeagol.class);
}

@Override
public void onStartup(jakarta.servlet.ServletContext servletContext){
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Map<String,String> createCasSettings(){
.put("casServerLoginUrl", casUrl + "/login")
.put("serverName", serviceUrl)
.put("casServerUrlPrefix", casUrl)
.put("proxyCallbackUrl", serviceUrl.replaceAll("/$", "") + "/proxyCallbackUrl")
.put("proxyCallbackUrl", serviceUrl.replaceAll("/$", "") + "/smeagol/proxyCallbackUrl")
.put("proxyReceptorUrl", contextPath.replaceAll("/$", "") + "/proxyCallbackUrl")
.put("acceptAnyProxy", "true")
.put("authenticationRedirectStrategyClass", AjaxAwareAuthenticationRedirectStrategy.class.getName())
Expand Down

0 comments on commit c4b5efa

Please sign in to comment.