Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add simple example docker-compose #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/simple/config/dhis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
connection.dialect = org.hibernate.dialect.PostgreSQLDialect
connection.driver_class = org.postgresql.Driver
connection.url = jdbc:postgresql://db/dhis
connection.username = dhis
connection.password = dhis

tracker.import.preheat.cache.enabled=off
40 changes: 40 additions & 0 deletions examples/simple/config/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="10">
<!-- Stream logs:
docker compose logs -f web
Stream logs of a particuar package only:
docker compose logs -f web | grep org.hisp.dhis.monitoring.metrics
Show timestamps:
docker compose logs -t -f web
-->
<Properties>
<Property name="layout">%-5level %c [%t] %msg%n</Property>
</Properties>

<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="${layout}" />
</Console>
</Appenders>

<Loggers>
<!--
This config logs events

for Loggers declared in packages prefixed with "org.hisp.dhis" i.e. "org.hisp.dhis.security"
from level INFO to more severe (WARN, ERROR, ...)

any Logger declared in a package not prefixed with "org.hisp.dhis" and
without a Logger config defined here will log from level WARN to more severe.

Adapt this config as you see fit.

Please check https://logging.apache.org/log4j/2.x/manual/configuration.html
-->
<Logger name="org.hisp.dhis" level="INFO" additivity="true"/>

<Root level="WARN">
<AppenderRef ref="console"/>
</Root>
</Loggers>
</Configuration>
50 changes: 50 additions & 0 deletions examples/simple/config/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
upstream web {
server web:8080 max_fails=3 fail_timeout=60s;
}

gzip on; # Enables compression, incl Web API content-types
gzip_types
"application/json;charset=utf-8" application/json
"application/javascript;charset=utf-8" application/javascript text/javascript
"application/xml;charset=utf-8" application/xml text/xml
"text/css;charset=utf-8" text/css
"text/plain;charset=utf-8" text/plain;

server {
listen 80;
port_in_redirect off;

root /data/apps;

client_max_body_size 25m;

# Redirect required to prevent 403 error on / access
rewrite ^/$ $scheme://$http_host/dhis-web-dashboard redirect;

location / {
include mime.types;
try_files $uri $uri/ $uri/index.html @web;
}

# location /screenshot {
# proxy_set_header Host $http_host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_pass http://screenshot:9000;
# }

location @web {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://web;
}
}
}
56 changes: 56 additions & 0 deletions examples/simple/config/server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<GlobalNamingResources>
<Resource
name="UserDatabase"
auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml"
/>
</GlobalNamingResources>

<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"
relaxedQueryChars='\ { } | [ ]'
/>

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm
className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"
/>
</Realm>

<Host
name="localhost"
appBase="webapps"
unpackWARs="true"
autoDeploy="false"
deployOnStartup="false"
>
<Context path="${context.path}" docBase="ROOT/" />

<Valve
className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b"
/>
</Host>
</Engine>
</Service>
</Server>
63 changes: 63 additions & 0 deletions examples/simple/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: "3.8"

services:
web:
image: "${DHIS2_IMAGE:-dhis2/core:2.40.1}"
restart: unless-stopped
volumes:
- files:/opt/dhis2
- ./config/dhis.conf:/opt/dhis2/dhis.conf:ro
- ./config/log4j2.xml:/opt/dhis2/log4j2.xml:ro
- ./config/server.xml:/usr/local/tomcat/conf/server.xml
environment:
JAVA_OPTS: "-Dcontext.path='${DHIS2_CORE_CONTEXT_PATH:-}' \
-Dlog4j2.configurationFile=/opt/dhis2/log4j2.xml"
depends_on:
db:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -q -S -O /dev/null http://127.0.0.1:8080/dhis-web-commons/security/login.action 2>&1| grep -q 'HTTP.*200'"]
start_period: 120s
interval: 10s
timeout: 5s
retries: 5
security_opt:
- no-new-privileges:true

