Skip to content

Commit 3b3e1d4

Browse files
committed
chore(localdev): docker compose setup
1 parent ba6ad48 commit 3b3e1d4

File tree

13 files changed

+599
-52
lines changed

13 files changed

+599
-52
lines changed

.dockerignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Docker development artifacts
2+
.git
3+
.gitignore
4+
.github
5+
.local
6+
.pre-commit-config.yaml
7+
.phpcs.xml
8+
.composer-require-checker.json
9+
phpstan.neon
10+
rector.php
11+
compose.yml
12+
.dockerignore
13+
docker/
14+
15+
# IDE and editor files
16+
.idea
17+
.vscode
18+
*.swp
19+
*.swo
20+
21+
# Test files
22+
tests
23+
24+
# Documentation
25+
README.md
26+
CHANGELOG.md
27+
.docs/
28+
29+
# CI/CD
30+
.release-please-manifest.json
31+
release-please-config.json
32+
33+
# Keep these - needed at runtime:
34+
# !vendor/ (composer dependencies - NEEDED)
35+
# !node_modules/ (npm dependencies - NEEDED if used)
36+
# !public/assets/ (built assets - NEEDED)

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,32 @@ See [`POLLING-ARCHITECTURE.md`](./POLLING-ARCHITECTURE.md) for detailed implemen
314314

315315
## Development
316316

317+
### Docker Development Environment
318+
319+
Quick setup for local module development:
320+
321+
```bash
322+
# 1. Clone and install dependencies
323+
git clone https://github.com/opencoreemr/oce-module-sinch-conversations.git
324+
cd oce-module-sinch-conversations
325+
composer install
326+
327+
# 2. Pre-build OpenEMR (optional but recommended - saves 5-10 min)
328+
cd vendor/openemr/openemr
329+
composer install --no-dev
330+
npm install --legacy-peer-deps && npm run build
331+
cd ../../..
332+
333+
# 3. Start Docker environment
334+
docker compose up -d --wait
335+
336+
# 4. Get the port and open in browser
337+
docker compose port openemr 80
338+
# Visit http://localhost:PORT and login with admin/pass
339+
```
340+
341+
**All local changes are immediately reflected** - no rebuild needed! See [`docker/README.md`](./docker/README.md) for details.
342+
317343
### PHI-Free Development
318344

319345
**60-70% of this module can be developed without any PHI:**

