diff --git a/Dockerfile b/Dockerfile index c8fc22d..912bc83 100755 --- a/Dockerfile +++ b/Dockerfile @@ -57,6 +57,21 @@ RUN composer install --no-dev --no-interaction --prefer-dist # Generate application key RUN php artisan key:generate || true +# Install yakpro-po for code obfuscation +RUN cd /tmp && \ + git clone https://github.com/pk-fr/yakpro-po.git && \ + cd yakpro-po && \ + chmod +x yakpro-po.php + +# Obfuscate application code (app directory only, preserve vendor) +RUN php /tmp/yakpro-po/yakpro-po.php \ + --config-file /var/www/html/yakpro-po.cnf \ + /var/www/html/app \ + -o /var/www/html/app_obfuscated && \ + rm -rf /var/www/html/app && \ + mv /var/www/html/app_obfuscated /var/www/html/app && \ + rm -rf /tmp/yakpro-po + # Run Laravel 5.0 optimization RUN php artisan clear-compiled && php artisan optimize diff --git a/yakpro-po.cnf b/yakpro-po.cnf new file mode 100644 index 0000000..ccd7c1c --- /dev/null +++ b/yakpro-po.cnf @@ -0,0 +1,54 @@ +t_directories = [ + 'app' +]; + +// Directories/files to skip +$conf->t_skip = [ + 'vendor', + 'storage', + 'bootstrap', + 'config', + 'database', + 'public', + 'resources', + 'tests', + '.env', + '.env.example', + 'artisan', + 'server.php' +]; + +// Obfuscation options +$conf->obfuscate_string_literal = false; // Don't obfuscate strings (can break Laravel) +$conf->obfuscate_function_name = true; // Obfuscate function names +$conf->obfuscate_class_name = true; // Obfuscate class names (except Laravel core) +$conf->obfuscate_variable_name = true; // Obfuscate variable names +$conf->obfuscate_property_name = true; // Obfuscate property names +$conf->obfuscate_class_constant_name = true; +$conf->obfuscate_constant_name = true; +$conf->obfuscate_namespace_name = false; // Keep namespaces readable +$conf->obfuscate_label_name = true; + +// Keep Laravel framework methods/classes readable +$conf->t_ignore_constants = ['APP_ENV', 'APP_DEBUG', 'APP_URL', 'APP_KEY']; +$conf->t_ignore_methods = [ + '__construct', '__destruct', '__call', '__get', '__set', + 'boot', 'register', 'handle', 'middleware', 'authorize' +]; + +// Scrambler mode +$conf->scrambler = true; + +// Allow multiple PHP versions +$conf->allow_and_operator = true; + +// Output directory (will be overridden in command) +$conf->t_dir = null; + +return $conf;