Skip to content

Commit 9ec2d06

Browse files
authored
Merge pull request #2 from stakater-docker/debug
fix user access issue
2 parents 9c16f2d + c21eaec commit 9ec2d06

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ FROM debian:stretch
22

33
RUN apt-get update && apt-get install -y git
44

5+
ARG USER=1001
6+
7+
ADD [--chown=$USER:root] init.sh /
8+
RUN chmod +x /init.sh
9+
10+
USER root
11+
512
RUN mkdir /root/.ssh/ && \
613
mkdir /repository && \
714
touch /root/.ssh/known_hosts && \
815
echo "\nStrictHostKeyChecking no" >> /etc/ssh/ssh_config
916

10-
ADD init.sh /
11-
RUN chmod +x /init.sh
17+
RUN chgrp -R 0 /root && \
18+
chmod -R g=u /root
1219

1320
# Clean up
1421
RUN apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ It is also required to mount a volume where the repository will be cloned from l
1818
In case of private repositories you also have to mount deployment SSH key authorized to clone code repository
1919

2020
### optional
21-
`TAG` - clone specified tag
21+
`REPO_TAG` - checkout specified tag
2222

23-
`BRANCH` - clone specified branch (defaults to master)
23+
`REPO_REVISION` - checkout specified revision
24+
25+
`REPO_BRANCH` - clone specified branch (defaults to master)
2426

2527
`REPO_KEY` - RSA key filename (defaults to id_rsa)
2628

init.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ fi
1515

1616
echo "repository : $REPO_LINK"
1717
echo "branch : $REPO_BRANCH"
18+
echo "tag : $REPO_TAG"
19+
echo "revision : $REPO_REVISION"
1820
# check if credentials files exist
1921
if [[ -f "/key/$REPO_KEY" ]] ; then
2022
echo "key file : $REPO_KEY"
@@ -27,12 +29,14 @@ if [ ! -z "$REPO_USER" ] && [ ! -z "$REPO_PASS" ]; then
2729
# clone with repository username & password
2830
echo "credentials: username and password"
2931
git clone -b $REPO_BRANCH https://$REPO_USER:$REPO_PASS@$REPO_LINK /repository
30-
elif [[ ! -f "/root/.ssh/id_rsa" ]] ; then
31-
echo -e "\033[1;91mERROR:\033[0m REPO_USER, REPO_PASS env variables or SSH deployment key missing"
32-
exit 1
3332
else
34-
# clone public repository or using ssh deployment key
35-
echo "credentials: RSA key"
33+
if [[ ! -f "/root/.ssh/id_rsa" ]] ; then
34+
echo -e "\033[1;93mWARNING:\033[0m REPO_USER, REPO_PASS env variables or SSH deployment key missing"
35+
else
36+
# clone public repository or using ssh deployment key
37+
echo "credentials: RSA key"
38+
fi
39+
ls -lah /repository
3640
git clone -b $REPO_BRANCH $REPO_LINK /repository
3741
fi
3842

@@ -42,3 +46,8 @@ if [ ! -z "$REPO_TAG" ]; then
4246
git checkout tags/$REPO_TAG
4347
fi
4448

49+
if [ ! -z "$REPO_REVISION" ]; then
50+
cd /repository && \
51+
echo "checking out repository revision: $REPO_REVISION"
52+
git checkout $REPO_REVISION
53+
fi

0 commit comments

Comments
 (0)