diff --git a/Dockerfile b/Dockerfile index 21a04e5..9ed195e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,15 +18,19 @@ ARG GITUSER=gogs ENV GITUSER=${GITUSER} ARG GITPASSWD=gogspw ENV GITPASSWD=${GITPASSWD} +ARG LOCALUSER=swsuser +ENV LOCALUSER=${LOCALUSER} +ARG LOCALGROUP=swsgroup +ENV LOCALGROUP=${LOCALGROUP} # ssh forwarding dosen't work, no --secret option is working #ARG GITCLONEURL=ssh://gogs@${GITSERVER}:${GITSERVERPORT}/${GITPROJECTUSER}/${GITPROJECTNAME}.git # https://gogs.serinty.net/Serinty/serinty-website.git #RUN --mount=type=secret,id=gogsserintywebsitepw GITPASSWD=$(cat /run/secrets/gogsserintywebsitepw)\ # && export GITPASSWD -ARG GITCLONEURL=https://${GITUSER}:${GITPASSWD}@${GITSERVER}:${GITSERVERPORT}/${GITPROJECTUSER}/${GITPROJECTNAME}.git -ENV GITCLONEURL=${GITCLONEURL} -RUN git config --global http.sslverify "false" -RUN git clone "${GITCLONEURL}" +#ARG GITCLONEURL=https://${GITUSER}:${GITPASSWD}@${GITSERVER}:${GITSERVERPORT}/${GITPROJECTUSER}/${GITPROJECTNAME}.git +#ENV GITCLONEURL=${GITCLONEURL} +#RUN git config --global http.sslverify "false" +#RUN git clone "${GITCLONEURL}" #RUN mkdir -p -m 0700 ~/.ssh && touch -m 600 ~/.ssh/known_hosts && ssh-keyscan -H -4 -t rsa -p ${GITSERVERPORT} ${GITSERVER} >> ~/.ssh/known_hosts #RUN echo "Host *" >> /etc/ssh/ssh_config #RUN echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config @@ -34,5 +38,13 @@ RUN git clone "${GITCLONEURL}" #RUN cat /etc/ssh/ssh_config #RUN --mount=type=ssh ssh-add -L #RUN --mount=type=ssh git clone -v ${GITCLONEURL} -WORKDIR ./${GITPROJECTNAME}/ -RUN zola build --output-dir /public_html +#WORKDIR ./${GITPROJECTNAME}/ +#RUN zola build --output-dir /public_html +RUN groupadd -g 1000 swsgroup \ + && useradd -r -u 1000 -g swsgroup ${LOCALUSER} +COPY ./git2zola.sh /home/${LOCALUSER}/.bin/git2zola.sh +USER ${LOCALUSER} +WORKDIR /home/${LOCALUSER} +RUN mkdir public && ssh-keyscan -q + +ENTRYPONT ['/home/${LOCALUSER}/.bin/git2zola.sh'] diff --git a/git2zola.sh b/git2zola.sh index d6222d3..4758d37 100755 --- a/git2zola.sh +++ b/git2zola.sh @@ -5,6 +5,17 @@ # - with https user login ( problrm with TLS error with own gogs # - with auth token (not implemented in gogs yet) +#default sws docker path +OUTPUT_DIR='/public' +BASE_URL='docker.local' +GITPROJECTNAME=serinty-website +GITPROJECTUSER=Serinty +GITSERVER=gogs.serinty.net +GITSERVERPORT=22104 +GITUSER=gogs +GITPASSWD=gogspw + + if [ -z $IDLE_TIME ] then # one day @@ -23,7 +34,12 @@ do git clone ${GITCLONEURL} elif [ ${gitstatus} -eq 0 ] then - git pull + gitpull=$(git pull --dry-run --ff-only) + if [ ! -z ${gitpull} ] + then + git pull --ff-only + zola build --base-url $BASE_URL --output-dir $OUTPUT_DIR + fi fi sleep ${IDLE_TIME}