Skip to content

Instantly share code, notes, and snippets.

@Filirom1
Last active April 27, 2020 17:42
Show Gist options
  • Save Filirom1/68acd74df00fa6419cd116862e02ccdc to your computer and use it in GitHub Desktop.
Save Filirom1/68acd74df00fa6419cd116862e02ccdc to your computer and use it in GitHub Desktop.
Build anything
#!/usr/bin/env
docker run --interactive --tty --rm --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate engines:install
docker run --interactive --tty --rm --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f text
#!/bin/bash
set -e
docker run --volume "$PWD:/code" "registry.gitlab.com/gitlab-org/security-products/license-management" analyze /code
IMAGE_NAME=$1
if [ ! -f s2i ]; then
echo "Download S2I"
curl -L -o s2i.tar.gz "https://github.com/openshift/source-to-image/releases/download/v1.1.10/source-to-image-v1.1.10-27f0729d-linux-amd64.tar.gz"
tar xvzf s2i.tar.gz
rm -f s2i.tar.gz
fi
if [ -n "$S2I_IMAGE" ]; then
echo "Custom s2i image detected: $S2I_IMAGE"
s2i $S2I_IMAGE
fi
if [ -f package.json ]; then
echo "NodeJS Detected"
s2i centos/nodejs-8-centos7
fi
if [ -f pom.xml ]; then
echo "Java Detected"
s2i registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift
fi
if [ -f Gemfile ]; then
echo "Ruby Detected"
s2i centos/ruby-22-centos7
fi
if [ -f setup.py ]; then
echo "Python Detected"
s2i centos/python-35-centos7
fi
if [ -f *.php ]; then
echo "PHP Detected"
s2i openshift/php-56-centos7
fi
if [ -f Dockerfile ]; then
echo "Python Detected"
docker build -t $IMAGE_NAME
exit
fi
function s2i(){
./s2i build . $1 $IMAGE_NAME
exit
}
#!/bin/bash
IMAGE_NAME=$1
docker run -d --name db arminc/clair-db:latest
docker run -p 6060:6060 --link db:postgres -d --name clair --restart on-failure arminc/clair-local-scan:v2.0.1
wget https://github.com/arminc/clair-scanner/releases/download/v8/clair-scanner_linux_amd64
mv clair-scanner_linux_amd64 clair-scanner
chmod +x clair-scanner
touch clair-whitelist.yml
retries=0
echo "Waiting for clair daemon to start"
while( ! wget -T 10 -q -O /dev/null http://localhost:6060/v1/namespaces ) ; do sleep 1 ; echo -n "." ; if [ $retries -eq 10 ] ; then echo " Timeout, aborting." ; exit 1 ; fi ; retries=$(($retries+1)) ; done
./clair-scanner -c http://localhost:6060 --ip $(hostname -i) -r gl-container-scanning-report.json -l clair.log -w clair-whitelist.yml $IMAGE_NAME || true
#!/bin/bash
set -e
docker run --env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}" --volume "$PWD:/code" --volume /var/run/docker.sock:/var/run/docker.sock "registry.gitlab.com/gitlab-org/security-products/sast:11-0-stable" /app/bin/run /code
#!/bin/bash
set -e
IMAGE_NAME=$1
if [ -f package.json ]; then
echo "NodeJS Detected"
docker run --entrypoint="/bin/bash" $IMAGE_NAME -c 'npm install && npm test'
fi
if [ -f pom.xml ]; then
echo "Java Detected"
docker run --entrypoint="/bin/bash" $IMAGE_NAME -c 'mvn test'
fi
if [ -f Rakefile ]; then
echo "Rake Detected"
docker run --entrypoint="/bin/bash" $IMAGE_NAME -c 'bundle install && bundle exec rake test'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment