Skip to content

Commit

Permalink
Merge pull request #2290 from snyk/revert/docker-monitor
Browse files Browse the repository at this point in the history
revert: partial revert of Dockerfile changes from #2091
  • Loading branch information
JackuB authored Sep 30, 2021
2 parents 83d8a19 + 475e437 commit a4b3963
Show file tree
Hide file tree
Showing 18 changed files with 57 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile.docker
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update && \
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
apt-get update && apt-get install -y docker-ce && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.gradle-2.8
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN apt-get update && \
unzip gradle-2.8-bin.zip -d /home/node/ &&\
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.gradle-4.4
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN apt-get update && \
unzip gradle-4.4-bin.zip -d /home/node/ && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.gradle-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN apt-get update && \
unzip gradle-5.4-bin.zip -d /home/node/ && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.gradle-5.4_java11
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt-get update && \
apt-get install -y nodejs && \
node -v && \
npm -v && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.maven-3.5.4
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update && \
rm -f apache-maven-3.5.4-bin.tar.gz && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.maven-3.6.3
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update && \
rm -f apache-maven-3.6.3-bin.tar.gz && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.maven-3.6.3_java11
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update && \
rm -f apache-maven-3.6.3-bin.tar.gz && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.npm_ruby
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENV HOME /home/node
# Install snyk cli and clean up
RUN apt-get update && \
apt-get install -y git && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.python-2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN pip install pip pipenv virtualenv -U && \
apt-get install -y build-essential curl git && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.python-3
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN pip install pip pipenv virtualenv -U && \
apt-get install -y build-essential curl git && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.python-3.6
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN pip install pip pipenv virtualenv -U && \
apt-get install -y build-essential curl git && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.python-3.8
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN pip install pip pipenv virtualenv -U && \
apt-get install -y build-essential curl git && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.python-3.9
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN pip install pip pipenv virtualenv -U && \
apt-get install -y build-essential curl git && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.sbt-0.13.16
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN apt-get update && \
echo "-sbt-version 0.13.16" >> /etc/sbt/sbtopts && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.sbt-1.0.4
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apt-get update && \
echo "addCommandAlias(\"dependency-tree\", \"dependencyTree\")" >> /home/node/.sbt/1.0/user.sbt && \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs && \
npm install --global snyk && \
npm install --global snyk snyk-to-html && \
apt-get autoremove -y && \
apt-get clean && \
chmod -R a+wrx /home/node
Expand Down
38 changes: 38 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash

OUTPUT_FILE=snyk-result.json
MONITOR_OUTPUT_FILE=snyk-monitor-result.json
ERROR_FILE=snyk-error.log
HTML_FILE=snyk_report.html
SNYK_COMMAND="$1"
SNYK_PARAMS="${@:2}"
ADDITIONAL_ENV=""
Expand Down Expand Up @@ -36,6 +38,25 @@ exitWithMsg() {
exit "$2"
}

TEST_SETTINGS=""
PROJECT_SUBDIR=""

if [ -n "${TARGET_FILE}" ]; then
if [ ! -f "${PROJECT_PATH}/${PROJECT_FOLDER}/${TARGET_FILE}" ]; then
exitWithMsg "\"${PROJECT_PATH}/${PROJECT_FOLDER}/${TARGET_FILE}\" does not exist" 2
fi

PROJECT_SUBDIR=$(dirname "${TARGET_FILE}")
MANIFEST_NAME=$(basename "${TARGET_FILE}")
TEST_SETTINGS="--file=${MANIFEST_NAME} "
fi

if [ -n "${ORGANIZATION}" ]; then
TEST_SETTINGS="${TEST_SETTINGS} --org=${ORGANIZATION}"
fi

SNYK_PARAMS="${SNYK_PARAMS} ${TEST_SETTINGS}"

if [ -z "${SNYK_TOKEN}" ]; then
exitWithMsg "Missing \${SNYK_TOKEN}" 2
fi
Expand All @@ -55,3 +76,20 @@ RC=$?
if [ "$RC" -ne "0" ] && [ "$RC" -ne "1" ]; then
exitWithMsg "${OUTPUT_FILE}" "$RC"
fi

runCmdAsDockerUser "touch \"${PROJECT_PATH}/${PROJECT_FOLDER}/${HTML_FILE}\""

if [ -n "$MONITOR" ]; then
echo "Monitoring & generating report ..."
runCmdAsDockerUser "PATH=$PATH snyk monitor --json ${SNYK_PARAMS} ${ADDITIONAL_ENV} > ${MONITOR_OUTPUT_FILE} 2>$ERROR_FILE"
fi

runCmdAsDockerUser "cat \"${OUTPUT_FILE}\" | snyk-to-html >> \"${PROJECT_PATH}/${PROJECT_FOLDER}/${HTML_FILE}\""

if [ $RC -ne "0" ]; then
exitWithMsg "${OUTPUT_FILE}" "$RC"
fi

cat "${OUTPUT_FILE}"

exit "$RC"
3 changes: 3 additions & 0 deletions docker/docker-python-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ installPipfileDeps() {
popd
}

PROJECT_SUBDIR=""
echo "Project path = ${PROJECT_PATH}"
if [ -n "${TARGET_FILE}" ]; then
if [ ! -f "${PROJECT_PATH}/${PROJECT_FOLDER}/${TARGET_FILE}" ]; then
exitWithMsg "\"${PROJECT_PATH}/${PROJECT_FOLDER}/${TARGET_FILE}\" does not exist" 2
fi

PROJECT_SUBDIR=$(dirname "${TARGET_FILE}")
MANIFEST_NAME=$(basename "${TARGET_FILE}")
TEST_SETTINGS="--file=${MANIFEST_NAME} "

echo "Target file = ${TARGET_FILE}"

Expand Down

0 comments on commit a4b3963

Please sign in to comment.