CNP OpenEMR Infrastructure Plan
Overview
This document describes the target infrastructure architecture for CNP’s OpenEMR-based platform, including the Food RX NFP initiative.
The primary goals are:
- HIPAA-capable deployment architecture
- Minimal operational complexity
- Low monthly operating cost
- Portable and cloud-agnostic design
- Infrastructure reproducibility across environments
- Avoidance of vendor lock-in
- Support for approximately 5 concurrent OpenEMR users
- Ability to self-host in AWS, another cloud provider, or on-premises with minimal changes
Design Principles
Keep Everything in a Box
The architecture intentionally favors simplicity over horizontal scalability.
Rather than adopting a traditional enterprise AWS architecture with multiple managed services, the platform is deployed as a self-contained appliance consisting of:
- One virtual machine
- One Docker Compose stack
- Local persistent storage
- Encrypted offsite backups
This approach minimizes:
- Infrastructure complexity
- Monthly costs
- Operational overhead
- Vendor dependencies
Infrastructure as Code
All infrastructure must be reproducible.
Infrastructure definitions should be maintained using:
- OpenTofu (preferred) or Terraform
- Docker Compose
- Shell bootstrap scripts
- Git-managed configuration
No manual server configuration should be required after provisioning.
Cloud Portability
The deployment architecture should be portable across:
- AWS
- Azure
- Google Cloud
- Hetzner
- DigitalOcean
- Bare metal
- Local development environments
The application stack should not depend on AWS-specific runtime services.
Production Architecture
Internet
|
HTTPS 443
|
Reverse Proxy
(Caddy/Nginx)
|
OpenEMR 8
|
MariaDB
|
Encrypted EBS Volume
|
Encrypted Restic Backups
|
S3
AWS Deployment
Compute
| Option | vCPU | Memory |
|---|---|---|
| t4g.medium | 2 | 4 GB |
| t4g.large | 2 | 8 GB |
Recommendation
Production should start with:
t4g.large
Reasons:
- More comfortable memory allocation for OpenEMR
- Better MariaDB performance
- More headroom for future Food RX modules
- Reduced risk of memory pressure during upgrades
Storage
Primary Storage
Encrypted EBS volume:
- gp3
- 100 GB initial allocation
- Expandable without downtime
Stores:
- OpenEMR application data
- Uploaded documents
- Configuration
- Database files
Backup Storage
Encrypted S3 bucket:
- Versioning enabled
- Lifecycle retention policies
- Restricted IAM access
- Backup-only usage
Container Architecture
Docker Compose
Production consists of:
services:
proxy:
caddy
openemr:
openemr
mariadb:
mariadbNo orchestration platform is required.
Specifically avoided:
- ECS
- EKS
- Kubernetes
- Fargate
Why Separate MariaDB
Although OpenEMR and MariaDB could technically run inside a single container, a dedicated database container provides:
- Cleaner upgrades
- Better backups
- Easier restores
- Better troubleshooting
- Reduced risk during application updates
The architecture remains simple while improving maintainability.
Backup Strategy
Daily Backups
Nightly backup process:
- Database dump
- OpenEMR file backup
- Encryption
- Upload to S3
Tools:
- Restic
- Age (optional)
Backup Retention
| Backup Type | Retention |
|---|---|
| Daily | 30 days |
| Weekly | 12 weeks |
| Monthly | 12 months |
Disaster Recovery
Recovery requires:
- One Linux server
- Docker
- Docker Compose
- Backup credentials
A complete environment can be rebuilt from source control and backups.
HIPAA Considerations
Administrative Requirements
Before production use:
- AWS Business Associate Agreement (BAA)
- Vendor BAAs for any third-party services
- Security policies
- Incident response process
- Backup validation procedures
Technical Controls
Encryption
- EBS encryption
- S3 encryption
- TLS 1.2+
- Encrypted backups
Access Control
- MFA for administrators
- Strong passwords
- Principle of least privilege
- Limited SSH access
Auditing
- OpenEMR audit logging enabled
- System logs retained
- Backup verification logs retained
Network Security
- HTTPS only
- Security group restrictions
- Host firewall enabled
- Fail2ban or equivalent
Environment Strategy
Local Development
Development environments run locally.
Requirements:
Docker
Docker Compose
OpenEMR
MariaDB
No cloud resources required.
Testing
Testing environments should mirror production.
Differences:
- Local storage
- Test data only
- Non-production credentials
Production
Production uses the same Docker image and Compose definitions as development.
This ensures:
- Environment consistency
- Easier troubleshooting
- Predictable deployments
ARM Architecture
Target Platform
Preferred architecture:
linux/arm64
Reasons:
- Lower AWS cost
- Better price/performance
- AWS Graviton support
- Future Raspberry Pi compatibility
Validation Requirement
Before production deployment, verify all images support:
linux/arm64
Including:
- OpenEMR
- MariaDB
- Reverse proxy
- Backup tooling
If any critical component lacks ARM support, production should temporarily use x86_64.
OpenEMR Customization Strategy
Guiding Principle
Avoid a deep fork of OpenEMR whenever possible.
Repository Structure
cnp-openemr/
├── docker/
├── modules/
│ └── foodrx/
├── config/
├── patches/
├── infra/
│ └── opentofu/
├── scripts/
└── docs/
Upstream Strategy
Maintain:
- An upstream OpenEMR remote
- A CNP fork
- Modular Food RX functionality
Preferred workflow:
OpenEMR Upstream
|
v
CNP Fork
|
v
Food RX Modules
Why Not a Deep Fork
A large fork increases:
- Upgrade difficulty
- Security maintenance burden
- Compliance risk
- Long-term operating costs
The goal is to remain close enough to upstream that security and platform updates can be adopted with minimal effort.
Estimated AWS Cost
Always-On Deployment
| Resource | Monthly Cost |
|---|---|
| t4g.medium | ~$25 |
| EBS 100 GB | ~$8 |
| S3 Backups | ~$2-3 |
| Public IPv4 | ~$4 |
| Total | ~$39/month |
Recommended Production
| Resource | Monthly Cost |
|---|---|
| t4g.large | ~$49 |
| EBS 100 GB | ~$8 |
| S3 Backups | ~$2-3 |
| Public IPv4 | ~$4 |
| Total | ~$63/month |
Night Shutdown Strategy
If the server is stopped approximately 12 hours each day:
| Configuration | Monthly Cost |
|---|---|
| t4g.medium | ~$26 |
| t4g.large | ~$39 |
Storage costs remain unchanged.
Future Evolution
The architecture is intentionally optimized for simplicity.
Future scaling options include:
- Dedicated database server
- Managed database service
- Load-balanced application nodes
- Object storage for documents
- Multi-region disaster recovery
These enhancements should only be adopted when justified by user growth or operational requirements.
Until then, a single-server architecture remains the preferred deployment model.
Conclusion
The recommended CNP OpenEMR deployment is:
- One AWS EC2 instance
- Docker Compose
- OpenEMR 8
- MariaDB
- Encrypted EBS storage
- Encrypted S3 backups
- ARM64-first deployment strategy
- Upstream-tracking OpenEMR fork
- Modular Food RX customization approach
This architecture provides a HIPAA-capable, low-cost, highly portable platform suitable for small healthcare and nonprofit deployments while preserving long-term flexibility and minimizing vendor lock-in.
← Back to portal