Skip to content

Instantly share code, notes, and snippets.

View sjeandeaux's full-sized avatar
👤

Stephane Jeandeaux sjeandeaux

👤
View GitHub Profile
@sjeandeaux
sjeandeaux / docker-proxy.sh
Last active August 29, 2015 14:19
Proxy and Dockerfile
#!/bin/bash
#Verify http_proxy if presents used else ping google.com
docker-proxy-in() {
if [ -z "$http_proxy" ] && ping -c 1 google.com > /dev/null ; then
cat ${1:-Dockerfile}
else
sed -e "/FROM/a\\
\\
ENV http_proxy=\"$http_proxy\" https_proxy=\"$https_proxy\" ftp_proxy=\"$ftp_proxy\" no_proxy=\"$no_proxy\"
@sjeandeaux
sjeandeaux / unset_proxy.sh
Last active August 29, 2015 14:19
unset_proxy
#configuration.
unset proxy
unset proxy_port
unset proxy_user
unset proxy_password
unset proxy_password_encoding
unset use_proxy
@sjeandeaux
sjeandeaux / proxy_template.sh
Last active January 24, 2017 10:31
proxy_template
#configuration.
export proxy=$1
export proxy_port=$2
export proxy_user=$3
export proxy_password=$4
export proxy_password_encoding=$5
export no_proxy=$6,/var/run/docker.sock
@sjeandeaux
sjeandeaux / docker.mk
Last active August 29, 2015 14:22
Docker and Makefile
#
# You need to define
# tag
# littleName
# environment
# publish
# registry
registry=
current_dir = $(shell pwd)
bigTag=$(registry)$(tag)

log4j.properties

# Root logger option
log4j.rootLogger=ERROR, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
#!/bin/sh
git stash -q --keep-index
###############################################################
#
# your command e.g : sbt clean compile
#
###############################################################
RESULT=$?
@sjeandeaux
sjeandeaux / IsUp.scala
Created February 2, 2016 15:51
Verify socket with scala
object IsUp {
class RetryException(msg: String, exception: Throwable) extends Exception(msg, exception)
def socket(host: String, port: Int, nb: Int = 10, time: Long = 1000): Unit = {
retry(nb, time) {
val socket = new Socket()
try {
socket.connect(new InetSocketAddress(host, port));
} finally {
@sjeandeaux
sjeandeaux / ivy-clear.sh
Last active March 17, 2016 07:37
Clear ivy dependencies
#!/bin/bash
if [[ $2 == "rm" ]]
then
echo "RM"
find ~/.ivy2/ -type f -name "$1*" -exec rm -rvf {} \;
else
find ~/.ivy2/ -type f -name "$1*"
fi
@sjeandeaux
sjeandeaux / docker-clear.sh
Created April 19, 2017 08:55
clear docker volume, image, network, container
sudo docker rm -f $(eval sudo docker ps -aq)
sudo docker volume rm $(eval sudo docker volume ls -qf dangling=true)
sudo docker rmi -f $(eval sudo docker images -f "dangling=true" -q)
sudo docker network inspect $(sudo docker network ls -q --filter driver=bridge) | jq ".[] | select (.Name != \"bridge\" and (.Containers | length == 0)) | .Name" | xargs sudo docker network rm
@sjeandeaux
sjeandeaux / migration.sh
Created June 13, 2017 07:02
Transfer your images docker from registry v1 to registry v2
#!/bin/bash
# No verification but we need:
# - to be able to run docker command
# - we use jq (https://stedolan.github.io/jq/manual/)
# Transfer image to docker registry v1 to docker registry v2
# TODO manage parameters
# TODO manage insecure (actually curl -k)
# TODO manage pagination
# TODO manage namespace "library/"