-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from olblak/config/01
Add application configuration through env variables
- Loading branch information
Showing
6 changed files
with
145 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ bin/jetty-runner*.jar | |
.gradle/ | ||
*.sw* | ||
build/ | ||
.env |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
FROM jetty:jre8-alpine | ||
|
||
ADD build/libs/accountapp*.war /var/lib/jetty/webapps/ROOT.war | ||
LABEL \ | ||
Description="Deploy Jenkins infra account app" \ | ||
Project="https://github.com/jenkins-infra/account-app" \ | ||
Maintainer="infra@lists.jenkins-ci.org" | ||
|
||
# This is apparently needed by Stapler for some weird reason. O_O | ||
RUN mkdir -p /home/jetty/.app | ||
EXPOSE 8080 | ||
|
||
RUN mkdir -p /etc/accountapp | ||
ENV CIRCUIT_BREAKER_FILE /etc/accountapp/circuitBreaker.txt | ||
|
||
EXPOSE 8080 | ||
# /home/jetty/.app is apparently needed by Stapler for some weird reason. O_O | ||
RUN \ | ||
mkdir -p /home/jetty/.app &&\ | ||
mkdir -p /etc/accountapp | ||
|
||
COPY config.properties.example /etc/accountapp/config.properties.example | ||
COPY circuitBreaker.txt /etc/accountapp/circuitBreaker.txt | ||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
RUN \ | ||
chmod 0755 /entrypoint.sh &&\ | ||
chown -R jetty:root /etc/accountapp | ||
|
||
COPY build/libs/accountapp*.war /var/lib/jetty/webapps/ROOT.war | ||
|
||
USER jetty | ||
|
||
# Overriding the ENTRYPOINT from our parent to make it easier to tell it about | ||
# our config.properties which the app needs | ||
ENTRYPOINT java -DCONFIG=/etc/accountapp/config.properties -Durl="$LDAP_URL" -Dpassword="$LDAP_PASSWORD" -Djira.username="$JIRA_USERNAME" -Djira.password="$JIRA_PASSWORD" -Djira.url="$JIRA_URL" -jar "$JETTY_HOME/start.jar" | ||
ENTRYPOINT /entrypoint.sh |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This file configures the Jenkins project's accounts management application. | ||
# | ||
# See: <https://github.com/jenkins-infra/account-app> | ||
server=LDAP_URL | ||
managerDN=LDAP_MANAGER_DN | ||
managerPassword=LDAP_PASSWORD | ||
|
||
newUserBaseDN=LDAP_NEW_USER_BASE_DN | ||
|
||
# Host which accountapp can use for sending out password reset and other emails | ||
smtpServer=SMTP_SERVER | ||
|
||
recaptchaPublicKey=RECAPTCHA_PUBLIC_KEY | ||
recaptchaPrivateKey=RECAPTCHA_PRIVATE_KEY | ||
|
||
url=APP_URL | ||
|
||
# Create this file on the host machine in order to temporarily disable account | ||
# creation | ||
circuitBreakerFile=CIRCUIT_BREAKER_FILE | ||
|
||
# vim: ft=conf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: '3' | ||
services: | ||
accountapp: | ||
build: . | ||
image: accountapp:latest | ||
env_file: .env | ||
network_mode: host | ||
ports: | ||
- '8080:8080' | ||
shell: | ||
build: . | ||
image: accountapp:latest | ||
env_file: .env | ||
entrypoint: /bin/sh | ||
network_mode: host |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
init_config_properties() { | ||
: "${LDAP_URL:?Ldap url required}" | ||
: "${LDAP_PASSWORD:?Ldap password required}" | ||
: "${JIRA_USERNAME:?Jira user required}" | ||
: "${JIRA_PASSWORD:?Jira password required}" | ||
: "${JIRA_URL:? Jira url required}" | ||
|
||
# /etc/accountapp/config.properties | ||
: "${SMTP_SERVER:? SMTP Server required}" | ||
: "${RECAPTCHA_PUBLIC_KEY:? Recaptcha private key}" | ||
: "${RECAPTCHA_PRIVATE_KEY:? Recaptcha private key}" | ||
: "${APP_URL:? Application url required}" | ||
: "${LDAP_MANAGER_DN:? Require ldap manager_DN}" | ||
: "${LDAP_NEW_USER_BASE_DN:? Require ldap new user base DN}" | ||
: "${CIRCUIT_BREAKER_FILE:? Require circuitBreaker file}" | ||
|
||
|
||
cp /etc/accountapp/config.properties.example /etc/accountapp/config.properties | ||
|
||
# Using # as variables may contain / | ||
sed -i "s#SMTP_SERVER#$SMTP_SERVER#" /etc/accountapp/config.properties | ||
sed -i "s#LDAP_URL#$LDAP_URL#" /etc/accountapp/config.properties | ||
sed -i "s#LDAP_PASSWORD#$LDAP_PASSWORD#" /etc/accountapp/config.properties | ||
sed -i "s#RECAPTCHA_PUBLIC_KEY#$RECAPTCHA_PUBLIC_KEY#" /etc/accountapp/config.properties | ||
sed -i "s#RECAPTCHA_PRIVATE_KEY#$RECAPTCHA_PRIVATE_KEY#" /etc/accountapp/config.properties | ||
sed -i "s#APP_URL#$APP_URL#" /etc/accountapp/config.properties | ||
sed -i "s#LDAP_MANAGER_DN#$LDAP_MANAGER_DN#" /etc/accountapp/config.properties | ||
sed -i "s#LDAP_NEW_USER_BASE_DN#$LDAP_NEW_USER_BASE_DN#" /etc/accountapp/config.properties | ||
sed -i "s#CIRCUIT_BREAKER_FILE#$CIRCUIT_BREAKER_FILE#" /etc/accountapp/config.properties | ||
} | ||
|
||
if [ ! -f /etc/accountapp/config.properties ]; then | ||
init_config_properties | ||
fi | ||
|
||
exec java -DCONFIG=/etc/accountapp/config.properties -Durl="$LDAP_URL" -Dpassword="$LDAP_PASSWORD" -Djira.username="$JIRA_USERNAME" -Djira.password="$JIRA_PASSWORD" -Djira.url="$JIRA_URL" -jar "$JETTY_HOME/start.jar" |