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.
- Make the smallest possible changes to achieve the goal
- Avoid unnecessary refactoring or feature additions
- Keep configurations simple and maintainable
- 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
- Document all configuration changes
- Update README.md for user-facing changes
- Add inline comments for complex Dockerfile logic
# 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# 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# 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-
Update Dockerfile (e.g.,
.docker/php-fpm/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
-
Update docker-compose.yml:
php-fpm: build: args: - INSTALL_EXTENSION=${PHP_FPM_INSTALL_EXTENSION}
-
Update .env.example:
### PHP-FPM ############################################## PHP_FPM_INSTALL_EXTENSION=false -
Test across PHP versions:
# 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
- 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:
# 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- Create Dockerfile in
.docker/<service-name>/ - Add service to
docker-compose.yml - Add configuration options to
.env.example - Document in README.md
- Add to CI/CD if appropriate
-
Build test:
docker compose --env-file .env.docker build <service>
-
Start test:
docker compose --env-file .env.docker up -d <service> docker compose --env-file .env.docker ps
-
Functionality test:
docker compose --env-file .env.docker exec <service> php -v docker compose --env-file .env.docker exec <service> php -m | grep <extension>
- All changes trigger GitHub Actions workflows
- Tests run for PHP 8.2, 8.3, 8.4
- Ensure builds pass before merging
- Xdebug should NEVER be enabled in production
- Always use trigger mode, never autostart
- Document security implications
- Never commit
.env.dockerfiles - this is a local configuration file that may contain sensitive data - Add
.env.dockerto.gitignoreto prevent accidental commits - Use
.env.exampleas the committed template for users to copy and modify - Use environment variables for sensitive data
- Document required secrets in
.env.example
- Run as non-root user where possible
- Keep base images updated
- Minimize installed packages
Order Dockerfile commands from least to most frequently changing:
# 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- Use build arguments for configurability
- Cache builds with different argument values
- Document all build arguments
When changing functionality, update README.md:
- Quick Start - If setup process changes
- Configuration - If new env vars added
- Troubleshooting - If new issues arise
- Examples - If new features added
Use comments for:
- Complex conditional logic
- Version-specific workarounds
- Security considerations
- Performance optimizations
# 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- Don't change default values without considering existing users
- Maintain backward compatibility
- Version breaking changes appropriately
- Always test builds completely
- Address all warnings, especially Xdebug connection warnings
- Clean build output is important
- Test on Linux, macOS, and Windows when possible
- Use cross-platform path separators
- Document platform-specific considerations
- Don't assume latest PHP version features
- Support the full range of declared PHP versions
- Test edge cases (oldest and newest versions)
Format: <type>: <short description>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesrefactor: Code refactoringtest: Test additions/changeschore: Maintenance tasks
Examples:
fix: Resolve Xdebug connection warnings during build
docs: Add Xdebug trigger mode documentation
feat: Add Redis container support
- Title: Clear, descriptive
- Description: Explain the change and why
- Testing: Describe testing performed
- Breaking Changes: List any breaking changes
- Screenshots: For UI/output changes
When using GitHub Copilot or similar tools:
- Review all suggestions - Don't blindly accept
- Understand the code - Know what you're committing
- Test thoroughly - AI can miss edge cases
- Document decisions - Explain non-obvious choices
- Security first - Verify security implications
- 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