-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathContainerfile
More file actions
644 lines (546 loc) · 22.3 KB
/
Copy pathContainerfile
File metadata and controls
644 lines (546 loc) · 22.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
# OpenEMR Container - CentOS Stream 10 with Remi PHP 8.5
# Multi-stage build for optimized final image
# Runs nginx + PHP-FPM + CQM in single container with supervisord
# ============================================================================
# Stage 1: Builder - Download and prepare OpenEMR + CQM service
# ============================================================================
FROM quay.io/centos/centos:stream10 AS builder
# OpenEMR version — single source of truth for the entire build.
# Override at build time: --build-arg OPENEMR_VERSION=<version>
# Tag format: dots → underscores, prefixed with 'v' (e.g. 8.0.0.2 → v8_0_0_2)
ARG OPENEMR_VERSION=8.0.0.1
# Install all build dependencies in one layer.
# Repo setup per Remi's official EL10 wizard (https://rpms.remirepo.net/wizard/):
# - CRB: dnf config-manager --set-enabled crb
# - EPEL: direct Fedora URL (not the epel-release package)
# - PHP: dnf module switch-to php:remi-8.5 (installs or upgrades to 8.5)
# php-pecl-redis5: required so Composer's platform check sees ext-redis
# (OpenEMR's composer.lock declares it as a platform requirement)
RUN dnf config-manager --set-enabled crb \
&& dnf install -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm \
https://rpms.remirepo.net/enterprise/remi-release-10.rpm \
&& dnf module switch-to php:remi-8.5 -y \
&& dnf install -y \
git curl unzip \
php-cli php-json php-mbstring php-xml php-zip \
php-pecl-redis5 \
&& dnf clean all \
&& rm -rf /var/cache/dnf /var/log/dnf*
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install Node.js 22 + yarn for CQM dependency resolution
RUN curl -fsSL https://rpm.nodesource.com/setup_22.x | bash - \
&& dnf install -y nodejs \
&& dnf clean all \
&& rm -rf /var/cache/dnf \
&& npm install -g yarn --quiet
# Clone and install oe-cqm-service (no public image exists — built from source)
RUN git clone --depth 1 https://github.com/openemr/oe-cqm-service.git /opt/cqm-service \
&& cd /opt/cqm-service \
&& yarn install --production --non-interactive \
&& yarn cache clean
# Clone OpenEMR from GitHub (shallow clone of the version tag)
# Tag format: dots → underscores, prefixed with 'v' (e.g. 8.0.0.1 → v8_0_0_1)
WORKDIR /tmp
RUN GIT_TAG="v$(echo ${OPENEMR_VERSION} | tr '.' '_')" \
&& echo "Cloning OpenEMR tag: ${GIT_TAG}" \
&& git clone https://github.com/openemr/openemr.git --branch "${GIT_TAG}" --depth 1
# InstallerAuto.php is included in OpenEMR source at contrib/util/installScripts/
# It supports no_root_db_access mode which works with pre-created databases
# Install PHP dependencies with Composer
WORKDIR /tmp/openemr
RUN composer install --no-dev --no-interaction --optimize-autoloader
# Note: npm build skipped - OpenEMR handles frontend build on first run
# This matches official OpenEMR Docker behavior and avoids build crashes
# Remove unnecessary files to reduce image size.
# Documentation (~598M) and swagger (~8.8M) are runtime dead weight.
# Keep composer vendor/ — required. Keep contrib/util/installScripts/ — used by entrypoint.
RUN cd /tmp/openemr && \
rm -rf .git .github .travis* tests docker contrib/util/docker \
Documentation swagger \
&& find . -type f -name "*.md" -delete \
&& find . -type f -name "*.jar" -delete \
&& find . -type f -name "*.war" -delete
# Verify InstallerAuto.php exists before proceeding
RUN test -f /tmp/openemr/contrib/util/installScripts/InstallerAuto.php \
&& echo "✓ InstallerAuto.php found" \
|| (echo "ERROR: InstallerAuto.php not found!" && exit 1)
# ============================================================================
# Stage 2: Runtime - Build final container
# ============================================================================
FROM quay.io/centos/centos:stream10
# Re-declare ARG so it's available in this stage
ARG OPENEMR_VERSION=8.0.0.1
LABEL maintainer="Ryan Nix <ryan.nix@gmail.com>" \
description="OpenEMR on CentOS Stream 10 - OpenShift Ready" \
version="${OPENEMR_VERSION}" \
io.k8s.description="OpenEMR Electronic Medical Records System" \
io.openshift.tags="openemr,healthcare,php,medical" \
io.openshift.expose-services="8080:http" \
app.openshift.io/runtime=php
# Environment variables
ENV OPENEMR_VERSION=${OPENEMR_VERSION} \
OPENEMR_WEB_ROOT=/var/www/html/openemr \
PHP_FPM_PORT=9000 \
NGINX_PORT=8080 \
PHP_VERSION=8.5
# Install ALL runtime packages in a single layer — eliminates 6 intermediate layers.
# Repo setup per Remi's official EL10 wizard (https://rpms.remirepo.net/wizard/):
# - CRB: dnf config-manager --set-enabled crb
# - EPEL: direct Fedora URL (not the epel-release package)
# - PHP: dnf module switch-to php:remi-8.5 (installs or upgrades to 8.5)
# php-xmlrpc: removed from PHP 8.0+ core, unavailable on EL10.
# wget: removed — curl is already present throughout.
RUN dnf config-manager --set-enabled crb \
&& dnf install -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm \
https://rpms.remirepo.net/enterprise/remi-release-10.rpm \
&& dnf upgrade -y \
&& dnf module switch-to php:remi-8.5 -y \
&& dnf install -y \
nginx \
# PHP Core
php php-fpm php-cli php-common \
# Database
php-mysqlnd php-pdo \
# OpenEMR Required Extensions
php-gd php-xml php-mbstring php-json php-zip \
php-curl php-opcache php-ldap php-soap php-bcmath php-intl \
# OpenEMR Recommended Extensions
php-imap php-tidy php-sodium \
# Session handling
php-pecl-redis5 \
# Process management
supervisor \
# Utilities
unzip \
&& dnf clean all \
&& rm -rf /var/cache/dnf /var/log/dnf* /tmp/dnf*
# Install Node.js 22 (runtime for CQM service + OpenEMR frontend build)
RUN curl -fsSL https://rpm.nodesource.com/setup_22.x | bash - \
&& dnf install -y nodejs \
&& dnf clean all \
&& rm -rf /var/cache/dnf /var/log/dnf* \
&& node --version && npm --version
# Copy OpenEMR from builder stage
COPY --from=builder /tmp/openemr ${OPENEMR_WEB_ROOT}
# Copy CQM service from builder stage (built from source — no public image available)
COPY --from=builder /opt/cqm-service /opt/cqm-service
# Verify InstallerAuto.php was copied
RUN test -f ${OPENEMR_WEB_ROOT}/contrib/util/installScripts/InstallerAuto.php \
&& echo "✓ InstallerAuto.php present in final image"
# Build OpenEMR frontend assets then purge all npm artifacts
WORKDIR ${OPENEMR_WEB_ROOT}
RUN npm install --legacy-peer-deps \
&& npm run build \
&& rm -rf node_modules \
&& npm cache clean --force \
&& echo "✓ Frontend assets built successfully"
# Preserve default site files for PVC-mounted deployments.
# When a PVC is mounted at sites/default/, it overlays the image layer and
# hides files like config.php. The entrypoint restores any missing files
# from this backup directory on first start.
RUN cp -a ${OPENEMR_WEB_ROOT}/sites/default ${OPENEMR_WEB_ROOT}/sites/default.dist
# ============================================================================
# PHP Configuration
# ============================================================================
# Create custom PHP configuration for OpenEMR
RUN cat > /etc/php.d/99-openemr.ini <<'EOF'
; OpenEMR PHP Configuration
; PHP ini files require semicolons for comments (# is rejected in PHP 8.x)
; File Upload Settings (for medical documents, images, lab results)
upload_max_filesize = 128M
post_max_size = 128M
max_input_vars = 3000
; Memory and Execution
memory_limit = 512M
max_execution_time = 300
max_input_time = 300
; Session Configuration (Redis-backed for multi-pod deployments)
session.save_handler = redis
session.save_path = "tcp://redis:6379"
session.gc_maxlifetime = 7200
session.cookie_httponly = 1
session.cookie_secure = 1
session.use_strict_mode = 1
; Error Handling (Production)
display_errors = Off
display_startup_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
log_errors = On
error_log = /dev/stderr
; Security
expose_php = Off
allow_url_fopen = On
allow_url_include = Off
; Date/Time
date.timezone = UTC
; OPcache (Performance)
opcache.enable = 1
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 10000
opcache.validate_timestamps = 0
opcache.revalidate_freq = 0
opcache.save_comments = 1
EOF
# ============================================================================
# PHP-FPM Configuration
# ============================================================================
RUN cat > /etc/php-fpm.d/www.conf <<'EOF'
[www]
; Unix socket or TCP (we use TCP for easier container networking)
listen = 127.0.0.1:9000
; Process ownership (OpenShift uses arbitrary UIDs, group 0)
listen.owner = nginx
listen.group = root
listen.mode = 0660
; Process manager configuration
user = nginx
group = root
; Dynamic process management
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.process_idle_timeout = 10s
pm.max_requests = 500
; Logging
access.log = /dev/stdout
catch_workers_output = yes
decorate_workers_output = no
; Health check endpoint
pm.status_path = /fpm-status
ping.path = /fpm-ping
ping.response = pong
; Session configuration (Redis)
php_value[session.save_handler] = redis
php_value[session.save_path] = "tcp://redis:6379"
php_value[session.gc_maxlifetime] = 7200
; Security
php_admin_flag[log_errors] = on
php_admin_value[error_log] = /dev/stderr
EOF
# ============================================================================
# nginx Configuration
# ============================================================================
RUN cat > /etc/nginx/nginx.conf <<'EOF'
# nginx configuration for OpenEMR
user nginx;
worker_processes auto;
error_log /dev/stderr warn;
pid /run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
# Performance
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# Gzip Compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript
application/xml application/xml+rss text/javascript application/x-font-ttf
font/opentype image/svg+xml;
server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
root /var/www/html/openemr;
index index.php index.html;
# Health check endpoints
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
location /fpm-status {
access_log off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# Zend modules (Manage Modules, Care Coordination, etc.)
location /interface/modules/zend_modules/public/ {
try_files $uri $uri/ /interface/modules/zend_modules/public/index.php?$query_string;
}
# OpenEMR main application
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP processing
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
# Increased timeouts for long-running reports
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
}
# Deny access to sensitive files
location ~ /\.ht {
deny all;
}
location ~ /\.git {
deny all;
}
# OpenEMR specific denies
location ~ ^/sites/.*/documents {
deny all;
}
location ~ ^/sites/default/sqlconf.php {
deny all;
}
# Allow larger uploads for medical documents
client_max_body_size 128M;
client_body_buffer_size 128k;
}
}
EOF
# ============================================================================
# Supervisor Configuration (manages nginx + PHP-FPM)
# ============================================================================
RUN mkdir -p /var/log/supervisor
RUN cat > /etc/supervisord.conf <<'EOF'
[supervisord]
nodaemon=true
logfile=/dev/stdout
logfile_maxbytes=0
loglevel=info
pidfile=/run/supervisord.pid
[supervisorctl]
serverurl=unix:///run/supervisor.sock
[unix_http_server]
file=/run/supervisor.sock
chmod=0700
[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
[program:php-fpm]
command=/usr/sbin/php-fpm --nodaemonize --fpm-config /etc/php-fpm.conf
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_events_enabled=true
stderr_events_enabled=true
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
autostart=true
autorestart=true
priority=10
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_events_enabled=true
stderr_events_enabled=true
[program:cqm]
command=node /opt/cqm-service/server.js
autostart=true
autorestart=true
priority=20
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_events_enabled=true
stderr_events_enabled=true
EOF
# ============================================================================
# OpenShift Permissions and Security
# ============================================================================
# Create directories, set OpenShift-compatible permissions (arbitrary UID, GID 0),
# and make required OpenEMR paths writable — all in one layer
RUN mkdir -p \
/var/log/php-fpm /var/log/nginx /var/lib/nginx /var/lib/php/session \
/run/php-fpm /tmp/sessions \
${OPENEMR_WEB_ROOT}/sites/default/documents \
${OPENEMR_WEB_ROOT}/sites/default/documents/logs_and_misc/methods \
&& chmod -R 775 /tmp/sessions \
&& chgrp -R 0 \
${OPENEMR_WEB_ROOT} /var/log/nginx /var/log/php-fpm /var/lib/nginx \
/var/lib/php /run /tmp/sessions /etc/nginx /etc/php-fpm.d /opt/cqm-service \
&& chmod -R g=u \
${OPENEMR_WEB_ROOT} /var/log/nginx /var/log/php-fpm /var/lib/nginx \
/var/lib/php /run /tmp/sessions /etc/nginx /etc/php-fpm.d /opt/cqm-service \
&& chmod -R 770 \
${OPENEMR_WEB_ROOT}/sites/default/documents \
${OPENEMR_WEB_ROOT}/sites \
${OPENEMR_WEB_ROOT}/interface/modules/zend_modules/config \
${OPENEMR_WEB_ROOT}/sites/default/documents/logs_and_misc
# Create entrypoint script
RUN cat > /entrypoint.sh <<'ENTRYPOINT'
#!/bin/bash
set -e
echo "=========================================="
echo "Starting OpenEMR Container"
echo "=========================================="
echo "OpenEMR Version: ${OPENEMR_VERSION}"
echo "PHP Version: $(php -v | head -n 1)"
echo "Web Root: ${OPENEMR_WEB_ROOT}"
echo ""
echo "Configuration:"
echo " - PHP-FPM: 127.0.0.1:${PHP_FPM_PORT}"
echo " - nginx: 0.0.0.0:${NGINX_PORT}"
echo " - UID: $(id -u), GID: $(id -g)"
echo "=========================================="
# Ensure permissions are correct (OpenShift may assign random UID)
echo "Setting permissions for UID $(id -u)..."
chmod -R g=u ${OPENEMR_WEB_ROOT}/sites 2>/dev/null || true
chmod -R g=u /tmp/sessions 2>/dev/null || true
chmod -R g=u /var/lib/php/session 2>/dev/null || true
# Create crypto keys directory (may be on mounted PVC, so create at runtime)
mkdir -p ${OPENEMR_WEB_ROOT}/sites/default/documents/logs_and_misc/methods 2>/dev/null || true
chmod -R 770 ${OPENEMR_WEB_ROOT}/sites/default/documents/logs_and_misc 2>/dev/null || true
# Restore default site files that are hidden by the PVC mount.
# The PVC at sites/default/ starts empty, so files like config.php that
# shipped with the image are invisible. Copy them from the backup.
if [ -d "${OPENEMR_WEB_ROOT}/sites/default.dist" ]; then
echo "Checking for missing default site files..."
cd ${OPENEMR_WEB_ROOT}/sites/default.dist
for f in *; do
if [ ! -e "${OPENEMR_WEB_ROOT}/sites/default/$f" ]; then
cp -a "$f" "${OPENEMR_WEB_ROOT}/sites/default/$f" 2>/dev/null \
&& echo " Restored: $f"
fi
done
cd ${OPENEMR_WEB_ROOT}
fi
# Test Redis connectivity and fall back to file sessions if needed
echo "Testing session storage..."
if php -r "try { \$r = new Redis(); \$r->connect('redis', 6379, 2); echo 'OK'; } catch (Exception \$e) { echo 'FAIL'; exit(1); }" 2>/dev/null; then
echo "✓ Redis session storage available"
else
echo "⚠ Redis unavailable, falling back to file-based sessions"
# Update PHP-FPM to use file sessions
sed -i 's|php_value\[session.save_handler\] = redis|php_value\[session.save_handler\] = files|' /etc/php-fpm.d/www.conf
sed -i 's|php_value\[session.save_path\].*|php_value\[session.save_path\] = "/var/lib/php/session"|' /etc/php-fpm.d/www.conf
# Also update the PHP ini so CLI scripts use file sessions too
sed -i 's|session.save_handler = redis|session.save_handler = files|' /etc/php.d/99-openemr.ini
sed -i 's|session.save_path = "tcp://redis:6379"|session.save_path = "/var/lib/php/session"|' /etc/php.d/99-openemr.ini
fi
# Check if OpenEMR is already configured (look for $config = 1 in sqlconf.php)
SQLCONF="${OPENEMR_WEB_ROOT}/sites/default/sqlconf.php"
INSTALLER="${OPENEMR_WEB_ROOT}/contrib/util/installScripts/InstallerAuto.php"
# Debug: Show what files exist
echo "Checking configuration status..."
echo " - sqlconf.php exists: $(test -f "$SQLCONF" && echo 'yes' || echo 'no')"
echo " - InstallerAuto.php exists: $(test -f "$INSTALLER" && echo 'yes' || echo 'no')"
# Check if already configured ($config = 1 means configured)
ALREADY_CONFIGURED=false
if [ -f "$SQLCONF" ] && grep -q '\$config = 1' "$SQLCONF" 2>/dev/null; then
ALREADY_CONFIGURED=true
echo " - Configuration status: CONFIGURED"
else
echo " - Configuration status: NOT CONFIGURED"
fi
# Auto-configuration on first run
if [ "$ALREADY_CONFIGURED" = false ] && [ -f "$INSTALLER" ]; then
echo "=========================================="
echo "Running OpenEMR Auto-Configuration"
echo "=========================================="
# Set defaults if not provided
export MYSQL_HOST=${MYSQL_HOST:-mariadb}
export MYSQL_PORT=${MYSQL_PORT:-3306}
export MYSQL_DATABASE=${MYSQL_DATABASE:-openemr}
export MYSQL_USER=${MYSQL_USER:-openemr}
export MYSQL_PASS=${MYSQL_PASS:-openemr}
export OE_USER=${OE_USER:-admin}
export OE_PASS=${OE_PASS:-pass}
echo "Database connection settings:"
echo " - Host: ${MYSQL_HOST}"
echo " - Port: ${MYSQL_PORT}"
echo " - Database: ${MYSQL_DATABASE}"
echo " - User: ${MYSQL_USER}"
echo " - Admin User: ${OE_USER}"
# Wait for database to be ready
echo "Waiting for database at ${MYSQL_HOST}..."
counter=0
while ! php -r "mysqli_connect('${MYSQL_HOST}', '${MYSQL_USER}', '${MYSQL_PASS}', '${MYSQL_DATABASE}') or exit(1);" 2>/dev/null; do
sleep 2
counter=$((counter+1))
echo " Attempt $counter: waiting for database..."
if [ $counter -gt 30 ]; then
echo "ERROR: Database not ready after 60 seconds"
echo "Check that MariaDB pod is running and credentials are correct"
echo "Falling back to manual setup..."
break
fi
done
if [ $counter -le 30 ]; then
echo "✓ Database connection successful"
# Run InstallerAuto.php with no_root_db_access mode
# This uses the pre-created database and user from MariaDB container
echo "Running InstallerAuto.php (no_root_db_access mode)..."
cd ${OPENEMR_WEB_ROOT}
# Enable the installer script
export OPENEMR_ENABLE_INSTALLER_AUTO=1
php -f contrib/util/installScripts/InstallerAuto.php \
no_root_db_access=1 \
server="${MYSQL_HOST}" \
port="${MYSQL_PORT}" \
login="${MYSQL_USER}" \
pass="${MYSQL_PASS}" \
dbname="${MYSQL_DATABASE}" \
iuser="${OE_USER}" \
iuserpass="${OE_PASS}" \
iuname="Administrator" \
2>&1 \
&& echo "✓ Auto-configuration completed successfully!" \
|| echo "⚠ Auto-configuration had issues, check logs above"
# Verify configuration was successful
if grep -q '\$config = 1' "$SQLCONF" 2>/dev/null; then
echo "✓ OpenEMR configured and ready!"
else
echo "⚠ Configuration may not be complete - manual setup may be required"
fi
echo "=========================================="
fi
elif [ "$ALREADY_CONFIGURED" = true ]; then
echo "✓ OpenEMR already configured, skipping auto-configuration"
else
echo "⚠ InstallerAuto.php not found - manual setup required"
echo " Visit the web interface to complete setup"
fi
# Start supervisor (manages nginx + PHP-FPM)
echo "Starting services via supervisord..."
exec /usr/bin/supervisord -c /etc/supervisord.conf
ENTRYPOINT
RUN chmod +x /entrypoint.sh && chgrp 0 /entrypoint.sh && chmod g=u /entrypoint.sh
# ============================================================================
# Health Checks and Metadata
# ============================================================================
# Expose nginx port (8080 for non-root)
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Switch to non-root user (OpenShift will override with arbitrary UID)
USER 1001
# Working directory
WORKDIR ${OPENEMR_WEB_ROOT}
# Start supervisor via entrypoint
ENTRYPOINT ["/entrypoint.sh"]