Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FRESH-1129 #793 Docker Compose App-Server Creation
- Loading branch information
0 parents
commit 7139618
Showing
12 changed files
with
303 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
**/opt/ | ||
**/volumes/ | ||
**/*tar.gz | ||
**/*.pgdump | ||
**/*.swp |
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,14 @@ | ||
FROM ubuntu:16.04 | ||
RUN apt update && apt -y full-upgrade | ||
RUN apt -y install netcat \ | ||
&& apt -y install openjdk-8-jdk-headless \ | ||
&& apt -y autoremove \ | ||
&& apt -y autoclean | ||
|
||
ADD sources/metasfresh_51_50.tar.gz / | ||
|
||
COPY sources/start_app.sh /opt/metasfresh/ | ||
RUN chmod 700 /opt/metasfresh/start_app.sh | ||
|
||
ENTRYPOINT ["/opt/metasfresh/start_app.sh"] | ||
EXPOSE 8282 |
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,37 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
DB_HOST=${DB_HOST:-db} | ||
APP_HOST=${APP_HOST:-app} | ||
|
||
set_properties() | ||
{ | ||
local prop_file="$1" | ||
if [[ $(cat $prop_file | grep FOO | wc -l) -ge "1" ]]; then | ||
sed -Ei "s/FOO_DBMS/$DB_HOST/g" $prop_file | ||
sed -Ei "s/FOO_APP/$APP_HOST/g" $prop_file | ||
fi | ||
} | ||
|
||
wait_dbms() | ||
{ | ||
until nc -z $DB_HOST 5432 | ||
do | ||
sleep 1 | ||
done | ||
} | ||
|
||
run_metasfresh() | ||
{ | ||
cd /opt/metasfresh/ && java -jar metasfresh_server.jar | ||
} | ||
|
||
|
||
set_properties /opt/metasfresh/metasfresh.properties | ||
set_properties /opt/metasfresh/local_settings.properties | ||
|
||
wait_dbms | ||
run_metasfresh | ||
|
||
exit 0 |
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,13 @@ | ||
FROM postgres:9.5 | ||
RUN apt update && apt -y full-upgrade | ||
|
||
RUN localedef -i de_DE -c -f UTF-8 -A /usr/share/locale/locale.alias de_DE.UTF-8 | ||
ENV LANG=de_DE.UTF-8 | ||
|
||
COPY sources/create_db.sh /docker-entrypoint-initdb.d/ | ||
COPY sources/metasfresh.pgdump /tmp/ | ||
|
||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
|
||
CMD ["postgres"] | ||
EXPOSE 5432 |
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,53 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
METASFRESH_DBNAME=${METASFRESH_DBNAME=-metasfresh} | ||
METASFRESH_APPHOST=${METASFRESH_APPHOST=-app} | ||
METASFRESH_USERNAME=${METASFRESH_USERNAME=-metasfresh} | ||
METASFRESH_PASSWORD=${METASFRESH_PASSWORD=-metasfresh} | ||
DB_SYSPASS=${DB_SYSPASS=-SYSPASS} | ||
|
||
create_initial() | ||
{ | ||
echo "[METASFRESH] Creating role, database and permissions ..." | ||
psql -v ON_ERROR_STOP=1 -U "postgres" <<- EOSQL | ||
CREATE ROLE $METASFRESH_USERNAME LOGIN ENCRYPTED PASSWORD '$METASFRESH_PASSWORD' SUPERUSER INHERIT CREATEDB NOCREATEROLE; | ||
CREATE DATABASE $METASFRESH_DBNAME WITH OWNER = $METASFRESH_USERNAME; | ||
GRANT ALL PRIVILEGES ON DATABASE $METASFRESH_DBNAME to $METASFRESH_USERNAME; | ||
EOSQL | ||
echo "[METASFRESH] ... done!" | ||
} | ||
|
||
apply_conf() | ||
{ | ||
echo "[METASFRESH] Applying host-specific scripts to database ... " | ||
psql -v ON_ERROR_STOP=1 -U "$METASFRESH_USERNAME" -d "$METASFRESH_DBNAME" <<- EOSQL | ||
DELETE FROM AD_SysConfig WHERE Name='de.metas.payment.sepa.api.impl.SEPADocumentBL.marshalXMLCreditFile.defaultPath'; | ||
UPDATE AD_User SET Password='$DB_SYSPASS' WHERE AD_User_ID=100 AND Name='SuperUser'; | ||
UPDATE ad_client SET StoreAttachmentsOnFileSystem='N', StoreArchiveOnFileSystem='N', WindowsAttachmentPath=null, WindowsArchivePath=null; | ||
UPDATE AD_SysConfig SET Value='http://$METASFRESH_APPHOST:8282/adempiereJasper/ReportServlet' WHERE Name='de.metas.adempiere.report.jasper.JRServerServlet'; | ||
-- required as of task 06275 | ||
UPDATE AD_SysConfig SET Value='http://$METASFRESH_APPHOST:8282/adempiereJasper/BarcodeServlet' WHERE Name='de.metas.adempiere.report.barcode.BarcodeServlet'; | ||
UPDATE AD_SysConfig SET Value='http://$METASFRESH_APPHOST:8282/printing-client-webapp-1.5/printing-client.jar' WHERE Name='de.metas.printing.client.archive'; | ||
UPDATE AD_SysConfig SET Value='http://$METASFRESH_APPHOST:8182/printing' WHERE Name='de.metas.printing.client.endpoint.RestHttpPrintConnectionEndpoint.ServerUrl'; | ||
UPDATE AD_SysConfig SET Value='tcp://$METASFRESH_APPHOST:61616' WHERE name='de.metas.jms.URL'; | ||
UPDATE AD_OrgInfo SET reportprefix='file:////opt/metasfresh/reports' WHERE reportprefix='file:////opt/metasfresh/jboss/server/adempiere/deploy/reports.war'; | ||
UPDATE AD_SysConfig SET Value='Y' WHERE NAME='de.metas.event.jms.UseEmbeddedBroker'; | ||
EOSQL | ||
echo "[METASFRESH] ... done!" | ||
} | ||
|
||
import_dump() | ||
{ | ||
echo "[METASFRESH] Populating database with data. This may take a while ... " | ||
pg_restore -Fc -U "$METASFRESH_USERNAME" -d "$METASFRESH_DBNAME" /tmp/metasfresh.pgdump | ||
echo "[METASFRESH] ... done!" | ||
} | ||
|
||
create_initial | ||
import_dump | ||
apply_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,40 @@ | ||
db2: | ||
build: db | ||
ports: | ||
- "5432" | ||
restart: always | ||
volumes: | ||
- ./volumes/db/data:/var/lib/postgresql/data | ||
- ./volumes/db/log:/var/log/postgresql | ||
- /etc/localtime:/etc/localtime:ro | ||
environment: | ||
- METASFRESH_USERNAME=metasfresh | ||
- METASFRESH_PASSWORD=metasfresh | ||
- METASFRESH_DBNAME=metasfresh | ||
- DB_SYSPASS=SYSPASS | ||
app2: | ||
build: app | ||
links: | ||
- db2:db | ||
restart: always | ||
volumes: | ||
- ./volumes/app/log:/opt/metasfresh/log:rw | ||
- /etc/localtime:/etc/localtime:ro | ||
environment: | ||
- METASFRESH_HOME=/opt/metasfresh | ||
webapi2: | ||
build: webapi | ||
ports: | ||
- "8080:8080" | ||
links: | ||
- app2:app | ||
- db2:db | ||
restart: always | ||
volumes: | ||
- ./volumes/webapi/log:/opt/metasfresh-webui-api/log:rw | ||
- /etc/localtime:/etc/localtime:ro | ||
webui2: | ||
build: webui | ||
ports: | ||
- "80:80" | ||
restart: always |
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,28 @@ | ||
version: "2" | ||
|
||
services: | ||
|
||
db: | ||
build: db | ||
ports: | ||
- "5432:5432" | ||
restart: always | ||
volumes: | ||
- ./volumes/db/data:/var/lib/postgresql/data | ||
- ./volumes/db/log:/var/log/postgresql | ||
- /etc/localtime:/etc/localtime:ro | ||
environment: | ||
- METASFRESH_USERNAME=metasfresh | ||
- METASFRESH_PASSWORD=metasfresh | ||
- METASFRESH_DBNAME=metasfresh | ||
- DB_SYSPASS=SYSPASS | ||
|
||
app: | ||
build: app | ||
ports: | ||
- "8080:8080" | ||
- "61616:61616" | ||
restart: always | ||
volumes: | ||
- ./volumes/app/log:/opt/metasfresh/log:rw | ||
- /etc/localtime:/etc/localtime:ro |
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,13 @@ | ||
FROM ubuntu:16.04 | ||
RUN apt update && apt -y full-upgrade | ||
RUN apt -y install netcat \ | ||
&& apt -y install openjdk-8-jdk-headless \ | ||
&& apt -y autoremove \ | ||
&& apt -y autoclean | ||
|
||
ADD sources/metasfresh_webapi.tar.gz / | ||
|
||
COPY sources/start_webapi.sh /opt/metasfresh-webui-api/ | ||
RUN chmod 700 /opt/metasfresh-webui-api/start_webapi.sh | ||
|
||
ENTRYPOINT ["/opt/metasfresh-webui-api/start_webapi.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
DB_HOST=${DB_HOST:-db} | ||
APP_HOST=${APP_HOST:-app} | ||
|
||
set_properties() | ||
{ | ||
local prop_file="$1" | ||
if [[ $(cat $prop_file | grep FOO | wc -l) -ge "1" ]]; then | ||
sed -Ei "s/FOO_DBMS/$DB_HOST/g" $prop_file | ||
sed -Ei "s/FOO_APP/$APP_HOST/g" $prop_file | ||
fi | ||
} | ||
|
||
wait_dbms() | ||
{ | ||
until nc -z $DB_HOST 5432 | ||
do | ||
sleep 1 | ||
done | ||
} | ||
|
||
run_metasfresh() | ||
{ | ||
cd /opt/metasfresh-webui-api/ && java -jar metasfresh-webui-api.jar | ||
} | ||
|
||
|
||
set_properties /opt/metasfresh-webui-api/metasfresh.properties | ||
set_properties /opt/metasfresh-webui-api/local_settings.properties | ||
|
||
wait_dbms | ||
run_metasfresh | ||
|
||
exit 0 |
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,35 @@ | ||
FROM ubuntu:16.04 | ||
RUN apt update && apt -y full-upgrade | ||
RUN apt -y install apache2 \ | ||
&& apt -y install nodejs \ | ||
&& apt -y install npm \ | ||
&& apt -y install git \ | ||
&& apt -y autoremove \ | ||
&& apt -y autoclean | ||
|
||
RUN ln -s /usr/bin/nodejs /usr/bin/node | ||
RUN a2enmod proxy_http proxy_html rewrite | ||
RUN a2dissite 000-default.conf default-ssl.conf | ||
RUN npm install webpack -g | ||
|
||
ADD sources/metasfresh_webui.tar.gz / | ||
|
||
COPY sources/metasfresh_webui.conf /etc/apache2/sites-available/ | ||
RUN a2ensite metasfresh_webui.conf | ||
|
||
RUN chmod 700 /opt/metasfresh-webui-frontend/scripts/update_metasfresh-webui-frontend.sh | ||
RUN /opt/metasfresh-webui-frontend/scripts/update_metasfresh-webui-frontend.sh | ||
|
||
COPY sources/index.html /opt/metasfresh-webui-frontend/dist/ | ||
|
||
ENV APACHE_RUN_USER www-data | ||
ENV APACHE_RUN_GROUP www-data | ||
ENV APACHE_PID_FILE /var/run/apache2.pid | ||
ENV APACHE_RUN_DIR /var/run/apache2 | ||
ENV APACHE_LOCK_DIR /var/lock/apache2 | ||
ENV APACHE_LOG_DIR /var/log/apache2 | ||
|
||
RUN chown www-data:www-data -R /opt/metasfresh-webui-frontend/ | ||
|
||
EXPOSE 80 | ||
ENTRYPOINT ["/usr/sbin/apache2", "-D", "FOREGROUND"] |
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,16 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> | ||
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,500,500i" rel="stylesheet"> | ||
<link rel="icon" type="image/png" href="/favicon.png"> | ||
<title>metasfresh</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script src="/config.js"></script> | ||
<script type="text/javascript" src="/bundle.js"></script> | ||
</body> | ||
</html> |
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,12 @@ | ||
<VirtualHost *:80> | ||
ServerName webui | ||
ServerAdmin webmaster@localhost | ||
DocumentRoot /opt/metasfresh-webui-frontend/dist/ | ||
ErrorLog ${APACHE_LOG_DIR}/error.log | ||
CustomLog ${APACHE_LOG_DIR}/access.log combined | ||
<Directory /opt/metasfresh-webui-frontend/dist/> | ||
Options Indexes FollowSymLinks | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
</VirtualHost> |