diff --git a/.gitignore b/.gitignore index 987e2a2..bf12543 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ composer.lock vendor +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5c59056 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM composer AS composer + +WORKDIR /app + +COPY composer.json . + +RUN composer install \ + --ignore-platform-reqs \ + --no-interaction \ + --no-plugins \ + --no-scripts \ + --prefer-dist + +# Final PHP Image +FROM php:7.2-alpine + +WORKDIR /obfuscator + +COPY ./ ./ +COPY --from=composer /app/vendor/ /obfuscator/vendor/ + +ENV PATH="/obfuscator/bin:${PATH}" + +ENTRYPOINT ["php", "/obfuscator/bin/obfuscate", "obfuscate"] \ No newline at end of file diff --git a/README.md b/README.md index ae70563..c7360af 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,26 @@ You can run the obfuscator with a configuration file through ```bash ./bin/obfuscate obfuscate /input/directory /output/directory --config=/foo/bar/config.yml ``` + +### Dockerized Version + +You can use the Docker image to obfuscate your code +```bash +docker run --rm -it -v ./source:/code lion2486/naneau-php-obfuscator /code +``` + +Or you can use the image to integrate it in your docker build pipeline using multi-stage build. + +1. Add the obfuscator stage as below: +``` +FROM lion2486/naneau-php-obfuscator AS obfuscator + +COPY . /code + +RUN php bin/obfuscate obfuscate /code +``` + +2. Copy your sources from the previous image like below: +``` +COPY --from=obfuscator /code /var/www +```