Commit 1001bc5e authored by femiadeyemi's avatar femiadeyemi
Browse files

packaging: make the start script more robust

Motivation:

More options are neccessary to enable robust packaging.
The start.sh script presently only takes one option,
however to do set some availabe after build is desirable
and this script can handle this.

Modification:

- make the file path of the web static directory, the port
   number of the server and the spring profile  settable
   through the script.
- set active profile to dev inside the dockerfile file
- add application yml for dev profile

Result:

start.sh now handle many options that can be configure for
starting the server.

Target: master
parent 94ab0dd6
Pipeline #45801 passed with stages
in 21 minutes and 21 seconds
FROM adoptopenjdk:11-jre-hotspot
COPY target/hm-server-package.tar hms.tar
EXPOSE 8080
CMD tar -xvf hms.tar -C ./ && cd ./hm-server/bin && ./start.sh -s $CLIENT_SECRET
CMD tar -xvf hms.tar -C ./ && cd ./hm-server/bin && ./start.sh -s $CLIENT_SECRET -a dev
package de.helmholtz.marketplace.webappserver.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
......
logging:
level:
root: DEBUG
org.springframework.web: TRACE
org.springframework.security: TRACE
org.springframework.security.oauth2: TRACE
org.springframework.boot.autoconfigure: DEBUG
\ No newline at end of file
......@@ -11,7 +11,7 @@ server:
spring:
resources:
static-locations: file:../webapp/
static-locations: ${path:'file:../webapp/'}
security:
oauth2:
client:
......
while getopts s: flag
#!/bin/bash
port=8080
currentDir=$(pwd)
parentDir="$(dirname "$currentDir")"
while getopts "a:d:f:p:s:" flag;
do
case "${flag}" in
a) profile=${OPTARG};;
d) parentDir=${OPTARG};;
f) filePath=${OPTARG};;
p) port=${OPTARG};;
s) secret=${OPTARG};;
*) echo 'error' >&2
exit 1
esac
done
java -Xms256m -Xmx512m -server -jar ../lib/helmholtz-marketplace-server-0.0.1-SNAPSHOT.jar --spring.security.oauth2.client.registration.unity.client-secret=$secret
\ No newline at end of file
if [ ! "$secret" ]; then
echo 'Option -s missing' >&2
exit 1
fi
if [ ! "$filePath" ]; then
filePath=file:$parentDir/webapp/
fi
if [ ! "$profile" ]; then
java -Xms256m -Xmx512m -server -jar "$parentDir"/lib/helmholtz-marketplace-server-0.0.1-SNAPSHOT.jar --spring.security.oauth2.client.registration.unity.client-secret=$secret --server.port=$port --spring.resources.static-locations="$filePath"
exit 1
fi
java -Xms256m -Xmx512m -Dspring.profiles.active="$profile" -server -jar "$parentDir"/lib/helmholtz-marketplace-server-0.0.1-SNAPSHOT.jar --spring.security.oauth2.client.registration.unity.client-secret=$secret --server.port=$port --spring.resources.static-locations="$filePath"
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment