Skip to content

Commit

Permalink
Merge pull request #81 from EyeSeeTea/development
Browse files Browse the repository at this point in the history
Release 1.5.0
  • Loading branch information
ifoche authored Jan 6, 2022
2 parents 55a074b + ba3996c commit 702ac5c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Some notes:
- Use option `--run-sql=DIRECTORY` to run SQL files (.sql, .sql.gz or .dump files) after the DB has been initialized.
- Use option `--run-scripts=DIRECTORY` to run shell scripts (.sh) from a directory within the `dhis2-core` container. By default, a script is run **after** postgres starts (`host=db`, `port=5432`) but **before** Tomcat starts; if its filename starts with prefix "post", it will be run **after** Tomcat is available. `curl` and typical shell tools are available on that Alpine Linux environment. Note that the Dhis2 endpoint is always `http://localhost:8080/${deployPath}`, regardless of the public port that the instance is exposed to.
- Use option `--java-opts="JAVA_OPTS"` to override the default JAVA_OPTS for the Tomcat process. That's tipically used to set the maximum/initial Heap Memory size (for example: `--java-opts="-Xmx3500m -Xms2500m"`)
- Use option `--postgis-version=13-3.1-alpine` to specify the PostGIS version to use. By default, 10-2.5-alpine is used.

#### Custom DHIS2 dhis.conf

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setuptools.setup(
name="d2_docker",
version="1.4.0",
version="1.5.0",
description="Dockers for DHIS2 instances",
long_description=open("README.md", encoding="utf-8").read(),
keywords=["python"],
Expand Down
11 changes: 8 additions & 3 deletions src/d2_docker/commands/list_.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ def get_images_info(running_containers):

def get_running_containers():
"""Return dictionary of {DATA_IMAGE_NAME: PORT} of active d2-docker instances."""
fmt = '{{.Label "com.eyeseetea.image-name"}} {{.Ports}} {{.Label "com.eyeseetea.deploy-path"}}'
lines = utils.run_docker_ps(["--format=" + fmt])
lines_parts_ps = [line.split(None, 2) for line in lines]
sep = " | "
fmt = [
'{{.Label "com.eyeseetea.image-name"}}',
"{{.Ports}}",
'{{.Label "com.eyeseetea.deploy-path"}}',
]
lines = utils.run_docker_ps(["--format=" + sep.join(fmt)])
lines_parts_ps = [line.split(sep) for line in lines]

running_containers = {}
for entry in lines_parts_ps:
Expand Down
10 changes: 7 additions & 3 deletions src/d2_docker/commands/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def setup(parser):


def run(args):
image_name = args.image or utils.get_running_image_name()
utils.logger.info("Push image: {}".format(image_name))
utils.push_image(image_name)
data_image_name = args.image or utils.get_running_image_name()
utils.logger.info("Push data image: {}".format(data_image_name))
utils.push_image(data_image_name)

core_image_name = utils.get_core_image_name(data_image_name)
utils.logger.info("Push core image: {}".format(core_image_name))
utils.push_image(core_image_name)
4 changes: 4 additions & 0 deletions src/d2_docker/commands/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def setup(parser):
parser.add_argument("--tomcat-server-xml", metavar="FILE", help=server_xml_help)
parser.add_argument("--dhis-conf", metavar="FILE", help=dhis_conf_help)
parser.add_argument("--run-sql", metavar="DIRECTORY", help="Run .sql[.gz] files in directory")
parser.add_argument("--db-port", metavar="PORT", help="Export DB Postgres port")
parser.add_argument(
"--run-scripts",
metavar="DIRECTORY",
Expand All @@ -35,6 +36,7 @@ def setup(parser):
parser.add_argument("-p", "--port", type=int, metavar="N", help="Set Dhis2 instance port")
parser.add_argument("--deploy-path", type=str, help="Set Tomcat context.path")
parser.add_argument("--java-opts", type=str, help="Set Tomcat JAVA_OPTS")
parser.add_argument("--postgis-version", type=str, help="Set PostGIS database version")


def run(args):
Expand Down Expand Up @@ -93,12 +95,14 @@ def start(args, image_name):
core_image=core_image,
load_from_data=override_containers,
post_sql_dir=args.run_sql,
db_port=args.db_port,
scripts_dir=args.run_scripts,
deploy_path=deploy_path,
dhis2_auth=args.auth,
tomcat_server=args.tomcat_server_xml,
dhis_conf=args.dhis_conf,
java_opts=args.java_opts,
postgis_version=args.postgis_version,
)

if args.detach:
Expand Down
2 changes: 1 addition & 1 deletion src/d2_docker/config/DHIS2_home/dhis.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ connection.password = dhis
# Database schema behavior, can be validate, update, create, create-drop
connection.schema = update

encryption.password = xxxx
encryption.password = xxxxxxxxxxxxxxxxxxxxxxxx
metadata.audit.persist = on
4 changes: 3 additions & 1 deletion src/d2_docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
depends_on:
- "db"
db:
image: "mdillon/postgis:10-alpine"
image: "postgis/postgis:${POSTGIS_VERSION:-10-2.5-alpine}"
labels:
- "com.eyeseetea.image-name=${DHIS2_DATA_IMAGE}"
volumes:
Expand All @@ -35,6 +35,8 @@ services:
POSTGRES_PASSWORD: dhis
command: "postgres -c max_locks_per_transaction=100"
restart: unless-stopped
ports:
- "${DB_PORT}"
gateway:
image: "jwilder/nginx-proxy:alpine"
labels:
Expand Down
6 changes: 5 additions & 1 deletion src/d2_docker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def get_image_status(image_name):


def get_port_from_docker_ports(info):
port_re = r"0\.0\.0\.0:(\d+)->"
port_re = r"0\.0\.0\.0:(\d+)->80"
match = re.match(port_re, info)
port = int(match.group(1)) if match else None
return port
Expand Down Expand Up @@ -224,12 +224,14 @@ def run_docker_compose(
port=None,
load_from_data=True,
post_sql_dir=None,
db_port=None,
scripts_dir=None,
deploy_path=None,
dhis_conf=None,
java_opts=None,
dhis2_auth=None,
tomcat_server=None,
postgis_version=None,
**kwargs,
):
"""
Expand Down Expand Up @@ -258,6 +260,8 @@ def run_docker_compose(
("DHIS2_AUTH", dhis2_auth or ""),
("TOMCAT_SERVER", get_absfile_for_docker_volume(tomcat_server)),
("DHIS_CONF", get_absfile_for_docker_volume(dhis_conf)),
("POSTGIS_VERSION", postgis_version),
("DB_PORT", ("{}:5432".format(db_port) if db_port else "0:1000")),
]
env = dict((k, v) for (k, v) in [pair for pair in env_pairs if pair] if v is not None)

Expand Down

0 comments on commit 702ac5c

Please sign in to comment.