Skip to content

Commit

Permalink
First version of Dockerizing the chat app
Browse files Browse the repository at this point in the history
Close #3
  • Loading branch information
JKrag committed Feb 17, 2021
1 parent 00f31d2 commit 042d5fa
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* 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 [email protected]:JKrag/demo.git -e "[email protected]" -n "Whale Hail"
```
40 changes: 40 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

usage() {
echo "Usage: $0 -r <REPOSITORY> -e <user.email> -n <user.name>"
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 <me@localhost> -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

0 comments on commit 042d5fa

Please sign in to comment.