diff --git a/.docker/php-fpm/Dockerfile b/.docker/php-fpm/Dockerfile index b8f42b6..c2f6b01 100644 --- a/.docker/php-fpm/Dockerfile +++ b/.docker/php-fpm/Dockerfile @@ -241,17 +241,20 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # Copy xdebug configuration for remote debugging COPY php-fpm/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini +# Configure Xdebug settings based on PHP version +# For Xdebug 3 (PHP 7.3, 7.4, 8.x): Use trigger mode to prevent connection warnings during build +# For Xdebug 2 (older PHP): Keep autostart disabled to prevent connection warnings during build RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ] || { [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && { [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ] || [ $(php -r "echo PHP_MINOR_VERSION;") = "3" ] ;} ;}; then \ sed -i "s/xdebug.remote_host=/xdebug.client_host=/" /usr/local/etc/php/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_connect_back=0/xdebug.discover_client_host=false/" /usr/local/etc/php/conf.d/xdebug.ini && \ - sed -i "s/xdebug.remote_port=9003/xdebug.client_port=${XDEBUG_PORT}/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug\.\(remote_port\|client_port\)=[0-9]*/xdebug.client_port=${XDEBUG_PORT}/" /usr/local/etc/php/conf.d/xdebug.ini && \ sed -i "s/xdebug.profiler_enable=0/; xdebug.profiler_enable=0/" /usr/local/etc/php/conf.d/xdebug.ini && \ sed -i "s/xdebug.profiler_output_dir=/xdebug.output_dir=/" /usr/local/etc/php/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_mode=req/; xdebug.remote_mode=req/" /usr/local/etc/php/conf.d/xdebug.ini && \ - sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=yes/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=trigger/" /usr/local/etc/php/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_enable=0/xdebug.mode=debug/" /usr/local/etc/php/conf.d/xdebug.ini \ ;else \ - sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/etc/php/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=0/" /usr/local/etc/php/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/php/conf.d/xdebug.ini \ ;fi RUN sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/php/conf.d/xdebug.ini diff --git a/.docker/workspace/Dockerfile b/.docker/workspace/Dockerfile index a4783fb..4991a1d 100644 --- a/.docker/workspace/Dockerfile +++ b/.docker/workspace/Dockerfile @@ -329,17 +329,20 @@ RUN echo "##### PHP Version #####" \ # ADD for REMOTE debugging COPY workspace/xdebug.ini /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini +# Configure Xdebug settings based on PHP version +# For Xdebug 3 (PHP 7.3, 7.4, 8.x): Use trigger mode to prevent connection warnings during build +# For Xdebug 2 (older PHP): Keep autostart disabled to prevent connection warnings during build RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ] || { [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && { [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ] || [ $(php -r "echo PHP_MINOR_VERSION;") = "3" ] ;} ;}; then \ sed -i "s/xdebug.remote_host=/xdebug.client_host=/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_connect_back=0/xdebug.discover_client_host=false/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ - sed -i "s/xdebug.remote_port=9000/xdebug.client_port=${XDEBUG_PORT}/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug\.\(remote_port\|client_port\)=[0-9]*/xdebug.client_port=${XDEBUG_PORT}/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.profiler_enable=0/; xdebug.profiler_enable=0/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.profiler_output_dir=/xdebug.output_dir=/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_mode=req/; xdebug.remote_mode=req/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ - sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=yes/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=trigger/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_enable=0/xdebug.mode=debug/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini \ ;else \ - sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=0/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini \ ;fi RUN sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini diff --git a/.docker/workspace/Dockerfile.74 b/.docker/workspace/Dockerfile.74 index adabd3a..08706c8 100644 --- a/.docker/workspace/Dockerfile.74 +++ b/.docker/workspace/Dockerfile.74 @@ -360,17 +360,20 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # ADD for REMOTE debugging COPY ./xdebug.ini /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini +# Configure Xdebug settings based on PHP version +# For Xdebug 3 (PHP 7.3, 7.4, 8.x): Use trigger mode to prevent connection warnings during build +# For Xdebug 2 (older PHP): Keep autostart disabled to prevent connection warnings during build RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ] || { [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && { [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ] || [ $(php -r "echo PHP_MINOR_VERSION;") = "3" ] ;} ;}; then \ sed -i "s/xdebug.remote_host=/xdebug.client_host=/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_connect_back=0/xdebug.discover_client_host=false/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ - sed -i "s/xdebug.remote_port=9000/xdebug.client_port=${XDEBUG_PORT}/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug\.\(remote_port\|client_port\)=[0-9]*/xdebug.client_port=${XDEBUG_PORT}/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.profiler_enable=0/; xdebug.profiler_enable=0/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.profiler_output_dir=/xdebug.output_dir=/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_mode=req/; xdebug.remote_mode=req/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ - sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=yes/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=trigger/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_enable=0/xdebug.mode=debug/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini \ ;else \ - sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=0/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini \ ;fi RUN sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini diff --git a/.docker/workspace/Dockerfile.81 b/.docker/workspace/Dockerfile.81 index 9de08f3..71f0f45 100644 --- a/.docker/workspace/Dockerfile.81 +++ b/.docker/workspace/Dockerfile.81 @@ -292,17 +292,20 @@ RUN echo "##### PHP Version #####" \ # ADD for REMOTE debugging COPY ./xdebug.ini /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini +# Configure Xdebug settings based on PHP version +# For Xdebug 3 (PHP 7.3, 7.4, 8.x): Use trigger mode to prevent connection warnings during build +# For Xdebug 2 (older PHP): Keep autostart disabled to prevent connection warnings during build RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ] || { [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && { [ $(php -r "echo PHP_MINOR_VERSION;") = "4" ] || [ $(php -r "echo PHP_MINOR_VERSION;") = "3" ] ;} ;}; then \ sed -i "s/xdebug.remote_host=/xdebug.client_host=/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_connect_back=0/xdebug.discover_client_host=false/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ - sed -i "s/xdebug.remote_port=9000/xdebug.client_port=${XDEBUG_PORT}/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug\.\(remote_port\|client_port\)=[0-9]*/xdebug.client_port=${XDEBUG_PORT}/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.profiler_enable=0/; xdebug.profiler_enable=0/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.profiler_output_dir=/xdebug.output_dir=/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_mode=req/; xdebug.remote_mode=req/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ - sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=yes/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=trigger/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_enable=0/xdebug.mode=debug/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini \ ;else \ - sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ + sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=0/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini \ ;fi RUN sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/php/${IVPLDOCK_PHP_VERSION}/cli/conf.d/xdebug.ini diff --git a/.docker/workspace/xdebug.ini b/.docker/workspace/xdebug.ini index 3e6346e..d1d6b29 100644 --- a/.docker/workspace/xdebug.ini +++ b/.docker/workspace/xdebug.ini @@ -3,7 +3,7 @@ zend_extension=xdebug.so ; Xdebug Mode xdebug.mode=debug -xdebug.start_with_request=yes +xdebug.start_with_request=trigger xdebug.client_host=host.docker.internal xdebug.client_port=9003 xdebug.discover_client_host=false diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..a880968 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,326 @@ +# GitHub Copilot Instructions for InvoicePlane-Docker + +## Project Context + +This repository provides a Docker-based development environment for InvoicePlane, forked from Laradock. The primary goal is to maintain a stable, performant, and easy-to-use containerized environment for InvoicePlane development. + +## Core Principles + +### 1. Minimalism +- Make the smallest possible changes to achieve the goal +- Avoid unnecessary refactoring or feature additions +- Keep configurations simple and maintainable + +### 2. Compatibility +- Support PHP versions: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 +- Maintain backward compatibility with existing configurations +- Test changes across all supported PHP versions + +### 3. Documentation +- Document all configuration changes +- Update README.md for user-facing changes +- Add inline comments for complex Dockerfile logic + +## Code Style Guidelines + +### Dockerfile Best Practices + +```dockerfile +# Good: Clear section headers and comments +########################################################################### +# Redis Extension: +########################################################################### + +ARG INSTALL_REDIS=false +RUN if [ ${INSTALL_REDIS} = true ]; then \ + # Install Redis extension for PHP + pecl install redis && \ + docker-php-ext-enable redis \ +;fi + +# Bad: No comments, unclear purpose +ARG INSTALL_REDIS=false +RUN if [ ${INSTALL_REDIS} = true ]; then \ + pecl install redis && \ + docker-php-ext-enable redis \ +;fi +``` + +### Shell Scripts + +```bash +# Good: Error handling and validation +#!/bin/bash +set -euo pipefail + +if [ ! -f .env.docker ]; then + echo "Error: .env.docker file not found!" + exit 1 +fi + +# Bad: No error handling +#!/bin/bash +docker-compose up -d +``` + +### Environment Variables + +```bash +# Good: Descriptive names with sensible defaults +WORKSPACE_INSTALL_XDEBUG=true +WORKSPACE_XDEBUG_PORT=9003 +PHP_VERSION=8.1 + +# Bad: Unclear names or no defaults +XDBG=true +PORT=9003 +VER=8.1 +``` + +## Common Tasks + +### Adding a New PHP Extension + +1. **Update Dockerfile** (e.g., `.docker/php-fpm/Dockerfile`): + ```dockerfile + ########################################################################### + # Extension Name: + ########################################################################### + + ARG INSTALL_EXTENSION=false + + RUN if [ ${INSTALL_EXTENSION} = true ]; then \ + # Install dependencies if needed + apt-get install -yqq lib-dependency && \ + # Install extension + pecl install extension-name && \ + docker-php-ext-enable extension-name \ + ;fi + ``` + +2. **Update docker-compose.yml**: + ```yaml + php-fpm: + build: + args: + - INSTALL_EXTENSION=${PHP_FPM_INSTALL_EXTENSION} + ``` + +3. **Update .env.example**: + ```bash + ### PHP-FPM ############################################## + PHP_FPM_INSTALL_EXTENSION=false + ``` + +4. **Test across PHP versions**: + ```bash + # Test with different PHP versions + sed -i 's/PHP_VERSION=8.1/PHP_VERSION=8.2/' .env.docker + docker compose --env-file .env.docker build php-fpm + ``` + +### Modifying Xdebug Configuration + +- **Always use trigger mode** to prevent build-time warnings +- **Never use autostart** for Xdebug 3 or remote_autostart=1 for Xdebug 2 +- **Document trigger methods** in README and inline comments + +Example: +```dockerfile +# Configure Xdebug settings based on PHP version +# For Xdebug 3 (PHP 7.3+, 7.4, 8.x): Use trigger mode to prevent connection warnings during build +# For Xdebug 2 (older PHP): Keep autostart disabled to prevent connection warnings during build +RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \ + sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=trigger/" /usr/local/etc/php/conf.d/xdebug.ini \ +;fi +``` + +### Adding New Services + +1. Create Dockerfile in `.docker//` +2. Add service to `docker-compose.yml` +3. Add configuration options to `.env.example` +4. Document in README.md +5. Add to CI/CD if appropriate + +## Testing Requirements + +### Before Committing + +1. **Build test**: + ```bash + docker compose --env-file .env.docker build + ``` + +2. **Start test**: + ```bash + docker compose --env-file .env.docker up -d + docker compose --env-file .env.docker ps + ``` + +3. **Functionality test**: + ```bash + docker compose --env-file .env.docker exec php -v + docker compose --env-file .env.docker exec php -m | grep + ``` + +### CI/CD Integration + +- All changes trigger GitHub Actions workflows +- Tests run for PHP 8.2, 8.3, 8.4 +- Ensure builds pass before merging + +## Security Considerations + +### Xdebug in Production + +- Xdebug should NEVER be enabled in production +- Always use trigger mode, never autostart +- Document security implications + +### Secrets Management + +- Never commit `.env.docker` files +- Use environment variables for sensitive data +- Document required secrets in `.env.example` + +### Container Security + +- Run as non-root user where possible +- Keep base images updated +- Minimize installed packages + +## Performance Optimization + +### Docker Layer Caching + +Order Dockerfile commands from least to most frequently changing: + +```dockerfile +# Good: Stable commands first +RUN apt-get update && apt-get install -yqq stable-package +COPY rarely-changed-file /dest/ +RUN frequently-changing-command +COPY frequently-changed-file /dest/ + +# Bad: Frequent changes invalidate cache for everything below +COPY frequently-changed-file /dest/ +RUN apt-get update && apt-get install -yqq stable-package +``` + +### Build Arguments + +- Use build arguments for configurability +- Cache builds with different argument values +- Document all build arguments + +## Documentation Standards + +### README Updates + +When changing functionality, update README.md: + +1. **Quick Start** - If setup process changes +2. **Configuration** - If new env vars added +3. **Troubleshooting** - If new issues arise +4. **Examples** - If new features added + +### Inline Comments + +Use comments for: +- Complex conditional logic +- Version-specific workarounds +- Security considerations +- Performance optimizations + +```dockerfile +# Good: Explains why +RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ + # PHP 5 requires older version of extension + pecl install extension-2.0.0; \ +else \ + pecl install extension; \ +fi + +# Bad: States obvious +RUN pecl install extension # Install extension +``` + +## Common Pitfalls to Avoid + +### 1. Breaking Changes +- Don't change default values without considering existing users +- Maintain backward compatibility +- Version breaking changes appropriately + +### 2. Build-Time Warnings +- Always test builds completely +- Address all warnings, especially Xdebug connection warnings +- Clean build output is important + +### 3. Cross-Platform Issues +- Test on Linux, macOS, and Windows when possible +- Use cross-platform path separators +- Document platform-specific considerations + +### 4. Version Compatibility +- Don't assume latest PHP version features +- Support the full range of declared PHP versions +- Test edge cases (oldest and newest versions) + +## Git Workflow + +### Commit Messages + +Format: `: ` + +Types: +- `feat`: New feature +- `fix`: Bug fix +- `docs`: Documentation changes +- `refactor`: Code refactoring +- `test`: Test additions/changes +- `chore`: Maintenance tasks + +Examples: +``` +fix: Resolve Xdebug connection warnings during build +docs: Add Xdebug trigger mode documentation +feat: Add Redis container support +``` + +### Pull Request Template + +1. **Title**: Clear, descriptive +2. **Description**: Explain the change and why +3. **Testing**: Describe testing performed +4. **Breaking Changes**: List any breaking changes +5. **Screenshots**: For UI/output changes + +## AI Assistance Best Practices + +When using GitHub Copilot or similar tools: + +1. **Review all suggestions** - Don't blindly accept +2. **Understand the code** - Know what you're committing +3. **Test thoroughly** - AI can miss edge cases +4. **Document decisions** - Explain non-obvious choices +5. **Security first** - Verify security implications + +## Resources + +- [Laradock Documentation](https://laradock.io) +- [Docker Best Practices](https://docs.docker.com/develop/dev-best-practices/) +- [PHP Docker Images](https://hub.docker.com/_/php) +- [Dockerfile Reference](https://docs.docker.com/engine/reference/builder/) + +## Support Channels + +- GitHub Issues: Bug reports and feature requests +- GitHub Discussions: Questions and community support +- Pull Requests: Code contributions + +--- + +**Last Updated**: 2025-01-05 +**Maintainer**: InvoicePlane Team diff --git a/.junie/guidelines.md b/.junie/guidelines.md new file mode 100644 index 0000000..adb3d35 --- /dev/null +++ b/.junie/guidelines.md @@ -0,0 +1,293 @@ +# InvoicePlane Docker Development Guidelines + +## Overview + +This repository provides a complete Docker-based development environment for InvoicePlane, forked from Laradock and optimized for InvoicePlane-specific needs. + +## Project Structure + +``` +InvoicePlane-Docker/ +├── .docker/ # All Dockerfile definitions +│ ├── php-fpm/ # PHP-FPM container configuration +│ ├── workspace/ # Workspace container for CLI operations +│ ├── nginx/ # Nginx web server +│ ├── mariadb/ # MariaDB database +│ └── ... # Other service containers +├── .github/ # GitHub Actions CI/CD workflows +├── sites/ # Nginx site configurations +├── *.sh # Helper scripts for common operations +├── docker-compose.yml # Main docker-compose configuration +└── .env.example # Example environment configuration +``` + +## Development Workflow + +### Initial Setup + +1. **Clone the repository** + ```bash + git clone https://github.com/InvoicePlane/InvoicePlane-Docker.git + cd InvoicePlane-Docker + ``` + +2. **Create environment file** + ```bash + cp .env.example .env.docker + ``` + +3. **Configure your environment** + - Edit `.env.docker` to set PHP version, ports, and paths + - Adjust `APP_CODE_PATH_HOST` to point to your projects directory + +4. **Build and start containers** + ```bash + ./builddmeup.sh # Build and start in background + ``` + +### Working with Containers + +#### Helper Scripts +Use the provided helper scripts for common operations: + +- **Building**: `./buildmeup.sh` (foreground) or `./builddmeup.sh` (background) +- **Starting**: `./startmeup.sh` (foreground) or `./starmeup.sh` (background) +- **Stopping**: `./down.sh` +- **Shell Access**: + - `./workmeup.sh` - Enter workspace as ivpldock user + - `./rootmeup.sh` - Enter workspace as root + - `./phpmeup.sh` - Enter php-fpm container + - `./worker.sh` - Enter php-worker container + +#### Executing Commands +Use `docker-exec.sh` to run commands in containers: +```bash +./docker-exec.sh +``` + +Examples: +```bash +# Composer operations +./docker-exec.sh workspace invoiceplane "composer install" +./docker-exec.sh workspace invoiceplane "composer update" + +# Laravel/Artisan commands +./docker-exec.sh php-fpm invoiceplane "php artisan migrate" +./docker-exec.sh workspace invoiceplane "php artisan test" + +# NPM operations +./docker-exec.sh workspace invoiceplane "npm install" +./docker-exec.sh workspace invoiceplane "npm run build" +``` + +## Code Standards + +### PHP Development + +- **PHP Version**: Support PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 +- **Framework**: Built for Laravel/CodeIgniter applications +- **Extensions**: All required PHP extensions are pre-installed + +### Docker Standards + +1. **Dockerfile Changes** + - Keep changes minimal and well-documented + - Test across all supported PHP versions + - Add comments explaining complex configurations + +2. **Build Optimization** + - Leverage Docker layer caching + - Order commands from least to most frequently changing + - Use multi-stage builds where appropriate + +3. **Environment Configuration** + - Never commit `.env.docker` files + - Document all new environment variables in `.env.example` + - Use sensible defaults + +## Debugging + +### Xdebug Configuration + +Xdebug is configured in **trigger mode** to prevent connection warnings during builds. + +#### Activating Xdebug + +**For Web Requests:** +1. Install Xdebug Helper browser extension +2. Set cookie: `XDEBUG_TRIGGER=1` +3. Or add query parameter: `?XDEBUG_TRIGGER=1` + +**For CLI Commands:** +```bash +# Inside container +XDEBUG_TRIGGER=1 php artisan test + +# From host +./docker-exec.sh workspace myproject "XDEBUG_TRIGGER=1 php artisan test" +``` + +#### IDE Configuration + +**PHPStorm:** +1. Settings → PHP → Debug → Port: 9003 +2. Settings → PHP → Servers → Name: ivpldock +3. Enable "Listen for PHP Debug Connections" + +**VS Code:** +1. Install PHP Debug extension +2. Configure launch.json with port 9003 +3. Set path mappings + +### Common Issues + +#### Container Won't Start +```bash +# Check if .env.docker exists +ls -la .env.docker + +# View logs +docker compose --env-file .env.docker logs -f + +# Check running containers +docker compose --env-file .env.docker ps +``` + +#### Port Conflicts +- Check if ports are already in use: `netstat -tlnp | grep ` +- Modify ports in `.env.docker` + +#### Permission Issues +- Ensure `PUID` and `PGID` in `.env.docker` match your user +- Run: `id -u` and `id -g` to get your user/group IDs + +## Testing + +### CI/CD Pipeline + +GitHub Actions automatically test: +- PHP 8.2, 8.3, 8.4 builds +- Container startup +- PHP extension installation +- Basic functionality + +### Local Testing + +Before committing changes: + +```bash +# Test build for specific PHP version +docker compose --env-file .env.docker build workspace php-fpm + +# Start containers +docker compose --env-file .env.docker up -d + +# Verify PHP version +docker compose --env-file .env.docker exec workspace php -v + +# Run application tests +./docker-exec.sh workspace invoiceplane "php artisan test" +``` + +## Contributing + +### Pull Request Guidelines + +1. **Branch Naming**: Use descriptive names + - `feature/add-redis-support` + - `fix/xdebug-connection-warnings` + - `docs/improve-readme` + +2. **Commit Messages**: Be clear and descriptive + - Start with verb: "Add", "Fix", "Update", "Remove" + - Reference issues: "Fix #123: Resolve port conflict" + +3. **Documentation**: Update relevant docs + - README.md for user-facing changes + - .env.example for new variables + - Inline comments for complex code + +4. **Testing**: Ensure all tests pass + - Local testing before push + - CI/CD must pass + - Test across PHP versions if applicable + +### Code Review Process + +1. Automated checks must pass +2. Manual review by maintainers +3. Address feedback promptly +4. Squash commits if requested + +## Performance Optimization + +### Build Caching + +Docker automatically caches layers: +- Built images persist even after stopping containers +- Only changed layers trigger rebuilds +- Use `--no-cache` sparingly + +### Volume Performance + +**macOS/Windows:** +- Use `:cached` flag for better performance +- Consider Docker Sync for large projects + +**Linux:** +- Native performance, no special flags needed + +## Security + +### Best Practices + +1. **Secrets Management** + - Never commit sensitive data + - Use environment variables + - Rotate credentials regularly + +2. **Container Security** + - Keep base images updated + - Run as non-root user where possible + - Limit container capabilities + +3. **Network Security** + - Use internal networks for service communication + - Expose only necessary ports + - Configure firewalls appropriately + +## Maintenance + +### Regular Updates + +1. **Base Images**: Update quarterly +2. **PHP Versions**: Support latest stable releases +3. **Dependencies**: Keep composer/npm packages current + +### Cleanup + +```bash +# Remove stopped containers +docker compose --env-file .env.docker down + +# Remove volumes (WARNING: deletes data) +docker compose --env-file .env.docker down -v + +# Clean up Docker system +docker system prune -a +``` + +## Resources + +- **Laradock**: Original upstream project - [github.com/laradock/laradock](https://github.com/laradock/laradock) +- **InvoicePlane**: Main application - [github.com/InvoicePlane/InvoicePlane](https://github.com/InvoicePlane/InvoicePlane) +- **Docker Documentation**: [docs.docker.com](https://docs.docker.com) +- **PHP Docker Images**: [hub.docker.com/_/php](https://hub.docker.com/_/php) + +## Support + +For issues or questions: +1. Check existing GitHub issues +2. Review documentation thoroughly +3. Create detailed issue with reproduction steps +4. Include relevant logs and configuration diff --git a/README.md b/README.md index 0f818bc..75397fc 100644 --- a/README.md +++ b/README.md @@ -1,119 +1,737 @@ # InvoicePlane Docker -Docker-compose with a webserver, MySQL, phpmyadmin and redis -- docker-compose.yml -- .env +> **Complete Docker-based development environment for InvoicePlane** -## Quick Start +A containerized development stack featuring PHP, Nginx, MariaDB, Redis, and more. Built on Laradock and optimized for InvoicePlane development with support for PHP 7.4 through 8.4. -1. Create your environment file: +## 🚀 Quick Start + +1. **Clone the repository** + ```bash + git clone https://github.com/InvoicePlane/InvoicePlane-Docker.git + cd InvoicePlane-Docker + ``` + +2. **Create your environment file** ```bash cp .env.example .env.docker ``` -2. Build and start containers: +3. **Configure your setup** (optional) + ```bash + # Edit .env.docker to customize: + # - PHP version (8.1, 8.2, 8.3, 8.4) + # - Database settings + # - Port mappings + nano .env.docker + ``` + +4. **Build and start containers** ```bash ./builddmeup.sh ``` -## Helper Scripts +5. **Verify installation** + ```bash + docker compose --env-file .env.docker ps + ``` + +Your development environment is now ready! 🎉 + +## 📖 Setting Up Your First Project (InvoicePlane) + +This guide will walk you through setting up InvoicePlane v1 step by step. + +### Step 1: Prepare Your Project Directory + +First, make sure your projects directory exists. By default, this is `~/projects`: + +```bash +# Create the projects directory if it doesn't exist +mkdir -p ~/projects + +# Clone InvoicePlane v1 into your projects directory +cd ~/projects +git clone https://github.com/InvoicePlane/InvoicePlane.git ivplv1 +cd ivplv1 +``` + +> 💡 **Note**: The folder name `ivplv1` will be used in the next steps. You can choose any name you like, but remember to use it consistently. + +### Step 2: Configure Your Environment + +Open your `.env.docker` file in the InvoicePlane-Docker directory: + +```bash +cd /path/to/InvoicePlane-Docker +nano .env.docker +``` + +Find the line that says `APP_CODE_PATH_HOST` and make sure it points to your projects directory: + +```bash +# This should match where you created your projects folder +APP_CODE_PATH_HOST=~/projects/ +``` + +> 💡 **Tip**: If you used a different path for your projects, update this line accordingly. For example, if your projects are in `/home/username/myprojects/`, use that path instead. + +### Step 3: Create Your Nginx Configuration + +Now we'll tell Nginx how to serve your InvoicePlane project: + +1. **Copy the example configuration:** + ```bash + cd /path/to/InvoicePlane-Docker + cp sites/copyme.conf.example sites/ivplv1.conf + ``` + +2. **Open the configuration file:** + ```bash + nano sites/ivplv1.conf + ``` + +3. **Replace all instances of `copyme` with `ivplv1`** and **remove `/public` from the root path** (there are 4 places to change): + - Line 5: `server_name copyme.local;` → `server_name ivplv1.test;` + - Line 6: `root /var/www/projects/copyme/public;` → `root /var/www/projects/ivplv1;` *(also remove /public)* + - Line 34: `error_log /var/log/nginx/copyme_error.log;` → `error_log /var/log/nginx/ivplv1_error.log;` + - Line 35: `access_log /var/log/nginx/copyme_access.log;` → `access_log /var/log/nginx/ivplv1_access.log;` + + > 💡 **Why remove `/public`?** InvoicePlane v1 doesn't use a public directory like some frameworks. The main files are in the root of the project. + + > 💡 **Why use `.test` instead of `.local`?** The `.test` domain is reserved for testing and won't conflict with real domains. You can use `.local` if you prefer, just be consistent. + +4. **Save and close the file** (in nano: press `Ctrl+X`, then `Y`, then `Enter`) + +### Step 4: Add Domain to Your Hosts File + +Tell your computer that `ivplv1.test` should point to your local Docker environment: + +**On Linux/Mac:** +```bash +sudo nano /etc/hosts +``` + +**On Windows:** +Open Notepad as Administrator, then open: +``` +C:\Windows\System32\drivers\etc\hosts +``` + +Add this line: +``` +127.0.0.1 ivplv1.test +``` + +Save and close the file. + +### Step 5: Start Docker + +Now start your Docker environment: + +```bash +cd /path/to/InvoicePlane-Docker +./starmeup.sh +``` + +> 💡 **What's happening?** Docker is: +> - Building the containers (first time takes 5-10 minutes) +> - Starting PHP, Nginx, MariaDB, and other services +> - Reading your `ivplv1.conf` file to know how to serve your project +> - Making your project available at `http://ivplv1.test` + +You'll see lots of output in your terminal. This is normal! Look for messages saying containers are starting. + +### Step 6: Verify Everything is Running + +In a new terminal window (keep Docker running in the first one): + +```bash +cd /path/to/InvoicePlane-Docker +docker compose --env-file .env.docker ps +``` + +You should see all services with "Up" status: +``` +NAME STATUS +workspace Up +php-fpm Up +nginx Up +mariadb Up +redis Up +``` + +### Step 7: Access Your Project + +Open your web browser and go to: +``` +http://ivplv1.test +``` + +You should see your InvoicePlane installation! 🎉 + +### Step 8: Stop Docker When Done + +When you're finished working, stop Docker: + +**Option 1: Stop from terminal** (if Docker is running in foreground) +- Press `Ctrl+C` in the terminal where Docker is running + +**Option 2: Stop and remove everything** +```bash +./down.sh +``` + +This stops all containers and removes them (but keeps your code safe). + +### Step 9: Restart Docker Later + +When you want to work again, just run: +```bash +./starmeup.sh +``` + +This is much faster than the first build! ⚡ + +--- + +### 🆘 Troubleshooting + +**Problem**: Can't access `http://ivplv1.test` +- **Solution**: Make sure you added `127.0.0.1 ivplv1.test` to your hosts file +- **Solution**: Make sure Docker is running (`docker compose ps`) +- **Solution**: Try `http://localhost` instead + +**Problem**: "Port already in use" +- **Solution**: Another service is using port 80. Either stop it, or change the port in `.env.docker`: + ```bash + NGINX_HOST_HTTP_PORT=8080 + ``` + Then **restart Docker** for the change to take effect: + ```bash + ./down.sh + ./starmeup.sh + ``` + Access your site at `http://ivplv1.test:8080` + +**Problem**: "Permission denied" errors +- **Solution**: Check your `PUID` and `PGID` in `.env.docker` match your user: + ```bash + id -u # This is your PUID + id -g # This is your PGID + ``` + +**Problem**: Changes to nginx config not working +- **Solution**: Restart Docker to reload the configuration: + ```bash + ./down.sh + ./starmeup.sh + ``` + +## 📦 What's Included + +### Services +- **PHP-FPM** - PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 (configurable) +- **Workspace** - CLI tools, Composer, Node.js, Git +- **Nginx** - Web server with optimized configuration +- **MariaDB** - Database server +- **Redis** - Caching and session storage +- **Beanstalkd** - Queue management +- **phpMyAdmin** - Database management interface +- **Redis Web UI** - Redis monitoring interface + +### Features +- ✅ Multiple PHP versions support +- ✅ Xdebug with trigger mode +- ✅ Pre-configured for Laravel and CodeIgniter +- ✅ Helper scripts for common tasks +- ✅ GitHub Actions CI/CD +- ✅ Optimized Docker layer caching + +## 🛠️ Helper Scripts All scripts include error handling and validation to ensure a smooth experience. -### Building +### 🔨 Building -Build and start containers: -- `./buildmeup.sh` - Build and start in foreground (with logs) -- `./builddmeup.sh` - Build and start in background (detached mode) +**Build and start containers:** +| Script | Mode | Description | +|--------|------|-------------| +| `./buildmeup.sh` | Foreground | Build and start with live logs | +| `./builddmeup.sh` | Background | Build and start in detached mode | -### Starting/Stopping +### ▶️ Starting/Stopping -Start existing containers (without rebuilding): -- `./startmeup.sh` - Start in foreground (with logs) -- `./startmeup.sh` - Start in background (detached mode) -- `./down.sh` - Stop and remove all containers and volumes +**Control existing containers:** +| Script | Mode | Description | +|--------|------|-------------| +| `./starmeup.sh` | Foreground | Start with live logs | +| `./startmeup.sh` | Background | Start in detached mode | +| `./down.sh` | - | Stop and remove all containers and volumes | -### Accessing Containers +### 🖥️ Accessing Containers -Enter a running container: -- `./workmeup.sh` - Enter workspace as ivpldock user -- `./rootmeup.sh` - Enter workspace as root -- `./phpmeup.sh` - Enter php-fpm container -- `./worker.sh` - Enter php-worker container +**Enter a running container:** +| Script | Container | User | Use Case | +|--------|-----------|------|----------| +| `./workmeup.sh` | workspace | ivpldock | Development tasks, Composer, NPM | +| `./rootmeup.sh` | workspace | root | System administration | +| `./phpmeup.sh` | php-fpm | root | PHP-FPM debugging | +| `./worker.sh` | php-worker | root | Queue worker debugging | -### Running Commands +### 🚀 Running Commands -Execute commands inside containers from your host: +Execute commands inside containers from your host using `docker-exec.sh`: + +**Syntax:** ```bash ./docker-exec.sh ``` -Examples: +**Common Examples:** + ```bash -# Run composer install +# 📦 Composer Operations ./docker-exec.sh workspace myproject "composer install" +./docker-exec.sh workspace myproject "composer update" +./docker-exec.sh workspace myproject "composer require vendor/package" -# Run Laravel migrations +# 🎨 Laravel/Artisan Commands +./docker-exec.sh php-fpm invoiceplane "php artisan migrate" ./docker-exec.sh php-fpm invoiceplane "php artisan migrate --force" +./docker-exec.sh workspace invoiceplane "php artisan test" +./docker-exec.sh workspace invoiceplane "php artisan db:seed" -# Run tests -./docker-exec.sh workspace myproject "php artisan test" +# 📊 Database Operations +./docker-exec.sh workspace invoiceplane "php artisan migrate:fresh --seed" +./docker-exec.sh workspace invoiceplane "php artisan migrate:rollback" -# Build assets +# 🔧 NPM Operations +./docker-exec.sh workspace myapp "npm install" ./docker-exec.sh workspace myapp "npm run build" +./docker-exec.sh workspace myapp "npm run dev" +./docker-exec.sh workspace myapp "npm run watch" + +# 🧪 Testing +./docker-exec.sh workspace myproject "php artisan test" +./docker-exec.sh workspace myproject "vendor/bin/phpunit" +./docker-exec.sh workspace myproject "php artisan test --filter UserTest" ``` -## Continuous Integration +## 🔄 Continuous Integration + +This repository includes automated GitHub Actions workflows that test Docker builds. + +**Tested PHP Versions:** +- ✅ PHP 8.2 +- ✅ PHP 8.3 +- ✅ PHP 8.4 -This repository includes GitHub Actions workflows that automatically test Docker builds for: -- PHP 8.2 -- PHP 8.3 -- PHP 8.4 +**CI Pipeline Verifies:** +- ✅ All containers build successfully +- ✅ PHP extensions are properly installed (zip, etc.) +- ✅ Services start correctly +- ✅ Basic functionality works -The CI pipeline verifies: -- All containers build successfully -- PHP extensions (including zip) are properly installed -- Services start correctly +**Workflow Triggers:** +- Push to main branches +- Pull requests +- Manual dispatch -## Directories +## 📁 Directory Structure -| Directory | Purpose | -|---------- |:--------------------------------------------------------------: | -| ./.docker | For all the DockerFiles | | -| ./sites | For all the sites (for the nginx webserver) | -| ./.github/workflows | GitHub Actions CI/CD pipelines | +| Directory | Purpose | +|-----------|---------| +| `.docker/` | All Dockerfile definitions for services | +| `sites/` | Nginx site configurations | +| `.github/workflows/` | GitHub Actions CI/CD pipelines | +| `*.sh` | Helper scripts for common operations | -## Configuration +## ⚙️ Configuration -Edit `.env.docker` to customize: -- PHP version (8.1, 8.2, 8.3, 8.4) -- Database settings -- Port mappings -- Service options +### Basic Setup -## Troubleshooting +Edit `.env.docker` to customize your environment: -### Container not starting? -Check if the .env.docker file exists: +**Core Settings:** ```bash -ls -la .env.docker +# PHP Version +PHP_VERSION=8.1 # Options: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 + +# Project Path +APP_CODE_PATH_HOST=../projects/ + +# Database +MARIADB_VERSION=latest +MARIADB_DATABASE=default +MARIADB_USER=default +MARIADB_PASSWORD=secret + +# Ports +NGINX_HOST_HTTP_PORT=80 +MARIADB_PORT=3306 +REDIS_PORT=6379 ``` -### Want to see running containers? +### 🐳 Docker Build Caching + +Docker automatically caches build layers to speed up subsequent builds. + +**How It Works:** +1. Docker Compose checks if dependent services need building +2. Uses cached layers if Dockerfile and context haven't changed +3. Only rebuilds layers that have changed + +**Benefits:** +- ⚡ Faster rebuild times +- 💾 Efficient resource usage +- 🔄 Smart dependency management + +**Tips for Better Caching:** ```bash +# Docker keeps built images in cache even after stopping containers docker compose --env-file .env.docker ps + +# Force complete rebuild only when necessary +docker compose --env-file .env.docker build --no-cache php-fpm + +# Build specific service +docker compose --env-file .env.docker build workspace + +# Parallel builds for multiple services +docker compose --env-file .env.docker build --parallel ``` -### View container logs? +**Example Workflow:** +```bash +# First build (takes longer) +docker compose --env-file .env.docker build php-fpm +# ⏱️ 5 minutes + +# Build dependent service (uses cache) +docker compose --env-file .env.docker build beanstalkd +# ⏱️ 30 seconds (php-fpm cached!) +``` + +### 🐛 Xdebug Configuration + +Xdebug is configured in **trigger mode** to prevent connection warnings during builds while maintaining full debugging capability. + +#### Activation Methods + +**1️⃣ Browser Debugging (Web Requests)** + +Using Browser Extension: +- Install [Xdebug Helper](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc) for Chrome +- Or [Xdebug Helper](https://addons.mozilla.org/en-US/firefox/addon/xdebug-helper-for-firefox/) for Firefox +- Click the extension icon to enable debugging + +Using Query Parameter: +``` +http://your-app.local?XDEBUG_TRIGGER=1 +``` + +Using Cookie: +```javascript +document.cookie = "XDEBUG_TRIGGER=1; path=/"; +``` + +**2️⃣ CLI Debugging (Command Line)** + +Inside Container: +```bash +# Enter workspace +./workmeup.sh + +# Run with Xdebug +XDEBUG_TRIGGER=1 php artisan test +XDEBUG_TRIGGER=1 php script.php +XDEBUG_TRIGGER=1 vendor/bin/phpunit +``` + +From Host: +```bash +# Single command with Xdebug +./docker-exec.sh workspace myproject "XDEBUG_TRIGGER=1 php artisan test" + +# Composer with Xdebug +./docker-exec.sh workspace myproject "XDEBUG_TRIGGER=1 composer install" +``` + +**3️⃣ Persistent Debugging (Environment Variable)** + +```bash +# Inside container +export XDEBUG_TRIGGER=1 +php artisan test # Now always uses Xdebug +``` + +#### IDE Configuration + +**PHPStorm Setup:** +1. Go to `Settings → PHP → Debug` +2. Set port to `9003` +3. Go to `Settings → PHP → Servers` +4. Add server named `ivpldock` +5. Set path mappings: + - Local: `/path/to/your/project` + - Remote: `/var/www/projects/yourproject` +6. Click "Start Listening for PHP Debug Connections" (phone icon) + +**VS Code Setup:** +1. Install [PHP Debug extension](https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug) +2. Create `.vscode/launch.json`: + ```json + { + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for Xdebug", + "type": "php", + "request": "launch", + "port": 9003, + "pathMappings": { + "/var/www/projects/yourproject": "${workspaceFolder}" + } + } + ] + } + ``` +3. Press F5 to start debugging + +#### Configuration Files + +```bash +# Xdebug settings locations +.docker/php-fpm/xdebug.ini # PHP-FPM container +.docker/workspace/xdebug.ini # Workspace container +``` + +**Default Port:** 9003 (configurable in `.env.docker`) + +#### Troubleshooting Xdebug + +```bash +# Verify Xdebug is installed +docker compose --env-file .env.docker exec workspace php -v +# Should show: "with Xdebug v3.x.x" + +# Check Xdebug configuration +docker compose --env-file .env.docker exec workspace php -i | grep xdebug + +# Test Xdebug trigger +docker compose --env-file .env.docker exec workspace bash -c "XDEBUG_TRIGGER=1 php -v" + +# View Xdebug logs +docker compose --env-file .env.docker exec workspace cat /tmp/xdebug.log +``` + +## 🔧 Troubleshooting + +### Common Issues + +#### ❌ Container Won't Start + +**Check environment file exists:** +```bash +ls -la .env.docker +``` + +**View detailed logs:** ```bash docker compose --env-file .env.docker logs -f +# Examples: +docker compose --env-file .env.docker logs -f workspace +docker compose --env-file .env.docker logs -f php-fpm ``` -> **Note**: The helper scripts use `docker-compose` for backward compatibility, but `docker compose` (v2) is recommended for manual commands. +**Check container status:** +```bash +docker compose --env-file .env.docker ps +docker compose --env-file .env.docker ps -a # Include stopped containers +``` + +#### 🔌 Port Already in Use + +**Check what's using the port:** +```bash +# Linux/Mac +sudo lsof -i :80 +sudo lsof -i :3306 + +# Or use netstat +netstat -tlnp | grep :80 +``` + +**Solution: Change port in `.env.docker`:** +```bash +NGINX_HOST_HTTP_PORT=8080 # Instead of 80 +MARIADB_PORT=3307 # Instead of 3306 +``` + +#### 🔐 Permission Denied Errors + +**Check and fix PUID/PGID:** +```bash +# Get your user and group ID +id -u # Your user ID +id -g # Your group ID + +# Update .env.docker +WORKSPACE_PUID=1000 # Your user ID +WORKSPACE_PGID=1000 # Your group ID +PHP_FPM_PUID=1000 +PHP_FPM_PGID=1000 + +# Rebuild containers +docker compose --env-file .env.docker build workspace php-fpm +docker compose --env-file .env.docker up -d +``` + +#### 🐌 Slow Performance (macOS/Windows) + +**Use cached volume flag:** +```bash +# In .env.docker +APP_CODE_CONTAINER_FLAG=:cached +``` + +**Consider Docker Sync for large projects:** +- Significant performance improvement +- See [docker-sync documentation](https://docker-sync.readthedocs.io/) + +#### 🗄️ Database Connection Failed + +**Verify database is running:** +```bash +docker compose --env-file .env.docker ps mariadb +``` + +**Check database credentials:** +```bash +# In .env.docker +MARIADB_DATABASE=default +MARIADB_USER=default +MARIADB_PASSWORD=secret + +# In your app's .env +DB_HOST=mariadb # Not localhost! +DB_PORT=3306 +DB_DATABASE=default +DB_USERNAME=default +DB_PASSWORD=secret +``` + +**Test connection:** +```bash +docker compose --env-file .env.docker exec workspace mysql -h mariadb -u default -psecret +``` + +#### 🧹 Clean Up Issues + +**Remove all containers and volumes:** +```bash +# WARNING: This deletes all data! +docker compose --env-file .env.docker down -v +``` + +**Full Docker cleanup:** +```bash +# Remove unused containers, networks, images +docker system prune -a + +# Remove all volumes (BE CAREFUL!) +docker volume prune +``` + +#### 📦 Build Failures + +**Clear build cache and rebuild:** +```bash +docker compose --env-file .env.docker build --no-cache --pull +``` + +**Check Docker disk space:** +```bash +docker system df +``` + +### Getting Help + +**Collect diagnostic information:** +```bash +# Docker version +docker --version +docker compose version + +# Container status +docker compose --env-file .env.docker ps + +# Recent logs +docker compose --env-file .env.docker logs --tail=50 workspace php-fpm + +# System info +docker info +``` + +**When reporting issues, include:** +1. Steps to reproduce +2. Error messages (full output) +3. Docker and compose versions +4. Operating system +5. Relevant configuration from `.env.docker` + +## 📚 Additional Resources + +### Documentation +- **Project Guidelines**: [.junie/guidelines.md](.junie/guidelines.md) - Comprehensive development guidelines +- **Copilot Instructions**: [.github/copilot-instructions.md](.github/copilot-instructions.md) - AI coding assistant guidelines +- **Docker Compatibility**: [DOCKER_COMPATIBILITY.md](DOCKER_COMPATIBILITY.md) - Version compatibility matrix + +### External Links +- **Laradock**: Original upstream project - [github.com/laradock/laradock](https://github.com/laradock/laradock) +- **InvoicePlane**: Main application - [github.com/InvoicePlane/InvoicePlane](https://github.com/InvoicePlane/InvoicePlane) +- **Docker Documentation**: [docs.docker.com](https://docs.docker.com) +- **Docker Compose Documentation**: [docs.docker.com/compose](https://docs.docker.com/compose) + +### Community & Support +- **Issues**: [GitHub Issues](https://github.com/InvoicePlane/InvoicePlane-Docker/issues) - Report bugs and request features +- **Discussions**: [GitHub Discussions](https://github.com/InvoicePlane/InvoicePlane-Docker/discussions) - Ask questions and share ideas +- **Pull Requests**: [Contributing Guidelines](.junie/guidelines.md#contributing) - Submit code improvements + +## 🤝 Contributing + +We welcome contributions! Please see our [development guidelines](.junie/guidelines.md) for: +- Code standards +- Testing requirements +- Pull request process +- Docker best practices + +### Quick Contribution Guide + +1. Fork the repository +2. Create a feature branch: `git checkout -b feature/amazing-feature` +3. Make your changes +4. Test thoroughly across PHP versions +5. Commit your changes: `git commit -m 'Add amazing feature'` +6. Push to branch: `git push origin feature/amazing-feature` +7. Open a Pull Request + +## 📝 License + +This project inherits its license from Laradock. See [LICENSE](LICENSE) for details. + +## 🙏 Origins & Credits + +This project was originally called **Laradock** and has been forked to target specifically the images needed to run InvoicePlane. + +- **Laradock**: [github.com/laradock/laradock](https://github.com/laradock/laradock/) +- **License**: Original license file included in this repository -## Origins +--- -This script was originally called Laradock. We've forked it to target just the specific images that are needed to run InvoicePlane. +**Version**: 2.0 +**Last Updated**: 2025-01-05 +**Maintained by**: [InvoicePlane Team](https://github.com/InvoicePlane) -Link to Laradock: [laradock](https://github.com/laradock/laradock/) -We've included their license file in this repository. +> **Note**: Helper scripts use `docker-compose` for backward compatibility, but `docker compose` (v2) is recommended for manual commands. diff --git a/docker-compose.yml b/docker-compose.yml index a5c302e..6bc8a84 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -149,7 +149,6 @@ services: volumes: - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG} - docker-in-docker:/certs/client - - /data/tenants:/tenants - ./.docker/php-worker/supervisord.d:/etc/supervisord.d extra_hosts: - "host.docker.internal:host-gateway"