From 33c5a4b9a4d291107690ef2f27fabd4dc13646b9 Mon Sep 17 00:00:00 2001 From: Matt Austin Date: Thu, 16 May 2024 19:10:03 -0700 Subject: [PATCH] Docker run (#50) * Added entrypoint to docker image. * Added information about running in docker. * Fix sonar issue * Fix sonar redirect complaint * Clean up docker image a bit --- README.md | 9 +++++++++ docker/Dockerfile | 20 ++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e0072e4..67f2b9c 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,15 @@ To simply scan some code and see possible changes to make: pixee fix /my/project/directory/ ``` +## Docker Usage + +Pixee can also be run in a Docker container. This is useful if you want to run Pixee on an oerating system that does not support brew, or a CI/CD pipeline or in a containerized environment. + +``` +docker run --rm -it -v "${PWD}:/src" codemodder/pixee-cli fix /src + +``` + ## F.A.Q. ### What languages are supported for fixes? diff --git a/docker/Dockerfile b/docker/Dockerfile index fee4774..4a80808 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,21 +1,17 @@ FROM python:3.11-rc-bullseye WORKDIR /pixee -RUN apt-get update +ENV CODEMODDER_JAVA_VERSION=0.75.1 -# Install Python 3, pip and wget -RUN apt-get install -y wget unzip openjdk-17-jre - -RUN ln -s /usr/bin/python3 /usr/bin/python && \ - java -version && \ - python --version && \ - python3 -m pip install semgrep==1.15.0 && \ - python3 -m pip install codemodder - -RUN wget https://github.com/pixee/codemodder-java/releases/download/v0.72.2/codemodder-java-codemods-0.72.2.zip -RUN unzip codemodder-java-codemods-0.72.2.zip +RUN apt-get update && apt-get --no-install-recommends install -y wget unzip openjdk-17-jre && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN wget --max-redirect=1 "https://github.com/pixee/codemodder-java/releases/download/v${CODEMODDER_JAVA_VERSION}/codemodder-java-codemods-${CODEMODDER_JAVA_VERSION}.zip" +RUN unzip codemodder-java-codemods-*.zip && rm codemodder-java-codemods-*.zip RUN python3 -m pip install pixee COPY bin ./bin ENV PATH="${PATH}:/pixee/bin" + +WORKDIR /src + +ENTRYPOINT ["pixee"]