Skip to content

Commit

Permalink
Fix run.sh Prevent stuck on initial clone error
Browse files Browse the repository at this point in the history
by adding clone to while loop

Closes #7
  • Loading branch information
elmariofredo committed Nov 15, 2018
1 parent 230f120 commit 773b377
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
FROM alpine:3.8

RUN apk add --no-cache git openssh curl

RUN curl -L https://storage.googleapis.com/kubernetes-release/release/v1.11.1/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl && \
chmod +x /usr/local/bin/kubectl
RUN apk add --no-cache git openssh

ADD https://storage.googleapis.com/kubernetes-release/release/v1.11.1/bin/linux/amd64/kubectl /usr/local/bin/kubectl
RUN chmod +x /usr/local/bin/kubectl

ADD run.sh /

Expand Down
26 changes: 18 additions & 8 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ function exec_log {
log "$EXIT" "$(echo $OUTPUT | tr '\n' '|')" "${1}"
}

log "0" "Cloning git repo '${GIT_REPO}' to '${TMP_FOLDER}'"
exec_log "git clone --verbose --depth=1 ${GIT_REPO} ${TMP_FOLDER}"

if [ -n "${TARGET_NAMESPACE}" ]
then

Expand All @@ -36,12 +33,25 @@ fi
while true
do

log "0" "Pulling git repo '${GIT_REPO}' to '${TMP_FOLDER}'"
cd ${TMP_FOLDER} && exec_log "git pull --verbose --update-shallow"
if [ ! -d "$TMP_FOLDER" ]
then

log "0" "Cloning git repo '${GIT_REPO}' to '${TMP_FOLDER}'"
exec_log "git clone --verbose --depth=1 ${GIT_REPO} ${TMP_FOLDER}"

fi

if [ ! -z "$(ls -A ${TMP_FOLDER})" ]
then

log "0" "Pulling git repo '${GIT_REPO}' to '${TMP_FOLDER}'"
cd ${TMP_FOLDER} && exec_log "git pull --verbose --update-shallow"

log "0" "Applying '${GIT_REPO}' repo against '${TARGET_NAMESPACE}' namespace"
exec_log "kubectl apply ${KUBE_ATTRS} -R --filename=${TMP_FOLDER}"

fi

log "0" "Applying '${GIT_REPO}' repo against '${TARGET_NAMESPACE}' namespace"
exec_log "kubectl apply ${KUBE_ATTRS} -R --filename=${TMP_FOLDER}"

log "0" "Sleep for ${INTERVAL_SECONDS} seconds"
sleep $INTERVAL_SECONDS

Expand Down

0 comments on commit 773b377

Please sign in to comment.