db:
image: postgis/postgis
restart: unless-stopped
volumes:
- postgresql:/var/lib/postgresql
environment:
POSTGRES_USER: dhis
POSTGRES_DB: dhis
POSTGRES_PASSWORD: &postgres_password dhis
PGPASSWORD: *postgres_password # needed by psql in healthcheck
healthcheck:
test: ["CMD-SHELL", "psql --no-password --quiet --username $$POSTGRES_USER postgres://127.0.0.1/$$POSTGRES_DB -p 5432 --command \"SELECT 'ok'\" > /dev/null"]
start_period: 120s
interval: 10s
timeout: 3s
retries: 5
security_opt:
- no-new-privileges:true

gateway:
image: nginx
restart: always
depends_on:
web:
condition: service_healthy
ports:
- "${DHIS2_PORT:-8080}:80"
volumes:
- ./config/nginx.conf:/etc/nginx/nginx.conf:ro
security_opt:
- no-new-privileges:true

volumes:
files:
driver: local
postgresql:
driver: local
7 changes: 7 additions & 0 deletions simple/config/dhis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
connection.dialect = org.hibernate.dialect.PostgreSQLDialect
connection.driver_class = org.postgresql.Driver
connection.url = jdbc:postgresql://db/dhis
connection.username = dhis
connection.password = dhis

tracker.import.preheat.cache.enabled=off
40 changes: 40 additions & 0 deletions simple/config/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="10">
<!-- Stream logs:
docker compose logs -f web
Stream logs of a particuar package only:
docker compose logs -f web | grep org.hisp.dhis.monitoring.metrics
Show timestamps:
docker compose logs -t -f web
-->
<Properties>
<Property name="layout">%-5level %c [%t] %msg%n</Property>
</Properties>

<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="${layout}" />
</Console>
</Appenders>

<Loggers>
<!--
This config logs events

for Loggers declared in packages prefixed with "org.hisp.dhis" i.e. "org.hisp.dhis.security"
from level INFO to more severe (WARN, ERROR, ...)

any Logger declared in a package not prefixed with "org.hisp.dhis" and
without a Logger config defined here will log from level WARN to more severe.

Adapt this config as you see fit.

Please check https://logging.apache.org/log4j/2.x/manual/configuration.html
-->
<Logger name="org.hisp.dhis" level="INFO" additivity="true"/>

<Root level="WARN">
<AppenderRef ref="console"/>
</Root>
</Loggers>
</Configuration>
50 changes: 50 additions & 0 deletions simple/config/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
upstream web {
server web:8080 max_fails=3 fail_timeout=60s;
}

gzip on; # Enables compression, incl Web API content-types
gzip_types
"application/json;charset=utf-8" application/json
"application/javascript;charset=utf-8" application/javascript text/javascript
"application/xml;charset=utf-8" application/xml text/xml
"text/css;charset=utf-8" text/css
"text/plain;charset=utf-8" text/plain;

server {
listen 80;
port_in_redirect off;

root /data/apps;

client_max_body_size 25m;

# Redirect required to prevent 403 error on / access
rewrite ^/$ $scheme://$http_host/dhis-web-dashboard redirect;

location / {
include mime.types;
try_files $uri $uri/ $uri/index.html @web;
}

# location /screenshot {
# proxy_set_header Host $http_host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_pass http://screenshot:9000;
# }

location @web {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://web;
}
}
}
56 changes: 56 additions & 0 deletions simple/config/server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<GlobalNamingResources>
<Resource
name="UserDatabase"
auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml"
/>
</GlobalNamingResources>

<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"
relaxedQueryChars='\ { } | [ ]'
/>

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm
className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"
/>
</Realm>

<Host
name="localhost"
appBase="webapps"
unpackWARs="true"
autoDeploy="false"
deployOnStartup="false"
>
<Context path="${context.path}" docBase="ROOT/" />

<Valve
className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b"
/>
</Host>
</Engine>
</Service>
</Server>
Loading