From c1c99f508781e045d397ae8a1e30fc49d1b558f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Ram=C3=ADrez?= Date: Mon, 18 May 2020 09:56:01 +0200 Subject: [PATCH 1/3] Fixing to use latest flamel image: WIP --- Dockerfile | 4 ++-- pre-commit.sh | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) 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/pre-commit.sh b/pre-commit.sh index 2f10eea..fa72554 100755 --- a/pre-commit.sh +++ b/pre-commit.sh @@ -1,6 +1,7 @@ #! /bin/sh -image=quay.io/someth2say/pre-commit:0.1.0 +#image=quay.io/someth2say/pre-commit:0.1.0 +image=pre-commit-docker book=$(pwd) container_book=/tmp/coursebook @@ -11,6 +12,8 @@ container_ssh_cfg=/root/.ssh pcommit_cache=~/.cache/pre-commit containe_pcommit_cache=/root/.cache/pre-commit +docker build -t $image $HOME/Desarrollo/pre-commit-image + docker run \ -v ${ssh_cfg}:${container_ssh_cfg} \ -v ${pcommit_cache}:${containe_pcommit_cache}:z \ From 6003c7b6ac4faa5a0c03c55306089fe077c94efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Ram=C3=ADrez?= Date: Mon, 18 May 2020 16:13:49 +0200 Subject: [PATCH 2/3] Updated readme --- README.md | 30 ++++++++++++++++++++++++++---- pre-commit.sh | 11 +++++++---- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index aecbcf9..70d27c0 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 fa72554..47bb95b 100755 --- a/pre-commit.sh +++ b/pre-commit.sh @@ -1,21 +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 -docker build -t $image $HOME/Desarrollo/pre-commit-image +# 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} $@ From cff4e8524c64bd8c59821d83707c66526f196e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Ram=C3=ADrez?= Date: Mon, 18 May 2020 16:16:21 +0200 Subject: [PATCH 3/3] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 70d27c0..8ee1a86 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Pre-commit image +# Pre commit image 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.