Skip to content

Instantly share code, notes, and snippets.

@myh-st
Forked from citizenrich/README.md
Created October 20, 2022 04:02
Show Gist options
  • Save myh-st/a2478f8133277c5e2f6b6dd8c7c6718b to your computer and use it in GitHub Desktop.
Save myh-st/a2478f8133277c5e2f6b6dd8c7c6718b to your computer and use it in GitHub Desktop.
How to setup HAPI FHIR and Postgres in Docker

Start with a fresh folder and copy a hapi.properties into it. It will be mounted into the container.

Carefully make sure your hapi.properties looks like this:

# add postgres
datasource.driver=org.postgresql.Driver
datasource.url=jdbc:postgresql://db:5432/hapi
hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect
datasource.username=admin
datasource.password=admin
# comment out derby
# datasource.driver=org.h2.Driver
# datasource.url=jdbc:h2:file:./target/database/h2
# datasource.username=
# datasource.password=

...
###################################################
# Database Settings
###################################################
# comment this out
# hibernate.dialect=org.hibernate.dialect.H2Dialect

Add the docker-compose below, and docker-compose up. Visit: http://localhost:8080/hapi-fhir-jpaserver/

To troubleshoot:

  • Database stuff: Connect to the database at localhost:5432 using your tool of choice with user admin, pass admin, and to db hapi. Obviously, don't use the same settings in production.
  • HAPI: Run docker ps to get your container id. Then run commands you need to in the running container like: docker exec <containerid> /bin/bash -c 'cat /usr/local/tomcat/conf/hapi.properties
version: "3"
services:
hapi-fhir-jpaserver-start:
image: hapiproject/hapi:v4.2.0
container_name: hapi-fhir-jpaserver-start
restart: on-failure
ports:
- "8080:8080"
environment:
- JAVA_OPTS='-Dhapi.properties=/usr/local/tomcat/conf/hapi.properties'
volumes:
- ./hapi.properties:/usr/local/tomcat/conf/hapi.properties
depends_on:
- db
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: admin
POSTGRES_USER: admin
POSTGRES_DB: hapi
# not needed for networking between containers but here for troubleshooting
ports:
- "5432:5432"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment