From 759e256cba6276a2b813ff6dc13db1e940ed8ef1 Mon Sep 17 00:00:00 2001 From: Konstantinos Mavrogiannis Date: Mon, 24 Jun 2019 12:29:18 +0300 Subject: [PATCH 1/3] Dockerfile --- .gitignore | 1 + Dockerfile | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 Dockerfile 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..67df5c3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +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 /app + +COPY ./ ./ +COPY --from=composer /app/vendor/ /app/vendor/ + +ENTRYPOINT ["php", "/app/bin/obfuscate", "obfuscate"] \ No newline at end of file From 9db436364b9870e03ab9ef92d05700ca26205f18 Mon Sep 17 00:00:00 2001 From: Konstantinos Mavrogiannis Date: Mon, 24 Jun 2019 12:49:06 +0300 Subject: [PATCH 2/3] changed default path and exposed ENV PATH, README instructions --- Dockerfile | 8 +++++--- README.md | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 67df5c3..5c59056 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,11 @@ RUN composer install \ # Final PHP Image FROM php:7.2-alpine -WORKDIR /app +WORKDIR /obfuscator COPY ./ ./ -COPY --from=composer /app/vendor/ /app/vendor/ +COPY --from=composer /app/vendor/ /obfuscator/vendor/ + +ENV PATH="/obfuscator/bin:${PATH}" -ENTRYPOINT ["php", "/app/bin/obfuscate", "obfuscate"] \ No newline at end of file +ENTRYPOINT ["php", "/obfuscator/bin/obfuscate", "obfuscate"] \ No newline at end of file diff --git a/README.md b/README.md index ae70563..2882c35 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:/app/code lion2486/naneau-php-obfuscator /app/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 +``` From d56965ee8a29c09d9510fcb150b27bc49313586e Mon Sep 17 00:00:00 2001 From: Konstantinos Mavrogiannis Date: Mon, 24 Jun 2019 12:50:37 +0300 Subject: [PATCH 3/3] Removed relative paths from readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2882c35..c7360af 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ You can run the obfuscator with a configuration file through You can use the Docker image to obfuscate your code ```bash -docker run --rm -it -v ./source:/app/code lion2486/naneau-php-obfuscator /app/code +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.