Unify Motech naming and nginx configuration for spotter-appmgr

This commit is contained in:
Disassembler 2018-03-25 23:13:55 +02:00
parent 9d37aed199
commit 551e2a2938
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
6 changed files with 16 additions and 29 deletions

View File

@ -22,8 +22,7 @@ cp ${SOURCE_DIR}/srv/motech/conf/config-locations.properties /srv/motech/conf/co
cp ${SOURCE_DIR}/srv/motech/conf/config/motech-settings.properties /srv/motech/conf/config/motech-settings.properties
cp ${SOURCE_DIR}/srv/motech/conf/config/org.motechproject.motech-platform-email/motech-email.properties /srv/motech/conf/config/org.motechproject.motech-platform-email/motech-email.properties
chown -R 8013:8013 /srv/motech/conf
cp ${SOURCE_DIR}/srv/motech/update-ip.sh /srv/motech/update-ip.sh
/srv/motech/update-ip.sh
cp ${SOURCE_DIR}/srv/motech/update-url.sh /srv/motech/update-url.sh
# Create Motech service
cp ${SOURCE_DIR}/etc/init.d/motech /etc/init.d/motech
@ -32,17 +31,13 @@ service motech start
# Configure Motech admin
echo `date` '- Waiting for database to be populated. This should take about a minute.'
until curl -s http://127.0.0.1:8013/motech/module/server/startup/ | grep -q adminLogin; do
until curl -s "http://motech:8080/motech/module/server/startup/" | grep -q adminLogin; do
sleep 1
done
export MOTECH_ADMIN_USER="admin"
export MOTECH_ADMIN_EMAIL="admin@example.com"
export MOTECH_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
curl -H "Content-Type: application/json" -X POST -d "{\"adminLogin\":\"${MOTECH_ADMIN_USER}\",\"adminEmail\":\"${MOTECH_ADMIN_EMAIL}\",\"adminPassword\":\"${MOTECH_ADMIN_PWD}\",\"adminConfirmPassword\":\"${MOTECH_ADMIN_PWD}\",\"language\":\"cs\",\"providerName\":\"\",\"providerUrl\":\"\",\"schedulerUrl\":\"\"}" http://127.0.0.1:8013/motech/module/server/startup/
curl -H "Content-Type: application/json" -X POST -d "{\"adminLogin\":\"${MOTECH_ADMIN_USER}\",\"adminEmail\":\"${MOTECH_ADMIN_EMAIL}\",\"adminPassword\":\"${MOTECH_ADMIN_PWD}\",\"adminConfirmPassword\":\"${MOTECH_ADMIN_PWD}\",\"language\":\"cs\",\"providerName\":\"\",\"providerUrl\":\"\",\"schedulerUrl\":\"\"}" http://motech:8080/motech/module/server/startup/
# Create nginx app definition
cp ${SOURCE_DIR}/etc/nginx/conf.d/motech.conf /etc/nginx/conf.d/motech.conf
service nginx reload
# Add portal application definition
portal-app-manager motech "https://{host}:8413/motech/" "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}"
# Add application definition
spotter-appmgr add-app motech "https://motech.{host}/motech/" "${MOTECH_ADMIN_USER}" "${MOTECH_ADMIN_PWD}"

View File

@ -10,8 +10,6 @@ RUN \
&& rm -f /srv/tomcat/webapps/motech/WEB-INF/lib/postgresql-9.1-901.jdbc4.jar /srv/tomcat/webapps/motech/WEB-INF/bundles/postgresql-9.1-901.jdbc4.jar \
&& wget https://jdbc.postgresql.org/download/postgresql-42.2.0.jar -O /srv/tomcat/webapps/motech/WEB-INF/lib/postgresql-42.2.0.jar \
&& cp /srv/tomcat/webapps/motech/WEB-INF/lib/postgresql-42.2.0.jar /srv/tomcat/webapps/motech/WEB-INF/bundles/postgresql-42.2.0.jar \
# Configure Tomcat port
&& sed -i 's/port="8080"/port="8013"/g' /srv/tomcat/conf/server.xml \
# Create OS user
&& addgroup -S -g 8013 motech \
&& adduser -S -u 8013 -h /srv/tomcat -s /bin/false -g motech -G motech motech \
@ -20,7 +18,7 @@ RUN \
&& rm -f /tmp/motech.war
VOLUME ["/srv/tomcat/.motech"]
EXPOSE 8013
EXPOSE 8080
USER motech
WORKDIR /srv/tomcat

View File

@ -14,11 +14,14 @@ start() {
--link activemq \
--link postfix \
--link postgres \
-p 127.0.0.1:8013:8013 \
-v /srv/motech/conf:/srv/tomcat/.motech \
motech
}
start_post() {
/usr/local/bin/spotter-appmgr update-hosts motech
}
stop() {
/usr/bin/docker stop motech
}

View File

@ -1,11 +0,0 @@
server {
listen [::]:8813 ipv6only=off;
listen [::]:8413 ssl http2 ipv6only=off;
access_log /var/log/nginx/motech.access.log;
error_log /var/log/nginx/motech.error.log;
location / {
proxy_pass http://127.0.0.1:8013;
}
}

View File

@ -1,4 +0,0 @@
#!/bin/sh
URL=$(ip route get 1 | awk '{print $NF;exit}')
sed -i "s|^server\.url.*|server.url=https://${URL}:8413/motech|" /srv/motech/conf/config/motech-settings.properties

View File

@ -0,0 +1,6 @@
#!/bin/sh
HOST="${1}"
[ "${2}" != "443" ] && HOST="${1}:${2}"
sed -i "s|^server\.url.*|server.url=https://${HOST}/motech|" /srv/motech/conf/config/motech-settings.properties