diff --git a/Dockerfile b/Dockerfile index 13ec7b7..e247f37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM quay.io/flozanorht/flamel:0.3-7 as pre-commit +FROM quay.io/redhattraining/flamel as pre-commit RUN curl https://pre-commit.com/install-local.py | python - & \ ln -s /root/bin/pre-commit /usr/bin/pre-commit & \ - dnf install -y perl ruby + dnf install -y perl ruby rubygems FROM pre-commit diff --git a/README.md b/README.md index aecbcf9..8ee1a86 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,28 @@ -Docker image for running GLS pre-commit hooks. +# Pre commit image -Usage: -Just run "pre-commit.sh" or alias it to "pre-commit" in your system. +Docker image for running GLS pre-commit hooks. You can just run "pre-commit.sh", symlink or alias it to "pre-commit" in your system. -If your SSH configuration or your pre-commit cache is not in the default locations, update the appropriate variables in the "pre-commit.sh" script file as needed. \ No newline at end of file +### Installation + +Clone this repository: + +```sh + +git clone git@github.com:jramcast/pre-commit-image.git +``` + +Go to `/usr/bin` or any other folder in your PATH and create a symlink to `pre-commit.sh`. +Change REPO_CLONE_PATH with the actual directory where you cloned the repo: + +```sh +ln -s REPO_CLONE_PATH/pre-commit.sh pre-commit-docker +```` + +If your SSH configuration or your pre-commit cache is not in the default locations, update the appropriate variables in the "pre-commit.sh" script file as needed. + +To run the script, go to any course root directory and execute `pre-commit-docker`: + +``` +cd $COURSE_DIR +pre-commit-docker +``` diff --git a/pre-commit.sh b/pre-commit.sh index 2f10eea..47bb95b 100755 --- a/pre-commit.sh +++ b/pre-commit.sh @@ -1,18 +1,24 @@ #! /bin/sh -image=quay.io/someth2say/pre-commit:0.1.0 +image=pre-commit-docker book=$(pwd) container_book=/tmp/coursebook +this_file=$(python -c "import os; print(os.path.realpath('$BASH_SOURCE'))") +this_dir=$( cd -P "$( dirname $this_file )" && pwd ) + ssh_cfg=~/.ssh container_ssh_cfg=/root/.ssh pcommit_cache=~/.cache/pre-commit -containe_pcommit_cache=/root/.cache/pre-commit +container_pcommit_cache=/root/.cache/pre-commit + +# Force image rebuild to always grab the latest flamel version +docker build -t $image $this_dir docker run \ -v ${ssh_cfg}:${container_ssh_cfg} \ - -v ${pcommit_cache}:${containe_pcommit_cache}:z \ + -v ${pcommit_cache}:${container_pcommit_cache}:z \ -v ${book}:${container_book}:z \ ${image} $@