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

Docker mimic iv postgres #1757

Open
wants to merge 3 commits into
base: main
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
4 changes: 4 additions & 0 deletions mimic-iv/buildmimic/postgres/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM postgres
COPY ./src/ /docker-entrypoint-initdb.d/
WORKDIR /app
EXPOSE 5432
37 changes: 37 additions & 0 deletions mimic-iv/buildmimic/postgres/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Getting MIMIC-IV up and running with Postgres and Docker
Use these scripts to quickly get setup with a containerized version of MIMIC-IV

## Steps
1. Install Docker
2. Download mimic data from PhysioNet by running the `download_data.sh` script. this will store the files in ./mimic-data/
3. Edit `POSTGRES_USER` and `POSTGRES_PASSWORD` as needed. Optionally, you can
change the host paths for the volume mounts if you would like to change where
the data are stored on the host machine.
4. Build and run the container by running `docker compose up`. This may take awhile.

Once complete you should have a containerized postgres instance containing MIMIC-IV data in the `mimiciv` database.

## Using the database

```bash
# spin up a container and detach
docker compose up -d

# you should now see a running container...e.g docker-mimic-db-1
docker ps

# if you have psql installed on the host machine you can do...password required
psql -U <username> -d mimiciv -h localhost

# if you do not have psql installed on host machine you can do...password not
# required
docker exec -it docker-mimic-db-1 psql -U <username> -d mimiciv

# psql on host machine...run profile script
psql -U <username> -d mimiciv -h localhost -f ../validate.sql

# psql not on host machine...need to mv validate into mount director so it can
# be accessed from container
cp ../validate.sql ./mimic-data/
docker exec -it docker-mimic-db-1 psql -U <username> -d mimiciv -f /data/validate.sql
```
30 changes: 30 additions & 0 deletions mimic-iv/buildmimic/postgres/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use postgres/example user/password credentials
version: '3.9'
services:
mimic-db:
image: mimiciv
build: .
restart: always
ports:
# you may need to change the host port if you have another postgres
# instance running on the host machine.
- 5432:5432
volumes:
# this mounts the mimic csv files to the /data/ directory within the
# container.
- ./mimic-data/:/data/
# this maps a directory on the host machine (i.e. ./mimic-db/) to the
# container so that the data in the database can persist after container
# has been shut down.
- /data/mimic-iv-db/:/var/lib/postgresql/data/
environment:
# this will be the name of the database within Postgres.
POSTGRES_DB: physionet-data
# set this to the same user that owns the directory storing the .csv data
# (hint: check ls -l ./mimic-data/) this should be the user of host
# machine. this will also be the user you will use to authenticate with
# postgres
POSTGRES_USER: mlbernauer
# this will be the password for authenticating with postgres...set to
# whatever you want
POSTGRES_PASSWORD: pass123
4 changes: 4 additions & 0 deletions mimic-iv/buildmimic/postgres/docker/download_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
read -p "Enter PhysioNet username: " USERNAME
echo "Downloading MIMIV-IV data to ./mimic-data/"
wget -P -A gz,txt ./mimic-data/ -r -N -c -nd -np --user ${USERNAME} --ask-password https://physionet.org/files/mimiciv/2.2/
Loading