compose.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# OpenEMR Docker Environment for Module Testing
2+
# Uses a simplified entrypoint that just runs the installer and starts Apache
3+
# (avoids the slow chown operations in the standard openemr.sh entrypoint)
4+
#
5+
# IMPORTANT: Pre-build OpenEMR dependencies locally for faster startup:
6+
# cd vendor/openemr/openemr
7+
# composer install --no-dev
8+
# npm install --legacy-peer-deps && npm run build
9+
# cd ../../..
10+
#
11+
# Usage:
12+
# 1. composer install (installs module + downloads OpenEMR source)
13+
# 2. Pre-build OpenEMR (see above - optional but recommended)
14+
# 3. docker compose up -d --wait
15+
# 4. docker compose port openemr 80 (get assigned port)
16+
# 5. Login: admin / pass
17+
# 6. Admin > Modules > Manage Modules > Enable module
18+
19+
services:
20+
mysql:
21+
restart: unless-stopped
22+
image: mariadb:11.4
23+
command:
24+
- mariadbd
25+
- --character-set-server=utf8mb4
26+
ports:
27+
- 3306
28+
volumes:
29+
- databasevolume:/var/lib/mysql
30+
environment:
31+
MYSQL_ROOT_PASSWORD: root
32+
healthcheck:
33+
test: [CMD, healthcheck.sh, --connect, --innodb_initialized]
34+
start_period: 30s
35+
interval: 10s
36+
timeout: 5s
37+
retries: 5
38+
39+
openemr:
40+
restart: unless-stopped
41+
image: openemr/openemr:flex
42+
entrypoint: [/custom-entrypoint.sh]
43+
ports:
44+
- 80
45+
- 443
46+
volumes:
47+
# Custom entrypoint scripts (installer + apache, no complex setup)
48+
- ./docker/entrypoint.sh:/custom-entrypoint.sh:ro
49+
- ./docker/entrypoint.php:/custom-entrypoint.php:ro
50+
# Mount OpenEMR directly to runtime location (pre-built with composer/npm)
51+
- ./vendor/openemr/openemr:/var/www/localhost/htdocs/openemr:rw
52+
# Mount our module into the custom_modules directory
53+
- .:/var/www/localhost/htdocs/openemr/interface/modules/custom_modules/oce-module-sinch-conversations:rw
54+
# Persistent volume for logs only (sites uses bind mount for dev)
55+
- logvolume:/var/log
56+
environment:
57+
# MySQL connection settings
58+
MYSQL_HOST: mysql
59+
MYSQL_PORT: 3306
60+
MYSQL_ROOT_USER: root
61+
MYSQL_ROOT_PASS: root
62+
MYSQL_USER: openemr
63+
MYSQL_PASS: openemr
64+
MYSQL_DATABASE: openemr
65+
# OpenEMR admin user settings
66+
OE_USER: admin
67+
OE_PASS: pass
68+
# Enable REST APIs for testing
69+
OPENEMR_SETTING_rest_api: 1
70+
OPENEMR_SETTING_rest_fhir_api: 1
71+
depends_on:
72+
mysql:
73+
condition: service_healthy
74+
healthcheck:
75+
test: [CMD, curl, -f, http://localhost/interface/login/login.php]
76+
start_period: 300s
77+
interval: 30s
78+
timeout: 10s
79+
retries: 5
80+
81+
phpmyadmin:
82+
restart: unless-stopped
83+
image: phpmyadmin
84+
ports:
85+
- 80
86+
environment:
87+
PMA_HOSTS: mysql
88+
healthcheck:
89+
test: [CMD, curl, -f, http://localhost/]
90+
start_period: 10s
91+
interval: 10s
92+
timeout: 5s
93+
retries: 3
94+
depends_on:
95+
mysql:
96+
condition: service_healthy
97+
98+
volumes:
99+
databasevolume: {}
100+
sitesvolume: {}
101+
logvolume: {}

composer.json

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,72 @@
3434
"ext-json": "*",
3535
"guzzlehttp/guzzle": "^7.0",
3636
"openemr/oe-module-installer-plugin": "^0.1.5",
37-
"symfony/event-dispatcher": "^6.0 || ^7.0",
38-
"symfony/http-foundation": "^6.0 || ^7.0",
37+
"symfony/event-dispatcher": "^6.4",
38+
"symfony/http-foundation": "^6.4",
3939
"twig/twig": "^3.0"
4040
},
4141
"require-dev": {
4242
"ergebnis/composer-normalize": "^2.44",
43-
"maglnet/composer-require-checker": "^4.0",
44-
"phpstan/phpstan": "^2.1",
45-
"rector/rector": "^2.0",
46-
"squizlabs/php_codesniffer": "^4.0"
43+
"maglnet/composer-require-checker": "~4.7.1",
44+
"openemr/openemr": ">=7.0.3.4 || 7.0.4.x-dev || dev-master",
45+
"phpstan/phpstan": "^1.10",
46+
"rector/rector": "^1.0",
47+
"squizlabs/php_codesniffer": "^3.0"
4748
},
48-
"minimum-stability": "stable",
49+
"repositories": [
50+
{
51+
"type": "package",
52+
"package": {
53+
"name": "openemr/openemr",
54+
"version": "7.0.3.4",
55+
"autoload": {
56+
"psr-4": {
57+
"OpenEMR\\": "src/"
58+
}
59+
},
60+
"source": {
61+
"type": "git",
62+
"url": "https://github.com/openemr/openemr.git",
63+
"reference": "v7_0_3_4"
64+
}
65+
}
66+
},
67+
{
68+
"type": "package",
69+
"package": {
70+
"name": "openemr/openemr",
71+
"version": "7.0.4.x-dev",
72+
"autoload": {
73+
"psr-4": {
74+
"OpenEMR\\": "src/"
75+
}
76+
},
77+
"source": {
78+
"type": "git",
79+
"url": "https://github.com/openemr/openemr.git",
80+
"reference": "rel-704"
81+
}
82+
}
83+
},
84+
{
85+
"type": "package",
86+
"package": {
87+
"name": "openemr/openemr",
88+
"version": "dev-master",
89+
"autoload": {
90+
"psr-4": {
91+
"OpenEMR\\": "src/"
92+
}
93+
},
94+
"source": {
95+
"type": "git",
96+
"url": "https://github.com/openemr/openemr.git",
97+
"reference": "master"
98+
}
99+
}
100+
}
101+
],
102+
"minimum-stability": "dev",
49103
"prefer-stable": true,
50104
"autoload": {
51105
"psr-4": {
@@ -56,7 +110,8 @@
56110
"config": {
57111
"allow-plugins": {
58112
"ergebnis/composer-normalize": true,
59-
"openemr/oe-module-installer-plugin": true
113+
"openemr/oe-module-installer-plugin": true,
114+
"php-http/discovery": true
60115
}
61116
},
62117
"extra": {

docker/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Docker Development Environment
2+
3+
This directory contains Docker configuration for testing the Sinch Conversations module.
4+
5+
**Key Feature:** Uses a simplified custom entrypoint (`entrypoint-simple.sh`) that bypasses the standard OpenEMR entrypoint's slow permission-setting operations, making startup much faster on macOS.
6+
7+
## Quick Start
8+
9+
```bash
10+
# 1. Install module dependencies
11+
composer install
12+
13+
# 2. Build OpenEMR dependencies (OPTIONAL - speeds up first start)
14+
# If you skip this, the container will build them automatically (slower)
15+
cd vendor/openemr/openemr
16+
composer install --no-dev
17+
npm install --legacy-peer-deps
18+
npm run build
19+
cd ../../..
20+
21+
# 3. Start the environment
22+
docker compose up -d --wait
23+
24+
# 4. Get the assigned port
25+
docker compose port openemr 80 # OpenEMR HTTP (e.g., 0.0.0.0:32768)
26+
27+
# 5. Open browser to http://localhost:PORT and login
28+
```
29+
30+
**Pro Tip:** Pre-building OpenEMR's dependencies (step 2) saves ~5-10 minutes on first container start. The Docker entrypoint detects existing builds and skips rebuilding.
31+
32+
## Default Credentials
33+
34+
| Service | Username | Password |
35+
|---------|----------|----------|
36+
| OpenEMR | admin | pass |
37+
| MySQL | root | root |
38+
39+
## Enable the Module
40+
41+
1. Log into OpenEMR as admin
42+
2. Go to **Administration > Modules > Manage Modules**
43+
3. Click **Register** next to "oce-module-sinch-conversations"
44+
4. Click **Install** and then **Enable**
45+
46+
## Development Workflow
47+
48+
**Local changes are immediately reflected** - no rebuild needed:
49+
- Edit any PHP file → refresh browser to see changes
50+
- Edit Twig templates → refresh browser
51+
- Run `composer install` in module → dependencies available immediately
52+
- Modify CSS/JS in `public/assets/` → refresh browser
53+
54+
The container has `OPCACHE_OFF=1` so PHP code changes are instant.
55+
56+
## Useful Commands
57+
58+
```bash
59+
# View logs
60+
docker compose logs -f openemr
61+
62+
# Stop environment
63+
docker compose down
64+
65+
# Stop and remove all data (fresh start)
66+
docker compose down -v
67+
68+
# Restart OpenEMR container (rarely needed)
69+
docker compose restart openemr
70+
71+
# Rebuild OpenEMR dependencies after updating OpenEMR version
72+
cd vendor/openemr/openemr && composer install --no-dev && npm install --legacy-peer-deps && npm run build && cd ../../..
73+
```
74+
75+
## File Locations
76+
77+
- **Module mount**: `/var/www/localhost/htdocs/openemr/interface/modules/custom_modules/oce-module-sinch-conversations`
78+
- **OpenEMR logs**: Check `docker compose logs openemr`
79+
- **Writable data**: `/var/www/localhost/htdocs/openemr/sites` (volume)
80+
81+
## Notes
82+
83+
- **Custom entrypoint**: We use `docker/entrypoint-simple.sh` instead of the standard `openemr.sh`
84+
- Runs InstallerAuto.php to configure OpenEMR (once)
85+
- Starts Apache immediately
86+
- Skips slow `chown` operations that take 5-10 minutes on macOS bind mounts
87+
- Much faster startup (~30 seconds instead of 10 minutes)
88+
- **Pre-built OpenEMR**: Mount pre-built OpenEMR from `vendor/openemr/openemr`
89+
- Run `composer install --no-dev` and `npm install && npm run build` locally first
90+
- Container uses pre-built artifacts, no need to rebuild inside Docker
91+
- **Persistent data**: Patient data, configurations, and uploads live in `sitesvolume` Docker volume
92+
- Survives container restarts
93+
- Use `docker compose down -v` to completely reset
94+
- **Live reload**: Code changes are immediately reflected since bind mounts update in real-time

0 commit comments

Comments
 (0)