|
| 1 | +# Developer Guide |
| 2 | + |
| 3 | +This guide describes how to set up a local development environment for the froxlor container and how to mount |
| 4 | +additional packages during development. |
| 5 | + |
| 6 | +## Directory Structure |
| 7 | + |
| 8 | +A typical local development setup may look like this: |
| 9 | + |
| 10 | +```text |
| 11 | +. |
| 12 | +├── container |
| 13 | +├── froxlor |
| 14 | +├── framework |
| 15 | +└── example-package |
| 16 | +``` |
| 17 | + |
| 18 | +In this layout: |
| 19 | + |
| 20 | +* `container` contains the Docker setup. |
| 21 | +* `froxlor` contains the froxlor application. |
| 22 | +* `framework` contains the froxlor framework package. |
| 23 | +* `example-package` contains an additional package under development. |
| 24 | + |
| 25 | +## Docker Compose |
| 26 | + |
| 27 | +The following `docker-compose.yml` example can be used for local development. |
| 28 | + |
| 29 | +```yaml |
| 30 | +services: |
| 31 | + froxlor: |
| 32 | + image: hub.froxlor.io/froxlor/froxlor:latest |
| 33 | + build: . |
| 34 | + restart: unless-stopped |
| 35 | + privileged: true |
| 36 | + pid: "host" |
| 37 | + depends_on: |
| 38 | + db: |
| 39 | + condition: service_healthy |
| 40 | + redis: |
| 41 | + condition: service_healthy |
| 42 | + adminer: |
| 43 | + condition: service_started |
| 44 | + ports: |
| 45 | + - "8000:8000" |
| 46 | + # Use the environment and/or the env_file as you like |
| 47 | + environment: |
| 48 | + FROXLOR_DB_CONNECTION: mariadb |
| 49 | + FROXLOR_DB_HOST: db |
| 50 | + FROXLOR_DB_PORT: 3306 |
| 51 | + FROXLOR_DB_DATABASE: froxlor |
| 52 | + FROXLOR_DB_USERNAME: froxlor |
| 53 | + FROXLOR_DB_PASSWORD: CHANGEM3 |
| 54 | + env_file: |
| 55 | + - path: ../froxlor/.env |
| 56 | + required: false |
| 57 | + volumes: |
| 58 | + - ../froxlor:/var/www/html/froxlor |
| 59 | + - ../framework:/opt/froxlor/packages/framework |
| 60 | + db: |
| 61 | + image: mariadb:latest |
| 62 | + restart: unless-stopped |
| 63 | + environment: |
| 64 | + MARIADB_ROOT_PASSWORD: CHANGEM3 |
| 65 | + MARIADB_DATABASE: froxlor |
| 66 | + MARIADB_USER: froxlor |
| 67 | + MARIADB_PASSWORD: CHANGEM3 |
| 68 | + healthcheck: |
| 69 | + test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] |
| 70 | + start_period: 30s |
| 71 | + interval: 10s |
| 72 | + timeout: 5s |
| 73 | + retries: 5 |
| 74 | + volumes: |
| 75 | + - database:/var/lib/mysql |
| 76 | + redis: |
| 77 | + image: redis:latest |
| 78 | + restart: unless-stopped |
| 79 | + healthcheck: |
| 80 | + test: [ "CMD", "redis-cli", "ping" ] |
| 81 | + start_period: 5s |
| 82 | + interval: 10s |
| 83 | + timeout: 5s |
| 84 | + retries: 5 |
| 85 | + volumes: |
| 86 | + - redis:/data |
| 87 | + adminer: |
| 88 | + image: adminer:latest |
| 89 | + restart: unless-stopped |
| 90 | + ports: |
| 91 | + - "8080:8080" |
| 92 | + depends_on: |
| 93 | + - db |
| 94 | +volumes: |
| 95 | + database: |
| 96 | + redis: |
| 97 | +``` |
| 98 | +
|
| 99 | +> [!WARNING] |
| 100 | +> This development setup runs the froxlor container in privileged mode and uses the host PID namespace. Use this |
| 101 | +> configuration only in trusted local development environments. |
| 102 | +
|
| 103 | +## Start the Development Environment |
| 104 | +
|
| 105 | +Start all services with: |
| 106 | +
|
| 107 | +```bash |
| 108 | +docker compose up -d |
| 109 | +``` |
| 110 | + |
| 111 | +After the services have started, open froxlor in your browser: |
| 112 | + |
| 113 | +```text |
| 114 | +http://localhost:8000 |
| 115 | +``` |
| 116 | + |
| 117 | +Adminer is available at: |
| 118 | + |
| 119 | +```text |
| 120 | +http://localhost:8080 |
| 121 | +``` |
| 122 | + |
| 123 | +## Package Development |
| 124 | + |
| 125 | +Additional packages can be mounted into the container under `/opt/froxlor/packages`. |
| 126 | + |
| 127 | +For example, to develop an additional package named `example-package`, add it as a volume: |
| 128 | + |
| 129 | +```yaml |
| 130 | +services: |
| 131 | + froxlor: |
| 132 | + # ... |
| 133 | + environment: |
| 134 | + FROXLOR_DEV_REPOSITORIES: framework,example-package |
| 135 | + FROXLOR_DEV_PACKAGES: froxlor/example-package |
| 136 | + volumes: |
| 137 | + - ../froxlor:/var/www/html/froxlor |
| 138 | + - ../framework:/opt/froxlor/packages/framework |
| 139 | + - ../example-package:/opt/froxlor/packages/example-package |
| 140 | +``` |
| 141 | +
|
| 142 | +## Helpful Commands |
| 143 | +
|
| 144 | +Here you'll find a list of helpful commands that you might need to use sometimes because of certain edge cases. |
| 145 | +
|
| 146 | +### Database migration and seeding |
| 147 | +
|
| 148 | +If you mount the source code without an existing database, startup may fail because database initialization will not |
| 149 | +run when the source code is present. To migrate and seed the database, run the following command: |
| 150 | +
|
| 151 | +```shell |
| 152 | +docker compose run froxlor php artisan migrate:fresh --seed |
| 153 | +``` |
| 154 | + |
| 155 | +### Usage of Composer |
| 156 | + |
| 157 | +Sometimes you may wish to use Composer without using froxlor's package management. This can easily be done with the |
| 158 | +following command: |
| 159 | + |
| 160 | +```shell |
| 161 | +docker compose run froxlor composer <...> |
| 162 | +``` |
0 commit comments