|
1 | | -# SuiteCRM |
2 | | -SuiteCRM with docker-compose |
| 1 | +# SuiteCRM Docker Development Environment |
3 | 2 |
|
4 | | -## Setup |
| 3 | +Docker-based development environment for SuiteCRM 8.x with PHP 8.3, Apache, and MySQL. |
5 | 4 |
|
6 | | -clone this repository and run: |
| 5 | +## Quick Start |
7 | 6 |
|
| 7 | +### Option 1: Automated Installation (Recommended) |
| 8 | + |
| 9 | +1. Clone this repository: |
| 10 | +```bash |
| 11 | +git clone <repository-url> |
| 12 | +cd suitecrm-docker |
| 13 | +``` |
| 14 | + |
| 15 | +2. Run the installation script: |
| 16 | +```bash |
| 17 | +./install.sh |
| 18 | +``` |
| 19 | + |
| 20 | +The script will start the containers, verify bug fixes, and guide you through the installation. |
| 21 | + |
| 22 | +### Option 2: Manual Installation |
| 23 | + |
| 24 | +1. Clone this repository: |
| 25 | +```bash |
| 26 | +git clone <repository-url> |
| 27 | +cd suitecrm-docker |
8 | 28 | ``` |
| 29 | + |
| 30 | +2. Start the containers: |
| 31 | +```bash |
9 | 32 | docker compose up -d |
10 | 33 | ``` |
| 34 | + |
| 35 | + **Note**: The entrypoint script automatically fixes known SuiteCRM 8.4.0 bugs on startup. |
| 36 | + |
| 37 | +3. Complete the installation: |
| 38 | +```bash |
| 39 | +docker compose exec php bin/console suitecrm:app:install \ |
| 40 | + -U root \ |
| 41 | + -P root \ |
| 42 | + -H mysql \ |
| 43 | + -Z 3306 \ |
| 44 | + -N root \ |
| 45 | + -u admin \ |
| 46 | + -p admin \ |
| 47 | + -S localhost \ |
| 48 | + -d no \ |
| 49 | + -W true |
| 50 | +``` |
| 51 | + |
| 52 | +4. Access SuiteCRM at http://localhost |
| 53 | + - **Username**: admin |
| 54 | + - **Password**: admin |
| 55 | + |
| 56 | +## Known Issues |
| 57 | + |
| 58 | +### SuiteCRM 8.4.0 Bugs |
| 59 | + |
| 60 | +SuiteCRM 8.4.0 contains multiple bugs when running on PHP 8.3: |
| 61 | + |
| 62 | +**Bug #1: Duplicate Static Variable in AOW_WorkFlow** |
| 63 | +- **File**: `public/legacy/modules/AOW_WorkFlow/aow_utils.php` |
| 64 | +- **Issue**: Static variable `$sfh` is declared twice (lines 438 and 644) |
| 65 | +- **Error**: `Fatal Compile Error: Duplicate declaration of static variable $sfh` |
| 66 | +- **Symptoms**: Database failure error on initial load |
| 67 | +- **Fix**: Remove line 644 |
| 68 | + |
| 69 | +**Bug #2: Duplicate Static Variable in InlineEditing** |
| 70 | +- **File**: `public/legacy/include/InlineEditing/InlineEditing.php` |
| 71 | +- **Issue**: Static variable `$sfh` is declared twice (lines 146 and 294) |
| 72 | +- **Error**: `Fatal Compile Error: Duplicate declaration of static variable $sfh` |
| 73 | +- **Symptoms**: "Error while fetching data" when trying to login or access GraphQL API |
| 74 | +- **Fix**: Remove line 294 |
| 75 | + |
| 76 | +**Bug #3: Incorrect RewriteBase in .htaccess** |
| 77 | +- **File**: `public/legacy/.htaccess` |
| 78 | +- **Issue**: RewriteBase is set to `localhostlegacy/` instead of `/legacy/` |
| 79 | +- **Error**: `RewriteBase: argument is not a valid URL` |
| 80 | +- **Symptoms**: 500 Internal Server Error when accessing legacy pages |
| 81 | +- **Fix**: Correct the RewriteBase path |
| 82 | + |
| 83 | +All three fixes are **automatically applied** by the entrypoint script when the container starts. The fixes are idempotent - they only run if the bugs are detected and won't break already-fixed installations. |
| 84 | + |
| 85 | +### Manual Bug Fixes (For Existing Installations) |
| 86 | + |
| 87 | +If you have an existing SuiteCRM installation that wasn't started with the updated entrypoint, you can manually apply the fixes: |
| 88 | + |
| 89 | +```bash |
| 90 | +# Fix bug #1: Duplicate static variable in AOW_WorkFlow |
| 91 | +docker compose exec php sed -i '644d' public/legacy/modules/AOW_WorkFlow/aow_utils.php |
| 92 | + |
| 93 | +# Fix bug #2: Duplicate static variable in InlineEditing |
| 94 | +docker compose exec php sed -i '294d' public/legacy/include/InlineEditing/InlineEditing.php |
| 95 | + |
| 96 | +# Fix bug #3: Incorrect RewriteBase in .htaccess |
| 97 | +docker compose exec php sed -i 's|RewriteBase localhostlegacy/|RewriteBase /legacy/|' public/legacy/.htaccess |
| 98 | + |
| 99 | +# Clear cache and restart |
| 100 | +docker compose exec php bash -c "rm -rf cache/prod/* public/legacy/cache/*" |
| 101 | +docker compose restart php |
| 102 | +``` |
| 103 | + |
| 104 | +### Installation Lock |
| 105 | + |
| 106 | +If the installation fails or is interrupted, you may need to unlock the installer: |
| 107 | +```bash |
| 108 | +docker compose exec php sed -i "s/'installer_locked' => true/'installer_locked' => false/" public/legacy/config.php |
| 109 | +``` |
| 110 | + |
| 111 | +Then retry the installation command from step 4. |
| 112 | + |
| 113 | +## Manual Installation via Console |
| 114 | + |
| 115 | +To manually install or reinstall SuiteCRM: |
| 116 | + |
| 117 | +```bash |
| 118 | +docker compose exec php bin/console suitecrm:app:install [options] |
| 119 | +``` |
| 120 | + |
| 121 | +### Installation Options |
| 122 | + |
| 123 | +- `-U, --db_username`: Database username (default: root) |
| 124 | +- `-P, --db_password`: Database password (default: root) |
| 125 | +- `-H, --db_host`: Database host (default: mysql) |
| 126 | +- `-Z, --db_port`: Database port (default: 3306) |
| 127 | +- `-N, --db_name`: Database name (default: root) |
| 128 | +- `-u, --site_username`: Admin username |
| 129 | +- `-p, --site_password`: Admin password |
| 130 | +- `-S, --site_host`: Site host (default: localhost) |
| 131 | +- `-d, --demoData`: Install demo data (yes/no) |
| 132 | +- `-W, --sys_check_option`: Ignore system check warnings (true/false) |
| 133 | + |
| 134 | +### Example Installation Command |
| 135 | + |
| 136 | +```bash |
| 137 | +docker compose exec php bin/console suitecrm:app:install \ |
| 138 | + --db_username=root \ |
| 139 | + --db_password=root \ |
| 140 | + --db_host=mysql \ |
| 141 | + --db_port=3306 \ |
| 142 | + --db_name=root \ |
| 143 | + --site_username=admin \ |
| 144 | + --site_password=MySecurePassword123 \ |
| 145 | + --site_host=localhost \ |
| 146 | + --demoData=no \ |
| 147 | + --sys_check_option=true |
| 148 | +``` |
| 149 | + |
| 150 | +## Architecture |
| 151 | + |
| 152 | +### Services |
| 153 | + |
| 154 | +- **php**: PHP 8.3 with Apache and required SuiteCRM extensions |
| 155 | + - Port: 80 |
| 156 | + - Volume: `./volumes/suitecrm` → `/var/www/html` |
| 157 | + - Xdebug pre-configured (disabled by default) |
| 158 | + |
| 159 | +- **mysql**: MySQL database |
| 160 | + - Port: 3306 |
| 161 | + - Root password: root |
| 162 | + - Database: root |
| 163 | + - Volume: `./volumes/mysql/data` → `/var/lib/mysql` |
| 164 | + |
| 165 | +### Environment Variables |
| 166 | + |
| 167 | +Create a `.env` file or set in `docker-compose.yml`: |
| 168 | + |
| 169 | +- `VERSION_SUITECRM`: SuiteCRM version to download (default: v8.8.0) |
| 170 | +- `XDEBUG_CONFIG`: Xdebug configuration |
| 171 | +- `TZ`: Timezone (default: America/Sao_Paulo) |
| 172 | + |
| 173 | +## Common Commands |
| 174 | + |
| 175 | +### Container Management |
| 176 | + |
| 177 | +```bash |
| 178 | +# Start services |
| 179 | +docker compose up -d |
| 180 | + |
| 181 | +# Stop services |
| 182 | +docker compose down |
| 183 | + |
| 184 | +# View logs |
| 185 | +docker compose logs -f php |
| 186 | + |
| 187 | +# Rebuild PHP container |
| 188 | +docker compose build php |
| 189 | + |
| 190 | +# Access PHP container shell |
| 191 | +docker compose exec php bash |
| 192 | +``` |
| 193 | + |
| 194 | +### Database Access |
| 195 | + |
| 196 | +```bash |
| 197 | +# MySQL CLI |
| 198 | +docker compose exec mysql mysql -uroot -proot root |
| 199 | + |
| 200 | +# External connection |
| 201 | +mysql -h localhost -P 3306 -u root -proot root |
| 202 | +``` |
| 203 | + |
| 204 | +### SuiteCRM Console |
| 205 | + |
| 206 | +```bash |
| 207 | +# Run console commands |
| 208 | +docker compose exec php bin/console <command> |
| 209 | + |
| 210 | +# Clear cache |
| 211 | +docker compose exec php bin/console cache:clear |
| 212 | + |
| 213 | +# List all commands |
| 214 | +docker compose exec php bin/console list |
| 215 | +``` |
| 216 | + |
| 217 | +### Cache Management |
| 218 | + |
| 219 | +```bash |
| 220 | +# Clear Symfony cache |
| 221 | +docker compose exec php bash -c "rm -rf cache/prod/*" |
| 222 | + |
| 223 | +# Clear legacy SuiteCRM cache |
| 224 | +docker compose exec php bash -c "rm -rf public/legacy/cache/*" |
| 225 | + |
| 226 | +# Restart PHP container |
| 227 | +docker compose restart php |
| 228 | +``` |
| 229 | + |
| 230 | +## Debugging |
| 231 | + |
| 232 | +### Enable Xdebug |
| 233 | + |
| 234 | +1. Edit `.docker/php/config/php.ini`: |
| 235 | +```ini |
| 236 | +xdebug.mode=debug |
| 237 | +``` |
| 238 | + |
| 239 | +2. Rebuild and restart: |
| 240 | +```bash |
| 241 | +docker compose build php |
| 242 | +docker compose up -d |
| 243 | +``` |
| 244 | + |
| 245 | +3. Configure your IDE to listen on port 9003 |
| 246 | + |
| 247 | +### View Logs |
| 248 | + |
| 249 | +```bash |
| 250 | +# Application logs |
| 251 | +docker compose exec php cat logs/prod/prod.log |
| 252 | + |
| 253 | +# Installation logs |
| 254 | +docker compose exec php cat logs/install.log |
| 255 | + |
| 256 | +# Apache logs |
| 257 | +docker compose logs php |
| 258 | +``` |
| 259 | + |
| 260 | +## Troubleshooting |
| 261 | + |
| 262 | +### Database Failure Error |
| 263 | + |
| 264 | +If you see "Database failure. Please refer to suitecrm.log": |
| 265 | + |
| 266 | +1. Check for the duplicate static variable bug (see Known Issues) |
| 267 | +2. Verify database connection: |
| 268 | +```bash |
| 269 | +docker compose exec php php -r "new PDO('mysql:host=mysql;port=3306;dbname=root', 'root', 'root'); echo 'OK';" |
| 270 | +``` |
| 271 | +3. Clear cache and restart |
| 272 | + |
| 273 | +### Reset Installation |
| 274 | + |
| 275 | +To completely reset and reinstall: |
| 276 | + |
| 277 | +```bash |
| 278 | +# Stop containers and remove volumes |
| 279 | +docker compose down -v |
| 280 | + |
| 281 | +# Remove SuiteCRM files |
| 282 | +sudo rm -rf volumes/ |
| 283 | + |
| 284 | +# Start fresh |
| 285 | +docker compose up -d |
| 286 | + |
| 287 | +# Apply bug fix and install |
| 288 | +# (Follow steps 3-4 from Quick Start) |
| 289 | +``` |
| 290 | + |
| 291 | +## CI/CD |
| 292 | + |
| 293 | +GitHub Actions automatically builds and publishes the Docker image to `ghcr.io` on: |
| 294 | +- Pushes to main/master |
| 295 | +- Tag creation (v*) |
| 296 | +- Pull requests |
| 297 | + |
| 298 | +## License |
| 299 | + |
| 300 | +SuiteCRM is licensed under AGPLv3. See LICENSE.txt for details. |
0 commit comments