Hi, Please tell me to what extent PostgreSQL can be used as a database for OpenMRS in Ozone HIS, within a Docker implementation.I have correctly configured the openmrs-server.properties file to use PostgreSQL as the database, but the backend is still requesting MySQL.
Hello, Ozone is currently on OpenMRS platform 2.7.4 Support for PostgreSQL was added in 2.8.0. We will upgrade soon.
@achachiez support for PostgreSQL has always been there since version 2.4.0
So, you do not have to upgrade to 2.8.0
If you encounter any problems with it, feel free to share them. ![]()
Thank you for this information
Yes, I’ve concluded that my problem isn’t with the database I’m using. I have a real issue connecting to the database (even MySQL), and despite all the configurations, I still get this error.
docker-compose.yml
version: "3.9"
services:
db:
image: postgres:15
container_name: docker_db_1
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- db_data:/var/lib/postgresql/data
healthcheck:
test: \["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"\]
interval: 5s
timeout: 3s
retries: 20
mysql:
image: mysql:5.7
container_name: docker_mysql_1
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ${MYSQL_DB}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- "3306:3306"
healthcheck:
test: \["CMD", "mysqladmin", "ping", "-h", "localhost", "-uopenmrs", "-popenmrs"\]
interval: 10s
timeout: 5s
retries: 10
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes:
- mysql_data:/var/lib/mysql
networks:
- backend_net
backend:
image: ${BACKEND_IMAGE}
container_name: docker_backend_1
restart: unless-stopped
depends_on:
mysql:
condition: service_healthy
environment:
OMRS_CONFIG_DATABASE: mysql
DB_HOST: mysql
DB_DATABASE: ${MYSQL_DB}
DB_USERNAME: ${MYSQL_USER}
DB_PASSWORD: ${MYSQL_PASSWORD}
OMRS_CONFIG_DIR: /openmrs/data/configuration
*# Optionnel: boostrap si besoin*
*# OMRS_CREATE_TABLES: "true"*
*# OMRS_AUTO_UPDATE: "true"*
*# Force l'URL & le driver modernes (évite "localhost")*
entrypoint: >
sh -c "( /openmrs/startup.sh & sleep 5 && cp /config/openmrs-server.properties /openmrs/openmrs-server.properties && wait )"
volumes:
- ./volumes/modules:/openmrs/data/modules
- ./volumes/configuration:/openmrs/data/configuration
- ./volumes/openmrs/openmrs-server.properties:/config/openmrs-server.properties:ro
networks:
- backend_net
frontend:
image: ${FRONTEND_IMAGE}
container_name: docker_frontend_1
restart: unless-stopped
environment:
API_URL: ${API_URL}
SPA_PATH: ${SPA_PATH}
SPA_CONFIG_URLS: ${SPA_CONFIG_URLS}
volumes:
- ./volumes/spa-configs:/usr/share/nginx/html/spa/configs
gateway:
image: openmrs/openmrs-reference-application-3-gateway:qa
container_name: docker_gateway_1
restart: unless-stopped
depends_on:
backend:
condition: service_started
frontend:
condition: service_started
environment:
BACKEND_URL: http://backend:8080
FRONTEND_URL: http://frontend:80
ports:
- "${HTTP_PORT:-8081}:80"
volumes:
db_data:
mysql_data:
networks:
backend_net:
.env
POSTGRES_IMAGE=postgres:15
POSTGRES_DB=openmrs
POSTGRES_USER=openmrs
POSTGRES_PASSWORD=StrongPassw0rd!
MYSQL_IMAGE=mysql:5.7
MYSQL_DB=openmrs
MYSQL_USER=openmrs
MYSQL_PASSWORD=openmrs
BACKEND_IMAGE=openmrs/openmrs-reference-application-3-backend:qa
FRONTEND_IMAGE=openmrs/openmrs-reference-application-3-frontend:qa
API_URL=/openmrs
SPA_PATH=/openmrs/spa
SPA_CONFIG_URLS=/openmrs/spa/configs/referenceapplication/config.json,/openmrs/>
HTTP_PORT=8081
openmrs-server.properties
connection.driver_class=com.mysql.jdbc.Driver
connection.url=jdbc:mysql://mysql:3306/openmrs?autoReconnect=true&sessionVariab>
connection.username=openmrs
connection.password=openmrs
auto_update_database=true
create_tables=true
has_current_openmrs_database=true
install_method=auto
module_web_admin=true
module.allow_web_admin=true
property.hibernate.search.backend.type=lucene
property.hibernate.search.backend.analysis.configurer=luceneConfig
property.hibernate.search.backend.uris=http://es:9200
property.hibernate.search.backend.discovery.enabled=true
error
neo@odoo:\~/cdlart/docker$ docker exec -it docker_backend_1 cat /openmrs/openmrs-server.properties
admin_user_password=Admin123
admin_password_locked=false
auto_update_database=true
connection.driver_class=com.mysql.jdbc.Driver
connection.username=openmrs
connection.password=openmrs
connection.url=jdbc:mysql://localhost:3306/openmrs?autoReconnect=true&sessionVariables=default_storage_engine=InnoDB&useUnicode=true&characterEncoding=UTF-8
create_database_user=false
create_tables=true
has_current_openmrs_database=true
install_method=auto
module_web_admin=true
module.allow_web_admin=true
property.hibernate.search.backend.type=lucene
property.hibernate.search.backend.analysis.configurer=luceneConfig
property.hibernate.search.backend.uris=http://es:9200
property.hibernate.search.backend.discovery.enabled=true
Ooooooh. I had no idea. In that case, we should probably have it as an option out of the box with Ozone. @attia We will look into it. For now, you may have to work around it with an extra Docker Compose file setting the OMRS_DB env to postgresql
@achachiez we are not sure though that all will be ok with openmrs-eip and Postgres, right?
@mksd That will definitely need some work before we can support it.
I’m not sure you posted the error that you’re referring to?
I guess we don’t have this documented anywhere, so here goes an attempt at what the configuration should look like to have the OpenMRS backend setup with Postgres in Docker Compose (I’ve omitted irrelevant services and stanzas from our default RefApp setup; I think Ozone has other recommended settings that may not be here):
backend:
image: openmrs/openmrs-reference-application-3-backend:${TAG:-qa}
restart: "unless-stopped"
depends_on:
- db
environment:
OMRS_MODULE_WEB_ADMIN: "true"
OMRS_AUTO_UPDATE_DATABASE: "true"
OMRS_CREATE_TABLES: "true"
OMRS_DB: postgresql
OMRS_DB_PORT: 5432
OMRS_DB_HOSTNAME: db
OMRS_DB_NAME: openmrs
OMRS_DB_USERNAME: ${OMRS_DB_USER:-openmrs}
OMRS_DB_PASSWORD: ${OMRS_DB_PASSWORD:-openmrs}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/openmrs"]
timeout: 5s
volumes:
- openmrs-data:/openmrs/data
db:
image: postgres:15
restart: "unless-stopped"
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-d", "openmrs"]
interval: 30s
timeout: 1s
retries: 5
environment:
POSTGRES_DB: openmrs
POSTGRES_USER: ${OMRS_DB_USER:-openmrs}
POSTGRES_PASSWORD: ${OMRS_DB_PASSWORD:-openmrs}
volumes:
- db-data:/var/lib/postgresql/data
Note that we don’t really test the O3 RefApp against Postgres, so there may be issues.
Thank you for your reply. Sorry, I’m new to Ozone HIS and I don’t really understand how it works. When I create my own distribution as described in the Ozone documentation, how do I manage the Docker containers? Where do I access these containers so I don’t have to create more? How do I add my own modules or modify existing ones?
OK, thanks
Well, they are also in the docker-compose files you posted, so I’d presume they’d overwrite things. But as you may have noticed, there’s some discussion here that Ozone’s interoperability layer doesn’t yet work with OpenMRS running on Postgres, so I wouldn’t recommend trying this until Ozone fully supports Postgres.
ok, thanks
Could you please tell me what caused this error?
neo@odoo:\~/Documents/cdl-his/target/cdl-his-1.0.0-SNAPSHOT/run/docker/scripts$ ls
destroy-demo.sh go-to-scripts-dir.sh ozone-dir.env start.sh
docker-compose-files.txt mvnw ozone-urls-template.csv stop-demo.sh
fetch-ozone-distro.sh mvnw.cmd start-demo.sh utils.sh
neo@odoo:\~/Documents/cdl-his/target/cdl-his-1.0.0-SNAPSHOT/run/docker/scripts$ ./start-demo.sh
Setting DEMO=true…
→ DEMO=true
→ DISTRO_PATH=../../distro
\[INFO\] Exporting distro paths…
→ OPENMRS_CONFIG_PATH=../../distro/configs/openmrs/initializer_config
→ OPENMRS_PROPERTIES_PATH=../../distro/configs/openmrs/properties
→ OPENMRS_MODULES_PATH=../../distro/binaries/openmrs/modules
→ SPA_PATH=/openmrs/spa
→ SENAITE_CONFIG_PATH=../../distro/configs/senaite/initializer_config
→ ODOO_EXTRA_ADDONS=../../distro/binaries/odoo/addons
→ ODOO_CONFIG_PATH=../../distro/configs/odoo/initializer_config/
→ ODOO_CONFIG_FILE_PATH=../../distro/configs/odoo/config/odoo.conf
→ EIP_ODOO_OPENMRS_ROUTES_PATH=../../distro/binaries/eip-odoo-openmrs
→ EIP_OPENMRS_SENAITE_ROUTES_PATH=../../distro/binaries/eip-openmrs-senaite
→ EIP_ERPNEXT_OPENMRS_ROUTES_PATH=../../distro/binaries/eip-erpnext-openmrs
→ OPENMRS_FRONTEND_CONFIG_PATH=../../distro/configs/openmrs/frontend_config/
→ SQL_SCRIPTS_PATH=../../distro/data/
→ SUPERSET_CONFIG_PATH=../../distro/configs/superset/
→ ERPNEXT_CONFIG_PATH=../../distro/configs/erpnext/initializer_config/
→ ERPNEXT_SCRIPTS_PATH=../../distro/binaries/erpnext/scripts/
\[INFO\] $TRAEFIK!=true, setting Nginx hostnames…
\[INFO\] Exporting Nginx hostnames…
→ O3_HOSTNAME=localhost
→ ODOO_HOSTNAME=localhost:8069
→ SENAITE_HOSTNAME=localhost:8081
→ SUPERSET_HOSTNAME=localhost:8088
→ ERPNEXT_HOSTNAME=localhost:8082
\[INFO\] DEMO=true, setting the number of demo patients…
→ NUMBER_OF_DEMO_PATIENTS=50
\[INFO\] Pulling Ozone FOSS images…
unknown shorthand flag: ‘p’ in -p
See ‘docker --help’.