Skip to content

Commit a1e4574

Browse files
committed
setup theia git
Signed-off-by: Chris Snow <[email protected]>
1 parent 1dde72e commit a1e4574

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

Dockerfile

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ RUN echo "Installing python modules in system python versions" \
3030
#&& ln -f -s /home/theia/.pyenv/versions/*/bin/isort /bin/
3131

3232
# Setup ssh for git
33-
RUN test -d ~/.ssh || mkdir ~/.ssh \
34-
&& touch ~/.ssh/known_hosts \
35-
&& chown -R theia ~/.ssh \
36-
&& chmod -R 600 ~/.ssh
37-
38-
RUN grep github.com ~/.ssh/known_hosts > /dev/null || echo "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts
33+
RUN test -d /home/theia/.ssh || mkdir /home/theia/.ssh \
34+
&& chmod 700 /home/theia/.ssh \
35+
&& touch /home/theia/.ssh/known_hosts \
36+
&& chmod 644 /home/theia/.ssh/known_hosts \
37+
&& chown -R theia /home/theia/.ssh \
38+
&& echo "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" > /home/theia/.ssh/known_hosts
3939

4040
USER theia
4141
WORKDIR /home/theia

git_env_password.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
echo $GIT_PASS

run_ide.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ if [[ "$(docker images -q $IMG 2> /dev/null)" == "" ]]; then
66
./build_ide.sh
77
fi
88

9+
echo
10+
911
git_vars=1
1012
if [[ -z $GIT_USER ]]; then
1113
echo "GIT_USER variable not found"
@@ -38,6 +40,7 @@ if [[ -z $GIT_COMMITTER_EMAIL ]]; then
3840
fi
3941

4042
if [[ $git_vars == 0 ]]; then
43+
echo
4144
echo "One or more git variables were not set."
4245
echo "You will not be able to commit inside theia."
4346
echo
@@ -51,4 +54,4 @@ if [[ $git_vars == 0 ]]; then
5154
done
5255
fi
5356

54-
docker run -it --init -p 3000:3000 -v "$(pwd):/home/project:cached" -e GIT_USER="$GIT_USER" -e GIT_PASS="$GIT_PASS" -e GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" -e GIT_COMMITTER_NAME="$GIT_COMMITTER_NAME" -e GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" -e GIT_COMMITTER_EMAIL="$GIT_COMMITTER_EMAIL" -e GIT_ASKPASS=/home/project/git_env_password.sh $IMG
57+
docker run --rm -it --init -p 3000:3000 -v "$(pwd):/home/project:cached" -e GIT_USER="$GIT_USER" -e GIT_PASS="$GIT_PASS" -e GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" -e GIT_COMMITTER_NAME="$GIT_COMMITTER_NAME" -e GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" -e GIT_COMMITTER_EMAIL="$GIT_COMMITTER_EMAIL" -e GIT_ASKPASS=/home/project/git_env_password.sh $IMG

theia_git_setup.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
git config credential.https://github.com.username $GIT_USER
4+
5+
git_url=$(git config --get remote.origin.url)
6+
7+
USER=$(echo $git_url | sed 's/.*://' | sed 's/\/.*//')
8+
REPO=$(echo $git_url | sed 's/.*://' | sed 's/.*\///')
9+
10+
if [[ git_url != "https://"** ]];
11+
then
12+
echo "You must use the 'https://github.com/...' git url and not '[email protected]:..'"
13+
echo "you can set this with:"
14+
15+
echo "git remote set-url origin https://github.com/$USER/$REPO"
16+
exit 1
17+
fi

0 commit comments

Comments
 (0)