From 042d5fa4aefae2648bcc454ad713e92038e3fe4c Mon Sep 17 00:00:00 2001 From: Jan Krag Date: Wed, 17 Feb 2021 22:45:18 +0100 Subject: [PATCH] First version of Dockerizing the chat app Close #3 --- Dockerfile | 11 +++++++++++ README.md | 19 ++++++++++++++++++- entrypoint.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d889efa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM bitnami/git:latest +RUN install_packages less +RUN mkdir /slick +COPY entrypoint.sh /slick + +RUN chmod +x /slick/entrypoint.sh + +COPY chat.sh /slick +WORKDIR /slick +ENTRYPOINT ["./entrypoint.sh"] + diff --git a/README.md b/README.md index d492531..8c84c1d 100644 --- a/README.md +++ b/README.md @@ -56,4 +56,21 @@ Maybe slightly in order of importance - but not necessarily order of implementat * [Private message support, just for the fun of it](https://github.com/JKrag/GitSlick/issues/4) * [Support running in split-screen terminal](https://github.com/JKrag/GitSlick/issues/5) * [Add a run-mode where chat takes place under the hood in an existing repo](https://github.com/JKrag/GitSlick/issues/6) -* I had the idea that it might be a good idea with a small safety check to avoid running chat.sh in the wrong repo. My initial thought was that it could be as simple as checking for the existance of a possibly empty `.gitslick` file in the root of the repo, and aborting f this doesn't exist. But writing this, I realise that it would either have to be an untracked file, or it would have to be copied over and added to each new branch. maybe it could look for this file in the .git folder? More thinking needed. \ No newline at end of file +* I had the idea that it might be a good idea with a small safety check to avoid running chat.sh in the wrong repo. My initial thought was that it could be as simple as checking for the existance of a possibly empty `.gitslick` file in the root of the repo, and aborting f this doesn't exist. But writing this, I realise that it would either have to be an untracked file, or it would have to be copied over and added to each new branch. maybe it could look for this file in the .git folder? More thinking needed. + +## Docker + +In case you want chat without cloning the chat repo locally, and without leaving too many traces on your computer, +you acn run the whoe thing in Docker. + +### Build image + +``` +docker to build -t gitslick . +``` + +### Run image + +``` +docker run -it -v ~/.ssh:/tmp/.ssh:ro gitslick -r git@github.com:JKrag/demo.git -e "jankrag@gmail.com" -n "Whale Hail" +``` diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..9042e8c --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +usage() { + echo "Usage: $0 -r -e -n " + echo "Usage: $0 -h" + echo "Note: REPOSITORY is the remote repo that you use to keep your GitSlick chat history" + echo + echo "Example: $0 -r https://github.com/JKrag/MySlick -e -n \"My name\"" + exit 1; +} + +while getopts r:e:n:h option; do + case "${option}" + in + r) REPOSITORY=${OPTARG};; + e) EMAIL=${OPTARG};; + n) NAME=${OPTARG};; + h) usage;; + *) usage;; + esac +done + + +# To be Windows compatible, we volume mount ssh keys to /tmp/.ssh and move them here +# instead of mounting directly to ~/.ssh. For more info see: +# https://nickjanetakis.com/blog/docker-tip-56-volume-mounting-ssh-keys-into-a-docker-container +cp -R /tmp/.ssh /root/.ssh +chmod 700 /root/.ssh +chmod 644 /root/.ssh/id_rsa.pub +chmod 600 /root/.ssh/id_rsa + +git config --global user.name "$NAME" +git config --global user.email "$EMAIL" +#git config core.sshCommand 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' +git config --global core.sshCommand 'ssh -o StrictHostKeyChecking=no' + +#echo "CHAT REPO: $REPOSITORY" +git clone -q "$REPOSITORY" chat +cd chat || exit +../chat.sh