From 0d5397a9dc7c2d2ea758d479ba0cf4723fe78b1b Mon Sep 17 00:00:00 2001 From: fraoustin Date: Sun, 24 Mar 2019 14:16:09 +0100 Subject: [PATCH 01/82] nginx: user nginx 1.15 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e97fdd0..fcb5046 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:1.13 +FROM nginx:1.15 LABEL maintainer "fraoustin@gmail.com" COPY ./src/default.conf /etc/nginx/conf.d/default.conf From 7e4253483dad765845d256390eab5c384bc10bed Mon Sep 17 00:00:00 2001 From: Youhei Sakurai Date: Mon, 29 Jul 2019 18:59:47 +0900 Subject: [PATCH 02/82] Add mime-support package (/etc/mime.types) to enable mime-wise raw preview --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index fcb5046..f029a48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \ gitweb \ highlight \ libcgi-pm-perl \ + mime-support \ spawn-fcgi \ && rm -rf /var/lib/apt/lists/* From 9661dc6564468f1ffea587e555e8fc6731000fa9 Mon Sep 17 00:00:00 2001 From: fraoustin Date: Wed, 5 Aug 2020 09:20:47 +0200 Subject: [PATCH 03/82] nginx: 1.19 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f029a48..b3ab0d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:1.15 +FROM nginx:1.19 LABEL maintainer "fraoustin@gmail.com" COPY ./src/default.conf /etc/nginx/conf.d/default.conf From e6851ab438905023823e48b758b3e0d2b135aa00 Mon Sep 17 00:00:00 2001 From: fraoustin Date: Sat, 19 Feb 2022 16:58:26 +0000 Subject: [PATCH 04/82] nginx 1.21 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b3ab0d7..a7c57f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:1.19 +FROM nginx:1.21 LABEL maintainer "fraoustin@gmail.com" COPY ./src/default.conf /etc/nginx/conf.d/default.conf From f6d2c106756ccc20fda8dcdcb112f93ab81727d9 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Thu, 9 Jun 2022 12:40:07 +0800 Subject: [PATCH 05/82] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20htpasswd=20=E5=9C=A8?= =?UTF-8?q?=E4=BD=8Elinux=E5=86=85=E6=A0=B8=E7=89=88=E6=9C=AC=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix bug 使用加密 ``` root@50b303640d95:/# htpasswd -nb uu pp > htpasswd: Unable to generate random bytes: Function not implemented ``` 尝试不使用加密 use -p > -p Do not encrypt the password (plaintext, insecure). ``` root@50b303640d95:/# htpasswd -npb uu pp > Warning: storing passwords as plain text might just not work on this platform. uu:pp ``` 测试正常 --- src/cmd/addauth.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cmd/addauth.sh b/src/cmd/addauth.sh index 3e1e905..6079cf2 100644 --- a/src/cmd/addauth.sh +++ b/src/cmd/addauth.sh @@ -13,9 +13,11 @@ usage(){ load(){ if [ ! -f $FPASS ]; then - htpasswd -bc $FPASS $1 $2 - else - htpasswd -b $FPASS $1 $2 + touch $FPASS + fi + htpasswd -b $FPASS $1 $2 + if [ "$?" != 0 ] ; then + htpasswd -bp $FPASS $1 $2 fi } From 8d14ec90715a29c5f21009884c0e4f72b1ee2403 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Thu, 9 Jun 2022 14:16:55 +0800 Subject: [PATCH 06/82] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20htpasswd=20=E6=98=8E?= =?UTF-8?q?=E6=96=87=E5=AF=86=E7=A0=81=E4=B8=8D=E5=8F=AF=E7=94=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 htpasswd 明文密码不可用bug: - `ningx` 在 `Linux` 中使用 `htpasswd`` 明文密码不可用 - 使用 `openssl passwd -apr1` 创建密码 --- src/cmd/addauth.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/addauth.sh b/src/cmd/addauth.sh index 6079cf2..b5381f0 100644 --- a/src/cmd/addauth.sh +++ b/src/cmd/addauth.sh @@ -17,7 +17,8 @@ load(){ fi htpasswd -b $FPASS $1 $2 if [ "$?" != 0 ] ; then - htpasswd -bp $FPASS $1 $2 + htpasswd -D $FPASS $1 + printf "$1:$(openssl passwd -apr1 $2)\n" >> $FPASS fi } From 6c31b12cef91870b25c0cd33d6c7ebef18ad25fc Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sun, 19 Jun 2022 15:16:55 +0800 Subject: [PATCH 07/82] UPDATE DOCKERFILE --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index a7c57f1..2c3e349 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,6 +51,7 @@ RUN cp /usr/share/gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css.o RUN mkdir /usr/share/gitweb/ihm VOLUME /var/lib/git +WORKDIR /var/lib/git EXPOSE 80 ENTRYPOINT ["/entrypoint.sh"] From 43fcd3e6776c5ac23d431b2b4cfd1d62970422e5 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sun, 19 Jun 2022 15:19:37 +0800 Subject: [PATCH 08/82] add description --- src/cmd/addrepos.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmd/addrepos.sh b/src/cmd/addrepos.sh index ca318d4..976bec8 100644 --- a/src/cmd/addrepos.sh +++ b/src/cmd/addrepos.sh @@ -17,6 +17,7 @@ load(){ mkdir $REPOS cd $REPOS git init --bare + echo "$1" > description chmod -R 777 $REPOS fi } From deef0125ece75e9b3b51793ca62142e05ed4476c Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sun, 19 Jun 2022 23:43:08 +0800 Subject: [PATCH 09/82] add docker-compose.yaml --- Dockerfile | 3 +++ docker-compose.yaml | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile index 2c3e349..88775e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,8 +51,11 @@ RUN cp /usr/share/gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css.o RUN mkdir /usr/share/gitweb/ihm VOLUME /var/lib/git + WORKDIR /var/lib/git + EXPOSE 80 ENTRYPOINT ["/entrypoint.sh"] + CMD ["app"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..cef39c8 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,15 @@ +version: "3" + +volumes: + gitweb: + +services: + gitweb: + image: fraoustin/gitweb + build: + context: https://github.com/fraoustin/gitweb.git + dockerfile: Dockerfile + ports: + - 80:80 + volumes: + - gitweb:/var/lib/git \ No newline at end of file From bed5ad951389e8b38eb249cca37e627a492f58d9 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Mon, 20 Jun 2022 01:34:18 +0800 Subject: [PATCH 10/82] add china - docker.cn --- Dockerfile.CN | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Dockerfile.CN diff --git a/Dockerfile.CN b/Dockerfile.CN new file mode 100644 index 0000000..bd0f8f9 --- /dev/null +++ b/Dockerfile.CN @@ -0,0 +1,68 @@ +FROM nginx:1.21 +LABEL maintainer "fraoustin@gmail.com" + +COPY ./src/default.conf /etc/nginx/conf.d/default.conf + +COPY ./src/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENV SET_CONTAINER_TIMEZONE false + +# SET CONTAINER TIMEZONE TO CHINA +ENV TZ "Asia/Shanghai" +ENV CONTAINER_TIMEZONE "Asia/Shanghai" + +# USE CHINA USTC MIRROR +RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list +RUN sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list + +RUN apt-get update && apt-get install -y \ + apache2-utils \ + fcgiwrap \ + git \ + git-core \ + gitweb \ + highlight \ + libcgi-pm-perl \ + mime-support \ + spawn-fcgi \ + && rm -rf /var/lib/apt/lists/* + +# manage user load fcgiwrap +RUN sed -i "s/www-data/nginx/g" /etc/init.d/fcgiwrap + +# manage start container +RUN mkdir /usr/share/gitweb/docker-entrypoint.pre +RUN mkdir /usr/share/gitweb/docker-entrypoint.post +COPY ./src/00_init.sh /usr/share/gitweb/docker-entrypoint.pre/00_init.sh +RUN chmod +x -R /usr/share/gitweb/docker-entrypoint.pre + +# add cmd gitweb +COPY ./src/cmd/addrepos.sh /usr/bin/addrepos +COPY ./src/cmd/addauth.sh /usr/bin/addauth +COPY ./src/cmd/rmrepos.sh /usr/bin/rmrepos +COPY ./src/cmd/rmauth.sh /usr/bin/rmauth +RUN chmod +x /usr/bin/addrepos +RUN chmod +x /usr/bin/addauth +RUN chmod +x /usr/bin/rmrepos +RUN chmod +x /usr/bin/rmauth + +# manage default value +ENV GITUSER gituser +ENV GITPASSWORD gitpassword + +# add ihm mdl +ENV IHM no-mdl +COPY ./src/ihm /mdl-ihm +RUN cp /usr/share/gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css.original +RUN mkdir /usr/share/gitweb/ihm + +VOLUME /var/lib/git + +WORKDIR /var/lib/git + +EXPOSE 80 + +ENTRYPOINT ["/entrypoint.sh"] + +CMD ["app"] From 63b369515ecc648723f0ba1ac15c34b8ac2adf5b Mon Sep 17 00:00:00 2001 From: zctmdc Date: Mon, 20 Jun 2022 01:58:48 +0800 Subject: [PATCH 11/82] add docker-compose-CN.yaml for china --- docker-compose-CN.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docker-compose-CN.yaml diff --git a/docker-compose-CN.yaml b/docker-compose-CN.yaml new file mode 100644 index 0000000..a842d87 --- /dev/null +++ b/docker-compose-CN.yaml @@ -0,0 +1,15 @@ +version: "3" + +volumes: + gitweb: + +services: + gitweb: + image: fraoustin/gitweb + build: + context: https://hub.fastgit.xyz/fraoustin/gitweb.git + dockerfile: Dockerfile.CN + ports: + - 80:80 + volumes: + - gitweb:/var/lib/git \ No newline at end of file From 571a58349c3bde34b79f95d82262da4a41ba6396 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Mon, 20 Jun 2022 02:15:18 +0800 Subject: [PATCH 12/82] build don't use remote --- docker-compose-CN.yaml | 2 +- docker-compose.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose-CN.yaml b/docker-compose-CN.yaml index a842d87..d47b822 100644 --- a/docker-compose-CN.yaml +++ b/docker-compose-CN.yaml @@ -7,7 +7,7 @@ services: gitweb: image: fraoustin/gitweb build: - context: https://hub.fastgit.xyz/fraoustin/gitweb.git + context: . dockerfile: Dockerfile.CN ports: - 80:80 diff --git a/docker-compose.yaml b/docker-compose.yaml index cef39c8..ed1143d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,7 +7,7 @@ services: gitweb: image: fraoustin/gitweb build: - context: https://github.com/fraoustin/gitweb.git + context: . dockerfile: Dockerfile ports: - 80:80 From 84a9f592a08fba7a377248beed4973aea8d58ae4 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Mon, 20 Jun 2022 03:45:41 +0800 Subject: [PATCH 13/82] mor deamo --- Dockerfile.CN | 3 +-- docker-compose-CN.yaml | 8 +++++++- docker-compose.yaml | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Dockerfile.CN b/Dockerfile.CN index bd0f8f9..dfa1939 100644 --- a/Dockerfile.CN +++ b/Dockerfile.CN @@ -8,8 +8,7 @@ RUN chmod +x /entrypoint.sh ENV SET_CONTAINER_TIMEZONE false -# SET CONTAINER TIMEZONE TO CHINA -ENV TZ "Asia/Shanghai" +# USE TIMEZONE TO CHINA ENV CONTAINER_TIMEZONE "Asia/Shanghai" # USE CHINA USTC MIRROR diff --git a/docker-compose-CN.yaml b/docker-compose-CN.yaml index d47b822..9ba480e 100644 --- a/docker-compose-CN.yaml +++ b/docker-compose-CN.yaml @@ -9,7 +9,13 @@ services: build: context: . dockerfile: Dockerfile.CN + environment: + - CONTAINER_TIMEZONE=Asia/Shanghai + - GITUSER=gituser + - GITPASSWORD=gitpassword + - SET_CONTAINER_TIMEZONE=false ports: - 80:80 + restart: always volumes: - - gitweb:/var/lib/git \ No newline at end of file + - gitweb:/var/lib/git diff --git a/docker-compose.yaml b/docker-compose.yaml index ed1143d..b98b403 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,7 +9,13 @@ services: build: context: . dockerfile: Dockerfile + environment: + - CONTAINER_TIMEZONE=Europe/Paris + - GITUSER=gituser + - GITPASSWORD=gitpassword + - SET_CONTAINER_TIMEZONE=false ports: - 80:80 + restart: always volumes: - gitweb:/var/lib/git \ No newline at end of file From b29d168738fdb289fddaefc25514ba99bec7235b Mon Sep 17 00:00:00 2001 From: fraoustin Date: Fri, 1 Jul 2022 12:11:05 +0000 Subject: [PATCH 14/82] new version and nginx 1.23 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2c3e349..197c110 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:1.21 +FROM nginx:1.23 LABEL maintainer "fraoustin@gmail.com" COPY ./src/default.conf /etc/nginx/conf.d/default.conf From f26f7907f48ff3a542f22a6096baa733395217c7 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 12:18:20 +0800 Subject: [PATCH 15/82] add: push to upstream --- Dockerfile | 6 ++++ Dockerfile.CN | 68 ------------------------------------------ docker-compose.yaml | 14 +++++++-- src/cmd/addrepos.sh | 4 ++- src/hooks/post-receive | 42 ++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 72 deletions(-) delete mode 100644 Dockerfile.CN create mode 100644 src/hooks/post-receive diff --git a/Dockerfile b/Dockerfile index 83fd38a..60d204e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,12 @@ COPY ./src/ihm /mdl-ihm RUN cp /usr/share/gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css.original RUN mkdir /usr/share/gitweb/ihm +# force push to upstream +WORKDIR /opt/gitweb/ +COPY ./src/hooks/post-receive /opt/gitweb/post-receive +RUN chmod +x /opt/gitweb/post-receive +ENV FORCEPUSH "" + VOLUME /var/lib/git WORKDIR /var/lib/git diff --git a/Dockerfile.CN b/Dockerfile.CN deleted file mode 100644 index bd0f8f9..0000000 --- a/Dockerfile.CN +++ /dev/null @@ -1,68 +0,0 @@ -FROM nginx:1.21 -LABEL maintainer "fraoustin@gmail.com" - -COPY ./src/default.conf /etc/nginx/conf.d/default.conf - -COPY ./src/entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - -ENV SET_CONTAINER_TIMEZONE false - -# SET CONTAINER TIMEZONE TO CHINA -ENV TZ "Asia/Shanghai" -ENV CONTAINER_TIMEZONE "Asia/Shanghai" - -# USE CHINA USTC MIRROR -RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list -RUN sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list - -RUN apt-get update && apt-get install -y \ - apache2-utils \ - fcgiwrap \ - git \ - git-core \ - gitweb \ - highlight \ - libcgi-pm-perl \ - mime-support \ - spawn-fcgi \ - && rm -rf /var/lib/apt/lists/* - -# manage user load fcgiwrap -RUN sed -i "s/www-data/nginx/g" /etc/init.d/fcgiwrap - -# manage start container -RUN mkdir /usr/share/gitweb/docker-entrypoint.pre -RUN mkdir /usr/share/gitweb/docker-entrypoint.post -COPY ./src/00_init.sh /usr/share/gitweb/docker-entrypoint.pre/00_init.sh -RUN chmod +x -R /usr/share/gitweb/docker-entrypoint.pre - -# add cmd gitweb -COPY ./src/cmd/addrepos.sh /usr/bin/addrepos -COPY ./src/cmd/addauth.sh /usr/bin/addauth -COPY ./src/cmd/rmrepos.sh /usr/bin/rmrepos -COPY ./src/cmd/rmauth.sh /usr/bin/rmauth -RUN chmod +x /usr/bin/addrepos -RUN chmod +x /usr/bin/addauth -RUN chmod +x /usr/bin/rmrepos -RUN chmod +x /usr/bin/rmauth - -# manage default value -ENV GITUSER gituser -ENV GITPASSWORD gitpassword - -# add ihm mdl -ENV IHM no-mdl -COPY ./src/ihm /mdl-ihm -RUN cp /usr/share/gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css.original -RUN mkdir /usr/share/gitweb/ihm - -VOLUME /var/lib/git - -WORKDIR /var/lib/git - -EXPOSE 80 - -ENTRYPOINT ["/entrypoint.sh"] - -CMD ["app"] diff --git a/docker-compose.yaml b/docker-compose.yaml index cef39c8..b13d6d4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,9 +6,17 @@ volumes: services: gitweb: image: fraoustin/gitweb - build: - context: https://github.com/fraoustin/gitweb.git - dockerfile: Dockerfile + container_name: gitweb + hostname: gitweb-test + # build: + # context: https://github.com/fraoustin/gitweb.git + # dockerfile: Dockerfile + environment: + - FORCEPUSH:"" + - CONTAINER_TIMEZONE=Europe/Paris + - GITUSER=gituser + - GITPASSWORD=gitpassword + - GITPROJECT=test ports: - 80:80 volumes: diff --git a/src/cmd/addrepos.sh b/src/cmd/addrepos.sh index 976bec8..dfa5a05 100644 --- a/src/cmd/addrepos.sh +++ b/src/cmd/addrepos.sh @@ -18,7 +18,9 @@ load(){ cd $REPOS git init --bare echo "$1" > description - chmod -R 777 $REPOS + cp /opt/gitweb/post-receive $REPOS/hooks/post-receive + chgrp -R nginx $REPOS + chmod 0755 $REPOS/hooks/post-receive fi } diff --git a/src/hooks/post-receive b/src/hooks/post-receive new file mode 100644 index 0000000..60bd9d7 --- /dev/null +++ b/src/hooks/post-receive @@ -0,0 +1,42 @@ +#!/bin/bash +# 客户端 git push 触发 +# +log_info(){ + echo -e "\033[32m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" +} +log_warn(){ + echo -e "\033[33m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" +} +log_error(){ + echo >&2 -e "\033[31m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" +} +log_run(){ + echo -e "\033[43;34m$@\033[0m" + eval $@ +} + +#判断是不是远端仓库 +IS_BARE=$(git rev-parse --is-bare-repository) +if [ -z "$IS_BARE" ]; then + log_error "fatal: post-receive: IS_NOT_BARE" + exit 1 +fi +log_warn "========================= deploy start =========================" +HOSTNAME="$(hostname)" +log_warn "========================= hostname: ${HOSTNAME}" + +git_push(){ + log_warn "========================= push start" + for remote in $(git remote) + do + log_info "${HOSTNAME} push to ${remote}" + log_run git push "${FORCEPUSH:+ -f}" --all ${remote} + done + log_warn "========================= push end" +} + + +log_info "try run : git_push" +git_push + +log_warn "========================= deploy end =========================" From cfb9125ab1c0c9f092e30ad484019e3d8cdcd459 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 13:45:16 +0800 Subject: [PATCH 16/82] add: add remote and push to upstream when downstream push --- Dockerfile | 6 ++- README.md | 95 ++++++++++++++++++++++++++++++++++++--------- docker-compose.yaml | 5 ++- src/cmd/addrepos.sh | 21 +++++++++- test/remotes.txt | 3 ++ 5 files changed, 105 insertions(+), 25 deletions(-) create mode 100644 test/remotes.txt diff --git a/Dockerfile b/Dockerfile index 60d204e..da19d7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,9 +56,11 @@ COPY ./src/hooks/post-receive /opt/gitweb/post-receive RUN chmod +x /opt/gitweb/post-receive ENV FORCEPUSH "" -VOLUME /var/lib/git +VOLUME /opt/gitweb/remote/ -WORKDIR /var/lib/git +VOLUME /var/lib/git/ + +WORKDIR /var/lib/git/ EXPOSE 80 diff --git a/README.md b/README.md index 4bf9dbc..eacb510 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,12 @@ load when start image load file in - GITUSER (default gituser) - GITPASSWORD (default gitpassword) - IHM (default "") +- FORCEPUSH ("" or every not blank string) manage force push to upstream when Downstream branch push ## Volume -- /var/lib/git +- git project: */var/lib/git/* +- git remove add: */opt/gitweb/remote/* ## Port @@ -34,30 +36,84 @@ load when start image load file in ## Usage direct run image fraoustin/gitweb +```bash + docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITPROJECT=test" \ + -v :/var/lib/git --name test -p 80:80 fraoustin/gitweb +``` +> use ^ for *CMD* OR ` for *Powershell* - docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITPROJECT=test" -v :/var/lib/git --name test -p 80:80 fraoustin/gitweb - -user default is gituser and password default is gitpassword +user default is gituser and password default is gitpassword +- You can change user and password by variable environment you use http://localhost/ for access gitweb +you can add remote +```bash + git remote add origin http://gituser:gitpassword@localhost/test.git +``` +you can push project + +when fist push +```bash + git push --set-upstream origin master +``` +every next time push +```bash + git push +``` +or manual push +```bash + git push origin # remote name +``` you can clone project - +```bash git clone http://gituser:gitpassword@localhost/test.git - -You can change user and password by variable environment - +``` +you can pull project when upstream update +```bash + git pull +``` +more use see: +- https://git-scm.com/doc +- https://www.runoob.com/git/git-tutorial.html + + + +## Add upstream and push + +creat *remotes.txt* +eg: +```text +gitweb-test1 https://gituser:gitpassword@gitweb-test1 +gitweb-test2 https://gituser:gitpassword@gitweb-test2 +gitweb-test3 https://gituser:gitpassword@gitweb-test3 +``` +run image fraoustin/gitweb +```bash + docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITPROJECT=test" \ + -e FORCEPUSH='not_blank_string' \ + -v :/var/lib/git/ \ + -v :/opt/gitweb/remote/ \ + --name test -p 80:80 fraoustin/gitweb +``` +if don't want force push, **DO NOT** set environment: FORCEPUSH + +- when run `addrepos ${project}` , + - will add hook: `hooks/post-receive` + - will add remote each: `add remote gitweb-test1 https://gituser:gitpassword@gitweb-test1/${project}.git` ... +- when downstream push + - gitweb will push to upstreams each: `git push [-f] --all gitweb-test1` ... ## Usage by Dockerfile Sample of Dockerfile - +```Dockerfile FROM fraoustin/gitweb COPY ./00_init.sh /usr/share/gitweb/docker-entrypoint.pre/00_init.sh RUN chmod +x -R /usr/share/gitweb/docker-entrypoint.pre - +``` File 00_init.sh - +```bash #!/bin/bash REPOS='/var/lib/git/test.git' if [ ! -d $REPOS ]; then @@ -67,15 +123,16 @@ File 00_init.sh chgrp -R nginx . fi addauth $GITUSER $GITPASSWORD - +``` build image mygit - +```bash docker build -t mygit . - +``` run image mygit - - docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITUSER=gituser" -e "GITPASSWORD=gitpassword" -v :/var/lib/git --name test -p 80:80 mygit - +```bash + docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITUSER=gituser" -e "GITPASSWORD=gitpassword" \ + -v :/var/lib/git --name test -p 80:80 mygit +``` @@ -84,6 +141,6 @@ run image mygit If you want use a new design for ihm, you can use IHM variable - IHM = mdl - +```bash docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "IHM=mdl" -e "GITPROJECT=test" -v :/var/lib/git --name test -p 80:80 fraoustin/gitweb - +``` diff --git a/docker-compose.yaml b/docker-compose.yaml index b13d6d4..002a188 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -12,12 +12,13 @@ services: # context: https://github.com/fraoustin/gitweb.git # dockerfile: Dockerfile environment: - - FORCEPUSH:"" - CONTAINER_TIMEZONE=Europe/Paris - GITUSER=gituser - GITPASSWORD=gitpassword - GITPROJECT=test + - FORCEPUSH="" ports: - 80:80 volumes: - - gitweb:/var/lib/git \ No newline at end of file + - gitweb:/var/lib/git/ + - /path/to/remote/:/opt/gitweb/remote/ \ No newline at end of file diff --git a/src/cmd/addrepos.sh b/src/cmd/addrepos.sh index dfa5a05..523d2c3 100644 --- a/src/cmd/addrepos.sh +++ b/src/cmd/addrepos.sh @@ -1,6 +1,11 @@ #!/bin/bash DIR="/var/lib/git/" - + +log_run(){ + echo -e "$@" + eval $@ +} + error(){ echo "ERROR : parameters invalid !" >&2 exit 1 @@ -18,9 +23,21 @@ load(){ cd $REPOS git init --bare echo "$1" > description - cp /opt/gitweb/post-receive $REPOS/hooks/post-receive chgrp -R nginx $REPOS + if [ ! -f /opt/gitweb/remote/remotes.txt ]; then + exit 0 + fi + cp /opt/gitweb/post-receive $REPOS/hooks/post-receive + chgrp nginx $REPOS/hooks/post-receive chmod 0755 $REPOS/hooks/post-receive + while read line + do + if [ -z "${line}" ];then + continue + fi + # eg: git remote add gitweb-test1 https://gituser:gitpassword@gitweb-test1/test.git + log_run git remote add ${line}/$(basename $(pwd)) + done < /opt/gitweb/remote/remotes.txt fi } diff --git a/test/remotes.txt b/test/remotes.txt new file mode 100644 index 0000000..06b4e39 --- /dev/null +++ b/test/remotes.txt @@ -0,0 +1,3 @@ +gitweb-test1 https://gituser:gitpassword@gitweb-test1 +gitweb-test2 https://gituser:gitpassword@gitweb-test2 +gitweb-test3 https://gituser:gitpassword@gitweb-test3 \ No newline at end of file From b535d076a8a2aacee59c2afa78beec7445c4e9a0 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 14:23:16 +0800 Subject: [PATCH 17/82] Create docker-publish.yml use github actions to Build, test and push Docker image to docker hub --- .github/workflows/docker-publish.yml | 92 ++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..9f7d392 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,92 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [ "master" ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "master" ] + +env: + # Use docker.io for Docker Hub if empty + # REGISTRY: ghcr.io + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 + with: + cosign-release: 'v1.9.0' + + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + COSIGN_EXPERIMENTAL: "true" + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} From 884f7581f16cce21de3d3fe115e610ce4112fb9b Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 14:27:53 +0800 Subject: [PATCH 18/82] set latest tag for master branch --- .github/workflows/docker-publish.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 9f7d392..bdf9f4a 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -66,7 +66,9 @@ jobs: uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - + tags: | + # set latest tag for master branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image From 13602dac894f9406d7d7a31df6c9f395ded55244 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 14:30:19 +0800 Subject: [PATCH 19/82] lf to crlf --- .github/workflows/docker-publish.yml | 188 +++++++++++++-------------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index bdf9f4a..207ecc8 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,94 +1,94 @@ -name: Docker - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -on: - push: - branches: [ "master" ] - # Publish semver tags as releases. - tags: [ 'v*.*.*' ] - pull_request: - branches: [ "master" ] - -env: - # Use docker.io for Docker Hub if empty - # REGISTRY: ghcr.io - REGISTRY: docker.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} - - -jobs: - build: - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 - with: - cosign-release: 'v1.9.0' - - - # Workaround: https://github.com/docker/build-push-action/issues/461 - - name: Setup Docker buildx - uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf - - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.REGISTRY_TOKEN }} - - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - # set latest tag for master branch - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - COSIGN_EXPERIMENTAL: "true" - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [ "master" ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "master" ] + +env: + # Use docker.io for Docker Hub if empty + # REGISTRY: ghcr.io + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 + with: + cosign-release: 'v1.9.0' + + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + # set latest tag for master branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + COSIGN_EXPERIMENTAL: "true" + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} From 35955c11adcf89c6696ed8aba3052519bef906ae Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 14:31:49 +0800 Subject: [PATCH 20/82] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 207ecc8..8656b23 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -66,8 +66,8 @@ jobs: uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # set latest tag for master branch tags: | - # set latest tag for master branch type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action From b0ed668ebc829f518849b6d925739f65f3fe0034 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 14:59:16 +0800 Subject: [PATCH 21/82] why 0755 not working ? --- src/cmd/addrepos.sh | 2 +- src/hooks/post-receive | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/cmd/addrepos.sh b/src/cmd/addrepos.sh index 523d2c3..199c640 100644 --- a/src/cmd/addrepos.sh +++ b/src/cmd/addrepos.sh @@ -29,7 +29,7 @@ load(){ fi cp /opt/gitweb/post-receive $REPOS/hooks/post-receive chgrp nginx $REPOS/hooks/post-receive - chmod 0755 $REPOS/hooks/post-receive + chmod a+x $REPOS/hooks/post-receive while read line do if [ -z "${line}" ];then diff --git a/src/hooks/post-receive b/src/hooks/post-receive index 60bd9d7..ec98646 100644 --- a/src/hooks/post-receive +++ b/src/hooks/post-receive @@ -1,6 +1,5 @@ #!/bin/bash -# 客户端 git push 触发 -# + log_info(){ echo -e "\033[32m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" } @@ -15,7 +14,6 @@ log_run(){ eval $@ } -#判断是不是远端仓库 IS_BARE=$(git rev-parse --is-bare-repository) if [ -z "$IS_BARE" ]; then log_error "fatal: post-receive: IS_NOT_BARE" @@ -29,8 +27,8 @@ git_push(){ log_warn "========================= push start" for remote in $(git remote) do - log_info "${HOSTNAME} push to ${remote}" - log_run git push "${FORCEPUSH:+ -f}" --all ${remote} + log_info ${HOSTNAME} push to ${remote} + log_run git push ${FORCEPUSH:+ -f} --all ${remote} done log_warn "========================= push end" } From ffd2b9916dd29965a04b70ab0e2eb24485ad4670 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 15:01:12 +0800 Subject: [PATCH 22/82] show more log --- src/cmd/addrepos.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cmd/addrepos.sh b/src/cmd/addrepos.sh index 199c640..eaebe06 100644 --- a/src/cmd/addrepos.sh +++ b/src/cmd/addrepos.sh @@ -27,9 +27,10 @@ load(){ if [ ! -f /opt/gitweb/remote/remotes.txt ]; then exit 0 fi - cp /opt/gitweb/post-receive $REPOS/hooks/post-receive - chgrp nginx $REPOS/hooks/post-receive - chmod a+x $REPOS/hooks/post-receive + log_run cp /opt/gitweb/post-receive $REPOS/hooks/post-receive + log_run chgrp nginx $REPOS/hooks/post-receive + log_run chmod 0755 $REPOS/hooks/post-receive + log_run chmod g+ws $REPOS/hooks/post-receive while read line do if [ -z "${line}" ];then From 1ef8464eb993f93c981ff4ff8a984d85dc4b409b Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 16:12:54 +0800 Subject: [PATCH 23/82] chmod -R g+ws . chgrp -R nginx . --- src/cmd/addrepos.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/addrepos.sh b/src/cmd/addrepos.sh index eaebe06..61b9065 100644 --- a/src/cmd/addrepos.sh +++ b/src/cmd/addrepos.sh @@ -23,7 +23,8 @@ load(){ cd $REPOS git init --bare echo "$1" > description - chgrp -R nginx $REPOS + chmod -R g+ws . + chgrp -R nginx . if [ ! -f /opt/gitweb/remote/remotes.txt ]; then exit 0 fi From ecc1791bbcb6f093d05d6ab167b47789c31e82a5 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 16:39:46 +0800 Subject: [PATCH 24/82] chmod and chgrp when addrepos --- src/00_init.sh | 2 -- src/cmd/addrepos.sh | 61 +++++++++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/00_init.sh b/src/00_init.sh index d06a38a..4cc41e0 100755 --- a/src/00_init.sh +++ b/src/00_init.sh @@ -4,8 +4,6 @@ if [ ! -z "$GITPROJECT" ]; then if [ ! -d $REPOS ]; then addrepos $GITPROJECT cd $REPOS - chmod -R g+ws . - chgrp -R nginx . fi fi if [ ! -z "$GITUSER" ]; then diff --git a/src/cmd/addrepos.sh b/src/cmd/addrepos.sh index 61b9065..ea4e9da 100644 --- a/src/cmd/addrepos.sh +++ b/src/cmd/addrepos.sh @@ -1,4 +1,5 @@ #!/bin/bash + DIR="/var/lib/git/" log_run(){ @@ -7,40 +8,40 @@ log_run(){ } error(){ - echo "ERROR : parameters invalid !" >&2 - exit 1 + echo "ERROR : parameters invalid !" >&2 + exit 1 } usage(){ - echo "Usage: addrepos NameOfRepository" - echo "--help or -h : view help" + echo "Usage: addrepos NameOfRepository" + echo "--help or -h : view help" } load(){ - REPOS=$DIR$1.git - if [ ! -d $REPOS ]; then - mkdir $REPOS - cd $REPOS - git init --bare - echo "$1" > description - chmod -R g+ws . + REPOS=$DIR$1.git + if [ ! -d $REPOS ]; then + mkdir $REPOS + cd $REPOS + git init --bare + echo "$1" > description + chmod -R g+ws . chgrp -R nginx . - if [ ! -f /opt/gitweb/remote/remotes.txt ]; then - exit 0 - fi - log_run cp /opt/gitweb/post-receive $REPOS/hooks/post-receive - log_run chgrp nginx $REPOS/hooks/post-receive - log_run chmod 0755 $REPOS/hooks/post-receive - log_run chmod g+ws $REPOS/hooks/post-receive - while read line - do - if [ -z "${line}" ];then - continue - fi - # eg: git remote add gitweb-test1 https://gituser:gitpassword@gitweb-test1/test.git - log_run git remote add ${line}/$(basename $(pwd)) - done < /opt/gitweb/remote/remotes.txt - fi + if [ ! -f /opt/gitweb/remote/remotes.txt ]; then + exit 0 + fi + log_run cp /opt/gitweb/post-receive $REPOS/hooks/post-receive + log_run chgrp nginx $REPOS/hooks/post-receive + log_run chmod 0755 $REPOS/hooks/post-receive + log_run chmod g+ws $REPOS/hooks/post-receive + while read line + do + if [ -z "${line}" ];then + continue + fi + # eg: git remote add gitweb-test1 https://gituser:gitpassword@gitweb-test1/test.git + log_run git remote add ${line}/$(basename $(pwd)) + done < /opt/gitweb/remote/remotes.txt + fi } # no parameters @@ -50,12 +51,12 @@ case "$1" in --help) usage ;; - + -h) usage ;; - + *) load $1 - + esac From 7890af689fc6ba4989436388c003704366f57cf8 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 16:41:54 +0800 Subject: [PATCH 25/82] use cache --- .github/workflows/docker-publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8656b23..932f9a2 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -79,7 +79,8 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - + cache-from: type=registry,ref=${{ github.repository }}:buildcache + cache-to: type=registry,ref=${{ github.repository }}:buildcache,mode=max # Sign the resulting Docker image digest except on PRs. # This will only write to the public Rekor transparency log when the Docker # repository is public to avoid leaking data. If you would like to publish From 68ca015a72a9cd21c21cbf819dcb30d3aafb6a83 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 16:43:49 +0800 Subject: [PATCH 26/82] change cache name ref --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 932f9a2..90210fe 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -79,8 +79,8 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ github.repository }}:buildcache - cache-to: type=registry,ref=${{ github.repository }}:buildcache,mode=max + cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max # Sign the resulting Docker image digest except on PRs. # This will only write to the public Rekor transparency log when the Docker # repository is public to avoid leaking data. If you would like to publish From 228866975e91d9624e71616914f7476f9924e846 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 17:09:23 +0800 Subject: [PATCH 27/82] CRLF to LF --- src/hooks/post-receive | 80 +++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/hooks/post-receive b/src/hooks/post-receive index ec98646..44f25eb 100644 --- a/src/hooks/post-receive +++ b/src/hooks/post-receive @@ -1,40 +1,40 @@ -#!/bin/bash - -log_info(){ - echo -e "\033[32m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" -} -log_warn(){ - echo -e "\033[33m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" -} -log_error(){ - echo >&2 -e "\033[31m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" -} -log_run(){ - echo -e "\033[43;34m$@\033[0m" - eval $@ -} - -IS_BARE=$(git rev-parse --is-bare-repository) -if [ -z "$IS_BARE" ]; then - log_error "fatal: post-receive: IS_NOT_BARE" - exit 1 -fi -log_warn "========================= deploy start =========================" -HOSTNAME="$(hostname)" -log_warn "========================= hostname: ${HOSTNAME}" - -git_push(){ - log_warn "========================= push start" - for remote in $(git remote) - do - log_info ${HOSTNAME} push to ${remote} - log_run git push ${FORCEPUSH:+ -f} --all ${remote} - done - log_warn "========================= push end" -} - - -log_info "try run : git_push" -git_push - -log_warn "========================= deploy end =========================" +#!/bin/bash + +log_info(){ + echo -e "\033[32m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" +} +log_warn(){ + echo -e "\033[33m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" +} +log_error(){ + echo >&2 -e "\033[31m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" +} +log_run(){ + echo -e "\033[43;34m$@\033[0m" + eval $@ +} + +IS_BARE=$(git rev-parse --is-bare-repository) +if [ -z "$IS_BARE" ]; then + log_error "fatal: post-receive: IS_NOT_BARE" + exit 1 +fi +log_warn "========================= deploy start =========================" +HOSTNAME="$(hostname)" +log_warn "========================= hostname: ${HOSTNAME}" + +git_push(){ + log_warn "========================= push start" + for remote in $(git remote) + do + log_info ${HOSTNAME} push to ${remote} + log_run git push ${FORCEPUSH:+ -f} --all ${remote} + done + log_warn "========================= push end" +} + + +log_info "try run : git_push" +git_push + +log_warn "========================= deploy end =========================" From a3092c4982305f6a28c7502a0310de4d26fcbfb3 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 17:26:12 +0800 Subject: [PATCH 28/82] Merge branch 'master' into develop --- .github/workflows/docker-publish.yml | 95 ++++++++++++++++++++++++++++ Dockerfile | 14 +++- Dockerfile.CN | 67 -------------------- README.md | 95 ++++++++++++++++++++++------ docker-compose.yaml | 16 +++-- src/00_init.sh | 2 - src/cmd/addrepos.sh | 54 +++++++++++----- src/hooks/post-receive | 40 ++++++++++++ test/remotes.txt | 3 + 9 files changed, 273 insertions(+), 113 deletions(-) create mode 100644 .github/workflows/docker-publish.yml delete mode 100644 Dockerfile.CN create mode 100644 src/hooks/post-receive create mode 100644 test/remotes.txt diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..90210fe --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,95 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [ "master" ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "master" ] + +env: + # Use docker.io for Docker Hub if empty + # REGISTRY: ghcr.io + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 + with: + cosign-release: 'v1.9.0' + + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # set latest tag for master branch + tags: | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + COSIGN_EXPERIMENTAL: "true" + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index 88775e3..da19d7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:1.21 +FROM nginx:1.23 LABEL maintainer "fraoustin@gmail.com" COPY ./src/default.conf /etc/nginx/conf.d/default.conf @@ -50,9 +50,17 @@ COPY ./src/ihm /mdl-ihm RUN cp /usr/share/gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css.original RUN mkdir /usr/share/gitweb/ihm -VOLUME /var/lib/git +# force push to upstream +WORKDIR /opt/gitweb/ +COPY ./src/hooks/post-receive /opt/gitweb/post-receive +RUN chmod +x /opt/gitweb/post-receive +ENV FORCEPUSH "" -WORKDIR /var/lib/git +VOLUME /opt/gitweb/remote/ + +VOLUME /var/lib/git/ + +WORKDIR /var/lib/git/ EXPOSE 80 diff --git a/Dockerfile.CN b/Dockerfile.CN deleted file mode 100644 index dfa1939..0000000 --- a/Dockerfile.CN +++ /dev/null @@ -1,67 +0,0 @@ -FROM nginx:1.21 -LABEL maintainer "fraoustin@gmail.com" - -COPY ./src/default.conf /etc/nginx/conf.d/default.conf - -COPY ./src/entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh - -ENV SET_CONTAINER_TIMEZONE false - -# USE TIMEZONE TO CHINA -ENV CONTAINER_TIMEZONE "Asia/Shanghai" - -# USE CHINA USTC MIRROR -RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list -RUN sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list - -RUN apt-get update && apt-get install -y \ - apache2-utils \ - fcgiwrap \ - git \ - git-core \ - gitweb \ - highlight \ - libcgi-pm-perl \ - mime-support \ - spawn-fcgi \ - && rm -rf /var/lib/apt/lists/* - -# manage user load fcgiwrap -RUN sed -i "s/www-data/nginx/g" /etc/init.d/fcgiwrap - -# manage start container -RUN mkdir /usr/share/gitweb/docker-entrypoint.pre -RUN mkdir /usr/share/gitweb/docker-entrypoint.post -COPY ./src/00_init.sh /usr/share/gitweb/docker-entrypoint.pre/00_init.sh -RUN chmod +x -R /usr/share/gitweb/docker-entrypoint.pre - -# add cmd gitweb -COPY ./src/cmd/addrepos.sh /usr/bin/addrepos -COPY ./src/cmd/addauth.sh /usr/bin/addauth -COPY ./src/cmd/rmrepos.sh /usr/bin/rmrepos -COPY ./src/cmd/rmauth.sh /usr/bin/rmauth -RUN chmod +x /usr/bin/addrepos -RUN chmod +x /usr/bin/addauth -RUN chmod +x /usr/bin/rmrepos -RUN chmod +x /usr/bin/rmauth - -# manage default value -ENV GITUSER gituser -ENV GITPASSWORD gitpassword - -# add ihm mdl -ENV IHM no-mdl -COPY ./src/ihm /mdl-ihm -RUN cp /usr/share/gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css.original -RUN mkdir /usr/share/gitweb/ihm - -VOLUME /var/lib/git - -WORKDIR /var/lib/git - -EXPOSE 80 - -ENTRYPOINT ["/entrypoint.sh"] - -CMD ["app"] diff --git a/README.md b/README.md index 4bf9dbc..eacb510 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,12 @@ load when start image load file in - GITUSER (default gituser) - GITPASSWORD (default gitpassword) - IHM (default "") +- FORCEPUSH ("" or every not blank string) manage force push to upstream when Downstream branch push ## Volume -- /var/lib/git +- git project: */var/lib/git/* +- git remove add: */opt/gitweb/remote/* ## Port @@ -34,30 +36,84 @@ load when start image load file in ## Usage direct run image fraoustin/gitweb +```bash + docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITPROJECT=test" \ + -v :/var/lib/git --name test -p 80:80 fraoustin/gitweb +``` +> use ^ for *CMD* OR ` for *Powershell* - docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITPROJECT=test" -v :/var/lib/git --name test -p 80:80 fraoustin/gitweb - -user default is gituser and password default is gitpassword +user default is gituser and password default is gitpassword +- You can change user and password by variable environment you use http://localhost/ for access gitweb +you can add remote +```bash + git remote add origin http://gituser:gitpassword@localhost/test.git +``` +you can push project + +when fist push +```bash + git push --set-upstream origin master +``` +every next time push +```bash + git push +``` +or manual push +```bash + git push origin # remote name +``` you can clone project - +```bash git clone http://gituser:gitpassword@localhost/test.git - -You can change user and password by variable environment - +``` +you can pull project when upstream update +```bash + git pull +``` +more use see: +- https://git-scm.com/doc +- https://www.runoob.com/git/git-tutorial.html + + + +## Add upstream and push + +creat *remotes.txt* +eg: +```text +gitweb-test1 https://gituser:gitpassword@gitweb-test1 +gitweb-test2 https://gituser:gitpassword@gitweb-test2 +gitweb-test3 https://gituser:gitpassword@gitweb-test3 +``` +run image fraoustin/gitweb +```bash + docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITPROJECT=test" \ + -e FORCEPUSH='not_blank_string' \ + -v :/var/lib/git/ \ + -v :/opt/gitweb/remote/ \ + --name test -p 80:80 fraoustin/gitweb +``` +if don't want force push, **DO NOT** set environment: FORCEPUSH + +- when run `addrepos ${project}` , + - will add hook: `hooks/post-receive` + - will add remote each: `add remote gitweb-test1 https://gituser:gitpassword@gitweb-test1/${project}.git` ... +- when downstream push + - gitweb will push to upstreams each: `git push [-f] --all gitweb-test1` ... ## Usage by Dockerfile Sample of Dockerfile - +```Dockerfile FROM fraoustin/gitweb COPY ./00_init.sh /usr/share/gitweb/docker-entrypoint.pre/00_init.sh RUN chmod +x -R /usr/share/gitweb/docker-entrypoint.pre - +``` File 00_init.sh - +```bash #!/bin/bash REPOS='/var/lib/git/test.git' if [ ! -d $REPOS ]; then @@ -67,15 +123,16 @@ File 00_init.sh chgrp -R nginx . fi addauth $GITUSER $GITPASSWORD - +``` build image mygit - +```bash docker build -t mygit . - +``` run image mygit - - docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITUSER=gituser" -e "GITPASSWORD=gitpassword" -v :/var/lib/git --name test -p 80:80 mygit - +```bash + docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITUSER=gituser" -e "GITPASSWORD=gitpassword" \ + -v :/var/lib/git --name test -p 80:80 mygit +``` @@ -84,6 +141,6 @@ run image mygit If you want use a new design for ihm, you can use IHM variable - IHM = mdl - +```bash docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "IHM=mdl" -e "GITPROJECT=test" -v :/var/lib/git --name test -p 80:80 fraoustin/gitweb - +``` diff --git a/docker-compose.yaml b/docker-compose.yaml index b98b403..13d8a93 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,16 +6,20 @@ volumes: services: gitweb: image: fraoustin/gitweb - build: - context: . - dockerfile: Dockerfile + container_name: gitweb + hostname: gitweb-test + # build: + # context: https://github.com/fraoustin/gitweb.git + # dockerfile: Dockerfile environment: - CONTAINER_TIMEZONE=Europe/Paris - - GITUSER=gituser + - GITUSER=gituser - GITPASSWORD=gitpassword - - SET_CONTAINER_TIMEZONE=false + - GITPROJECT=test + - FORCEPUSH="" ports: - 80:80 restart: always volumes: - - gitweb:/var/lib/git \ No newline at end of file + - gitweb:/var/lib/git/ + - /path/to/remote/:/opt/gitweb/remote/ \ No newline at end of file diff --git a/src/00_init.sh b/src/00_init.sh index d06a38a..4cc41e0 100755 --- a/src/00_init.sh +++ b/src/00_init.sh @@ -4,8 +4,6 @@ if [ ! -z "$GITPROJECT" ]; then if [ ! -d $REPOS ]; then addrepos $GITPROJECT cd $REPOS - chmod -R g+ws . - chgrp -R nginx . fi fi if [ ! -z "$GITUSER" ]; then diff --git a/src/cmd/addrepos.sh b/src/cmd/addrepos.sh index 976bec8..ea4e9da 100644 --- a/src/cmd/addrepos.sh +++ b/src/cmd/addrepos.sh @@ -1,25 +1,47 @@ #!/bin/bash + DIR="/var/lib/git/" - + +log_run(){ + echo -e "$@" + eval $@ +} + error(){ - echo "ERROR : parameters invalid !" >&2 - exit 1 + echo "ERROR : parameters invalid !" >&2 + exit 1 } usage(){ - echo "Usage: addrepos NameOfRepository" - echo "--help or -h : view help" + echo "Usage: addrepos NameOfRepository" + echo "--help or -h : view help" } load(){ - REPOS=$DIR$1.git - if [ ! -d $REPOS ]; then - mkdir $REPOS - cd $REPOS - git init --bare - echo "$1" > description - chmod -R 777 $REPOS - fi + REPOS=$DIR$1.git + if [ ! -d $REPOS ]; then + mkdir $REPOS + cd $REPOS + git init --bare + echo "$1" > description + chmod -R g+ws . + chgrp -R nginx . + if [ ! -f /opt/gitweb/remote/remotes.txt ]; then + exit 0 + fi + log_run cp /opt/gitweb/post-receive $REPOS/hooks/post-receive + log_run chgrp nginx $REPOS/hooks/post-receive + log_run chmod 0755 $REPOS/hooks/post-receive + log_run chmod g+ws $REPOS/hooks/post-receive + while read line + do + if [ -z "${line}" ];then + continue + fi + # eg: git remote add gitweb-test1 https://gituser:gitpassword@gitweb-test1/test.git + log_run git remote add ${line}/$(basename $(pwd)) + done < /opt/gitweb/remote/remotes.txt + fi } # no parameters @@ -29,12 +51,12 @@ case "$1" in --help) usage ;; - + -h) usage ;; - + *) load $1 - + esac diff --git a/src/hooks/post-receive b/src/hooks/post-receive new file mode 100644 index 0000000..44f25eb --- /dev/null +++ b/src/hooks/post-receive @@ -0,0 +1,40 @@ +#!/bin/bash + +log_info(){ + echo -e "\033[32m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" +} +log_warn(){ + echo -e "\033[33m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" +} +log_error(){ + echo >&2 -e "\033[31m$(date +%Y-%m-%d_%H:%M:%S) - $@\033[0m" +} +log_run(){ + echo -e "\033[43;34m$@\033[0m" + eval $@ +} + +IS_BARE=$(git rev-parse --is-bare-repository) +if [ -z "$IS_BARE" ]; then + log_error "fatal: post-receive: IS_NOT_BARE" + exit 1 +fi +log_warn "========================= deploy start =========================" +HOSTNAME="$(hostname)" +log_warn "========================= hostname: ${HOSTNAME}" + +git_push(){ + log_warn "========================= push start" + for remote in $(git remote) + do + log_info ${HOSTNAME} push to ${remote} + log_run git push ${FORCEPUSH:+ -f} --all ${remote} + done + log_warn "========================= push end" +} + + +log_info "try run : git_push" +git_push + +log_warn "========================= deploy end =========================" diff --git a/test/remotes.txt b/test/remotes.txt new file mode 100644 index 0000000..06b4e39 --- /dev/null +++ b/test/remotes.txt @@ -0,0 +1,3 @@ +gitweb-test1 https://gituser:gitpassword@gitweb-test1 +gitweb-test2 https://gituser:gitpassword@gitweb-test2 +gitweb-test3 https://gituser:gitpassword@gitweb-test3 \ No newline at end of file From e973cd6b76bfd013fe98ecb093e99d48a27ee5ab Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 17:26:32 +0800 Subject: [PATCH 29/82] rm docker-compose-CN --- docker-compose-CN.yaml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 docker-compose-CN.yaml diff --git a/docker-compose-CN.yaml b/docker-compose-CN.yaml deleted file mode 100644 index 9ba480e..0000000 --- a/docker-compose-CN.yaml +++ /dev/null @@ -1,21 +0,0 @@ -version: "3" - -volumes: - gitweb: - -services: - gitweb: - image: fraoustin/gitweb - build: - context: . - dockerfile: Dockerfile.CN - environment: - - CONTAINER_TIMEZONE=Asia/Shanghai - - GITUSER=gituser - - GITPASSWORD=gitpassword - - SET_CONTAINER_TIMEZONE=false - ports: - - 80:80 - restart: always - volumes: - - gitweb:/var/lib/git From 2f45f3470bfadd51273b589feff684c5b81e44a4 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 17:31:32 +0800 Subject: [PATCH 30/82] add action "develop" --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 90210fe..353d385 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,11 +7,11 @@ name: Docker on: push: - branches: [ "master" ] + branches: [ "master" , "develop" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] pull_request: - branches: [ "master" ] + branches: [ "master", "develop" ] env: # Use docker.io for Docker Hub if empty From d675222f6d53414e7a73589e0c989e28f1baae19 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:05:46 +0800 Subject: [PATCH 31/82] Setting base url via Docker close: #3 --- Dockerfile | 3 +++ README.md | 4 ++++ src/entrypoint.sh | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index da19d7b..a6d92bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,6 +56,9 @@ COPY ./src/hooks/post-receive /opt/gitweb/post-receive RUN chmod +x /opt/gitweb/post-receive ENV FORCEPUSH "" +# Setting base url via Docker +ENV URLPATH / + VOLUME /opt/gitweb/remote/ VOLUME /var/lib/git/ diff --git a/README.md b/README.md index eacb510..77c705f 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,10 @@ if don't want force push, **DO NOT** set environment: FORCEPUSH - when downstream push - gitweb will push to upstreams each: `git push [-f] --all gitweb-test1` ... +## Setting base url via Docker environment + +use environment *URLPATH* to set base url + ## Usage by Dockerfile Sample of Dockerfile diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 07a910a..1a4568f 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -29,7 +29,12 @@ if [ "$1" = 'app' ]; then echo '$site_footer="ihm/footer.html";' >> /etc/gitweb.conf cat /usr/share/gitweb/ihm/headstring.conf >> /etc/gitweb.conf cp /usr/share/gitweb/ihm/gitweb.css /usr/share/gitweb/static/gitweb.css - fi + fi + if [ -n "${URLPATH}" ]; then + sed -n '10p' /etc/nginx/conf.d/default.conf + sed -i "10s|.*| location ${URLPATH} {|" /etc/nginx/conf.d/default.conf + sed -n '10p' /etc/nginx/conf.d/default.conf + fi service fcgiwrap start nginx -g "daemon off;" /bin/run-parts --verbose --regex '\.(sh)$' "/usr/share/gitweb/docker-entrypoint.post" From 101e89cf361c7c5befafc0ffaf575493daf707bc Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:14:46 +0800 Subject: [PATCH 32/82] hand tag for other branch --- .github/workflows/docker-publish.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 353d385..7599077 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -66,8 +66,12 @@ jobs: uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # set latest tag for master branch tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + # set latest tag for master branch type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action From b882df5f9ad127d5265b3e5841d6662a51069c47 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:20:48 +0800 Subject: [PATCH 33/82] why https://github.com/Mars-Sea/phddns-docker is working --- .github/workflows/docker-publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7599077..7da7c25 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -71,7 +71,6 @@ jobs: type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - # set latest tag for master branch type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action From 0f9cc08b2db578223c8d7451b46bf7846ef4b167 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:25:21 +0800 Subject: [PATCH 34/82] CRLF to LF --- .github/workflows/docker-publish.yml | 197 ++++++++++++++------------- 1 file changed, 99 insertions(+), 98 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7da7c25..9a17fae 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,98 +1,99 @@ -name: Docker - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -on: - push: - branches: [ "master" , "develop" ] - # Publish semver tags as releases. - tags: [ 'v*.*.*' ] - pull_request: - branches: [ "master", "develop" ] - -env: - # Use docker.io for Docker Hub if empty - # REGISTRY: ghcr.io - REGISTRY: docker.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} - - -jobs: - build: - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 - with: - cosign-release: 'v1.9.0' - - - # Workaround: https://github.com/docker/build-push-action/issues/461 - - name: Setup Docker buildx - uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf - - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.REGISTRY_TOKEN }} - - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache - cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - COSIGN_EXPERIMENTAL: "true" - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [ "master" , "develop" ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "master", "develop" ] + +env: + # Use docker.io for Docker Hub if empty + # REGISTRY: ghcr.io + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 + with: + cosign-release: 'v1.9.0' + + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + # set latest tag for master branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + COSIGN_EXPERIMENTAL: "true" + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} From 351ce2718cb7da87a2801c21592a0e1e53839eda Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:26:19 +0800 Subject: [PATCH 35/82] re creat it --- .github/workflows/docker-publish.yml | 99 ---------------------------- 1 file changed, 99 deletions(-) delete mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index 9a17fae..0000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: Docker - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -on: - push: - branches: [ "master" , "develop" ] - # Publish semver tags as releases. - tags: [ 'v*.*.*' ] - pull_request: - branches: [ "master", "develop" ] - -env: - # Use docker.io for Docker Hub if empty - # REGISTRY: ghcr.io - REGISTRY: docker.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} - - -jobs: - build: - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 - with: - cosign-release: 'v1.9.0' - - - # Workaround: https://github.com/docker/build-push-action/issues/461 - - name: Setup Docker buildx - uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf - - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.REGISTRY_TOKEN }} - - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - # set latest tag for master branch - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache - cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - COSIGN_EXPERIMENTAL: "true" - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} From 7e18184abfe0bc903534b819a80f2d7812a1a85c Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:29:51 +0800 Subject: [PATCH 36/82] update --- .github/workflows/docker-publish.yml | 194 ++++++++++++++------------- 1 file changed, 99 insertions(+), 95 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 90210fe..9a17fae 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,95 +1,99 @@ -name: Docker - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -on: - push: - branches: [ "master" ] - # Publish semver tags as releases. - tags: [ 'v*.*.*' ] - pull_request: - branches: [ "master" ] - -env: - # Use docker.io for Docker Hub if empty - # REGISTRY: ghcr.io - REGISTRY: docker.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} - - -jobs: - build: - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 - with: - cosign-release: 'v1.9.0' - - - # Workaround: https://github.com/docker/build-push-action/issues/461 - - name: Setup Docker buildx - uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf - - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.REGISTRY_TOKEN }} - - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # set latest tag for master branch - tags: | - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache - cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - COSIGN_EXPERIMENTAL: "true" - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [ "master" , "develop" ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "master", "develop" ] + +env: + # Use docker.io for Docker Hub if empty + # REGISTRY: ghcr.io + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 + with: + cosign-release: 'v1.9.0' + + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + # set latest tag for master branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + COSIGN_EXPERIMENTAL: "true" + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} From 18fef60f80b15458ac0f99952f5603f44d94428a Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:30:42 +0800 Subject: [PATCH 37/82] delete CN --- docker-compose-CN.yaml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 docker-compose-CN.yaml diff --git a/docker-compose-CN.yaml b/docker-compose-CN.yaml deleted file mode 100644 index 9ba480e..0000000 --- a/docker-compose-CN.yaml +++ /dev/null @@ -1,21 +0,0 @@ -version: "3" - -volumes: - gitweb: - -services: - gitweb: - image: fraoustin/gitweb - build: - context: . - dockerfile: Dockerfile.CN - environment: - - CONTAINER_TIMEZONE=Asia/Shanghai - - GITUSER=gituser - - GITPASSWORD=gitpassword - - SET_CONTAINER_TIMEZONE=false - ports: - - 80:80 - restart: always - volumes: - - gitweb:/var/lib/git From e6eed0cc43a2fea7677a59f62b9678c009efa841 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:31:16 +0800 Subject: [PATCH 38/82] Delete docker-publish.yml --- .github/workflows/docker-publish.yml | 99 ---------------------------- 1 file changed, 99 deletions(-) delete mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index 9a17fae..0000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: Docker - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -on: - push: - branches: [ "master" , "develop" ] - # Publish semver tags as releases. - tags: [ 'v*.*.*' ] - pull_request: - branches: [ "master", "develop" ] - -env: - # Use docker.io for Docker Hub if empty - # REGISTRY: ghcr.io - REGISTRY: docker.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} - - -jobs: - build: - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 - with: - cosign-release: 'v1.9.0' - - - # Workaround: https://github.com/docker/build-push-action/issues/461 - - name: Setup Docker buildx - uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf - - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.REGISTRY_TOKEN }} - - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - # set latest tag for master branch - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache - cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - COSIGN_EXPERIMENTAL: "true" - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} From c8e18b76b9ab2abb16815c159d8336b2251a4bf0 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:31:50 +0800 Subject: [PATCH 39/82] Create docker-publish.yml --- .github/workflows/docker-publish.yml | 99 ++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..9a17fae --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,99 @@ +name: Docker + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [ "master" , "develop" ] + # Publish semver tags as releases. + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "master", "develop" ] + +env: + # Use docker.io for Docker Hub if empty + # REGISTRY: ghcr.io + REGISTRY: docker.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 + with: + cosign-release: 'v1.9.0' + + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + # set latest tag for master branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + COSIGN_EXPERIMENTAL: "true" + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} From ae6f0458d5c3b9e07c4d9a123f330db6aa3ef96f Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:33:25 +0800 Subject: [PATCH 40/82] update --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 9a17fae..a326578 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -71,8 +71,8 @@ jobs: type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - # set latest tag for master branch type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} + # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image From 5f47fa02f060fe73ca22bc956d05ebc1bfa35cf5 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 12 Aug 2022 18:53:41 +0800 Subject: [PATCH 41/82] hand other branch hand other branch --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a326578..da682c9 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,11 +7,11 @@ name: Docker on: push: - branches: [ "master" , "develop" ] + branches: [ "master" , "develop" , "patch-*" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] pull_request: - branches: [ "master", "develop" ] + branches: [ "master", "develop" , "patch-*" ] env: # Use docker.io for Docker Hub if empty From e6cf569223b501f16466154babc3f5e0230bdfaa Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sat, 13 Aug 2022 14:13:30 +0800 Subject: [PATCH 42/82] other branch git branch --set-upstream-to=/ --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 77c705f..9f0eaaf 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,13 @@ when fist push ```bash git push --set-upstream origin master ``` +other branch +```bash + git branch --set-upstream-to=/ + +eg: + git branch --set-upstream-to=gitweb/main main +``` every next time push ```bash git push From 97e38895c33c812b918fb5a24fd7b72a45af7cbf Mon Sep 17 00:00:00 2001 From: romain Date: Sat, 27 Aug 2022 12:46:20 +0200 Subject: [PATCH 43/82] added syntax highlighting feature --- Dockerfile | 1 + src/entrypoint.sh | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index 197c110..0997a53 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,6 +43,7 @@ RUN chmod +x /usr/bin/rmauth # manage default value ENV GITUSER gituser ENV GITPASSWORD gitpassword +ENV GITHIGHLIGHT 0 # add ihm mdl ENV IHM no-mdl diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 07a910a..8ca0efd 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -30,6 +30,11 @@ if [ "$1" = 'app' ]; then cat /usr/share/gitweb/ihm/headstring.conf >> /etc/gitweb.conf cp /usr/share/gitweb/ihm/gitweb.css /usr/share/gitweb/static/gitweb.css fi + if [ "$GITHIGHLIGHT" = "1" ]; then + echo '' >> /etc/gitweb.conf + echo '# enable syntax highlighting' >> /etc/gitweb.conf + echo "\$feature{'highlight'}{'default'} = [1];" >> /etc/gitweb.conf + fi service fcgiwrap start nginx -g "daemon off;" /bin/run-parts --verbose --regex '\.(sh)$' "/usr/share/gitweb/docker-entrypoint.post" From 2db1cfefbcbfbacc0155eadf92461b618b6788e8 Mon Sep 17 00:00:00 2001 From: romain Date: Sat, 27 Aug 2022 20:10:23 +0200 Subject: [PATCH 44/82] document new GITHIGHLIGHT option --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4bf9dbc..c5e8089 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ load when start image load file in - GITPROJECT - GITUSER (default gituser) - GITPASSWORD (default gitpassword) +- GITHIGHLIGHT (default `0`) - IHM (default "") ## Volume From 7cf808ac8b0aa260d381cf4e51da93ff1831df68 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sun, 4 Sep 2022 14:44:08 +0800 Subject: [PATCH 45/82] try build arm Install QEMU static binaries --- .github/workflows/docker-publish.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index da682c9..0aa8d44 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -43,8 +43,12 @@ jobs: uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 with: cosign-release: 'v1.9.0' - - + + # You may pin to the exact commit or the version. + # uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + # Workaround: https://github.com/docker/build-push-action/issues/461 - name: Setup Docker buildx uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf From a653ea1b3dc767758d912834556a89806477d1cd Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sun, 4 Sep 2022 14:48:42 +0800 Subject: [PATCH 46/82] add platforms linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6 --- .github/workflows/docker-publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a326578..98a8060 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -81,6 +81,7 @@ jobs: with: context: . push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache From 748a35872e927845bb3acdbab428487e918aba8b Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sun, 4 Sep 2022 14:50:24 +0800 Subject: [PATCH 47/82] change platforms linux/amd64,linux/arm64,linux/386,linux/arm/v7 --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 98a8060..2680b6d 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -81,7 +81,7 @@ jobs: with: context: . push: ${{ github.event_name != 'pull_request' }} - platforms: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6 + platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache From 6a8998c2167581a3c88d8137052b8fd5c3e8625d Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sun, 4 Sep 2022 14:57:26 +0800 Subject: [PATCH 48/82] use nginx:latest --- Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index a6d92bd..b930afa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM nginx:1.23 +FROM nginx:latest + LABEL maintainer "fraoustin@gmail.com" COPY ./src/default.conf /etc/nginx/conf.d/default.conf @@ -9,7 +10,8 @@ RUN chmod +x /entrypoint.sh ENV SET_CONTAINER_TIMEZONE false ENV CONTAINER_TIMEZONE "" -RUN apt-get update && apt-get install -y \ +RUN apt-get update \ + && apt-get install -y \ apache2-utils \ fcgiwrap \ git \ @@ -19,7 +21,8 @@ RUN apt-get update && apt-get install -y \ libcgi-pm-perl \ mime-support \ spawn-fcgi \ - && rm -rf /var/lib/apt/lists/* + && apt-get autoclean \ + && rm -rf /var/lib/apt/lists/* # manage user load fcgiwrap RUN sed -i "s/www-data/nginx/g" /etc/init.d/fcgiwrap From 9e7d4794557a95b1d83c87ace509353134650ba7 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sun, 4 Sep 2022 15:02:05 +0800 Subject: [PATCH 49/82] sync nginx platforms --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b877d6b..772f455 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -85,7 +85,7 @@ jobs: with: context: . push: ${{ github.event_name != 'pull_request' }} - platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7 + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/arm/v7,linux/arm/v5 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache From 8d3cf0b8af2ad999aff9bd9c295c938b35a5c767 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sun, 4 Sep 2022 15:27:57 +0800 Subject: [PATCH 50/82] >Format Document >inline_html-allowed_elements: kbd --- README.md | 56 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index acd8a32..7ad56f4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Docker Image for gitweb -generate a nginx server with git server and gitweb for ihm on http://127.0.0.1/ +generate a nginx server with git server and gitweb for ihm on load when start image load file in @@ -37,94 +37,117 @@ load when start image load file in ## Usage direct run image fraoustin/gitweb + ```bash docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITPROJECT=test" \ -v :/var/lib/git --name test -p 80:80 fraoustin/gitweb ``` -> use ^ for *CMD* OR ` for *Powershell* -user default is gituser and password default is gitpassword +> use ^ for *CMD* OR ` for *Powershell* + +user default is gituser and password default is gitpassword + - You can change user and password by variable environment -you use http://localhost/ for access gitweb +you use for access gitweb you can add remote + ```bash git remote add origin http://gituser:gitpassword@localhost/test.git ``` + you can push project when fist push + ```bash git push --set-upstream origin master ``` + other branch + ```bash git branch --set-upstream-to=/ eg: git branch --set-upstream-to=gitweb/main main ``` + every next time push + ```bash git push ``` + or manual push + ```bash git push origin # remote name ``` + you can clone project + ```bash git clone http://gituser:gitpassword@localhost/test.git ``` + you can pull project when upstream update + ```bash git pull ``` -more use see: -- https://git-scm.com/doc -- https://www.runoob.com/git/git-tutorial.html +more use see: +- +- ## Add upstream and push creat *remotes.txt* eg: + ```text gitweb-test1 https://gituser:gitpassword@gitweb-test1 gitweb-test2 https://gituser:gitpassword@gitweb-test2 gitweb-test3 https://gituser:gitpassword@gitweb-test3 ``` + run image fraoustin/gitweb + ```bash docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITPROJECT=test" \ - -e FORCEPUSH='not_blank_string' \ + -e FORCEPUSH='not_blank_string' \ -v :/var/lib/git/ \ -v :/opt/gitweb/remote/ \ --name test -p 80:80 fraoustin/gitweb ``` -if don't want force push, **DO NOT** set environment: FORCEPUSH + +if don't want force push, **DO NOT** set environment: FORCEPUSH - when run `addrepos ${project}` , - - will add hook: `hooks/post-receive` - - will add remote each: `add remote gitweb-test1 https://gituser:gitpassword@gitweb-test1/${project}.git` ... + - will add hook: `hooks/post-receive` + - will add remote each: `add remote gitweb-test1 https://gituser:gitpassword@gitweb-test1/${project}.git` ... - when downstream push - - gitweb will push to upstreams each: `git push [-f] --all gitweb-test1` ... + - gitweb will push to upstreams each: `git push [-f] --all gitweb-test1` ... ## Setting base url via Docker environment -use environment *URLPATH* to set base url +use environment *URLPATH* to set base url ## Usage by Dockerfile Sample of Dockerfile + ```Dockerfile FROM fraoustin/gitweb COPY ./00_init.sh /usr/share/gitweb/docker-entrypoint.pre/00_init.sh RUN chmod +x -R /usr/share/gitweb/docker-entrypoint.pre ``` + File 00_init.sh + ```bash #!/bin/bash REPOS='/var/lib/git/test.git' @@ -136,23 +159,26 @@ File 00_init.sh fi addauth $GITUSER $GITPASSWORD ``` + build image mygit + ```bash docker build -t mygit . ``` + run image mygit + ```bash docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITUSER=gituser" -e "GITPASSWORD=gitpassword" \ -v :/var/lib/git --name test -p 80:80 mygit ``` - - ## IHM material design If you want use a new design for ihm, you can use IHM variable - IHM = mdl + ```bash docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "IHM=mdl" -e "GITPROJECT=test" -v :/var/lib/git --name test -p 80:80 fraoustin/gitweb ``` From 3e4ddaa336ab58149efd0e322642c604fad0eb9c Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Sun, 4 Sep 2022 15:30:18 +0800 Subject: [PATCH 51/82] >inline_html-allowed_elements: kbd demo: add GITHIGHLIGHT,URLPATH --- .vscode/settings.json | 8 ++++++++ docker-compose.yaml | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7fcb16a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "markdownlint.config": { + "default": true, + "MD033": { + "allowed_elements": ["kbd"] + } + } +} diff --git a/docker-compose.yaml b/docker-compose.yaml index 13d8a93..c3a3845 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,6 +3,7 @@ version: "3" volumes: gitweb: + services: gitweb: image: fraoustin/gitweb @@ -13,13 +14,15 @@ services: # dockerfile: Dockerfile environment: - CONTAINER_TIMEZONE=Europe/Paris - - GITUSER=gituser + - GITUSER=gituser - GITPASSWORD=gitpassword - GITPROJECT=test - FORCEPUSH="" + - URLPATH=/ + - GITHIGHLIGHT=1 ports: - 80:80 restart: always volumes: - gitweb:/var/lib/git/ - - /path/to/remote/:/opt/gitweb/remote/ \ No newline at end of file + - /path/to/remote/:/opt/gitweb/remote/ From 077f735d750c6a349eae531a785872cb7921ee2b Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 03:26:22 +0800 Subject: [PATCH 52/82] =?UTF-8?q?pr=E6=8F=90=E4=BA=A4=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E4=B8=8D=E9=80=9A=E8=BF=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 772f455..909d63b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -39,7 +39,7 @@ jobs: # Install the cosign tool except on PR # https://github.com/sigstore/cosign-installer - name: Install cosign - if: github.event_name != 'pull_request' + if: ${{ github.event_name != 'pull_request' }} uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 with: cosign-release: 'v1.9.0' @@ -56,7 +56,7 @@ jobs: # Login against a Docker registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' + if: ${{ github.event_name != 'pull_request' }} uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c with: registry: ${{ env.REGISTRY }} From f5e4efd88168f987a08a877e00e31d67c7bdcf3f Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 03:35:34 +0800 Subject: [PATCH 53/82] uypdate cosign-release: "v1.13.1" --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 909d63b..e577bc8 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -42,7 +42,7 @@ jobs: if: ${{ github.event_name != 'pull_request' }} uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 with: - cosign-release: 'v1.9.0' + cosign-release: "v1.13.1" # You may pin to the exact commit or the version. # uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 From 6755319c17f7265e870cfe9900ce01615f614154 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 06:25:52 +0800 Subject: [PATCH 54/82] use github action auto test --- .github/workflows/docker-publish.yml | 32 +++++++++++----- docker-compose.build.yaml | 21 ++++++++++ docker-compose.test.yaml | 57 ++++++++++++++++++++++++++++ test/load.sh | 7 +++- test/remotes.txt | 4 +- 5 files changed, 107 insertions(+), 14 deletions(-) create mode 100644 docker-compose.build.yaml create mode 100644 docker-compose.test.yaml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 772f455..f384d23 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,11 +7,11 @@ name: Docker on: push: - branches: [ "master" , "develop" , "patch-*" ] + branches: ["master", "develop", "patch-*"] # Publish semver tags as releases. - tags: [ 'v*.*.*' ] + tags: ["v*.*.*"] pull_request: - branches: [ "master", "develop" , "patch-*" ] + branches: ["master", "develop", "patch-*"] env: # Use docker.io for Docker Hub if empty @@ -20,10 +20,8 @@ env: # github.repository as / IMAGE_NAME: ${{ github.repository }} - jobs: build: - runs-on: ubuntu-latest permissions: contents: read @@ -42,13 +40,13 @@ jobs: if: github.event_name != 'pull_request' uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 with: - cosign-release: 'v1.9.0' - + cosign-release: "v1.9.0" + # You may pin to the exact commit or the version. # uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 - name: Set up QEMU uses: docker/setup-qemu-action@v2 - + # Workaround: https://github.com/docker/build-push-action/issues/461 - name: Setup Docker buildx uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf @@ -76,10 +74,26 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} - + + - name: Build and export to Docker + uses: docker/build-push-action@v3 + with: + context: . + load: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test + cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache + cache-to: type=inline + + - name: Test + run: | + docker compose -f ./docker-compose.test.yaml up -d + docker exec -t gitweb-test3 chmod +x /opt/gitweb/test/load.sh + docker exec -t gitweb-test3 /opt/gitweb/test/load.sh + # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image + if: ${{ github.event_name != 'pull_request' }} id: build-and-push uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a with: diff --git a/docker-compose.build.yaml b/docker-compose.build.yaml new file mode 100644 index 0000000..d4da3e4 --- /dev/null +++ b/docker-compose.build.yaml @@ -0,0 +1,21 @@ +version: "3" + +volumes: + gitweb: + + +services: + gitweb: + image: ${REGISTRY}${REGISTRY+/}fraoustin/gitweb + container_name: gitweb + hostname: gitweb-test + build: + # context: https://github.com/fraoustin/gitweb.git + context: . + dockerfile: Dockerfile + +# e.g +# linux: export REGISTRY=docker.io +# powershell: $env:registry.your.domain +# docker compose -f .\docker-compose.build.yaml build +# docker compose -f .\docker-compose.build.yaml push \ No newline at end of file diff --git a/docker-compose.test.yaml b/docker-compose.test.yaml new file mode 100644 index 0000000..a1cd69e --- /dev/null +++ b/docker-compose.test.yaml @@ -0,0 +1,57 @@ +version: "3" + +volumes: + gitweb-1: + gitweb-2: + gitweb-3: + + +services: + + gitweb-test1: + image: fraoustin/gitweb + container_name: gitweb-test1 + hostname: gitweb-test1 + environment: + - CONTAINER_TIMEZONE=Europe/Paris + - GITUSER=gituser + - GITPASSWORD=gitpassword + - GITPROJECT=test1 + - URLPATH=/ + - GITHIGHLIGHT=1 + - IHM=mdl + restart: always + volumes: + - gitweb-1:/var/lib/git/ + + gitweb-test2: + image: fraoustin/gitweb + container_name: gitweb-test2 + hostname: gitweb-test2 + environment: + - CONTAINER_TIMEZONE=Europe/Paris + - GITUSER=gituser + - GITPASSWORD=gitpassword + - GITPROJECT=test2 + - FORCEPUSH="true" + - URLPATH=/path/ + restart: always + volumes: + - gitweb-2:/var/lib/git/ + - ./test/:/opt/gitweb/remote/ + + gitweb-test3: + image: fraoustin/gitweb + container_name: gitweb-test3 + hostname: gitweb-test3 + environment: + - CONTAINER_TIMEZONE=Europe/Paris + - GITUSER=gituser + - GITPASSWORD=gitpassword + - GITPROJECT=test + - FORCEPUSH="" + - URLPATH=/ + restart: always + volumes: + - gitweb-3:/var/lib/git/ + - ./test/:/opt/gitweb/test/ diff --git a/test/load.sh b/test/load.sh index 07dac22..47b4dd0 100755 --- a/test/load.sh +++ b/test/load.sh @@ -1,6 +1,6 @@ #!/bin/bash cd /tmp -git clone http://gituser:gitpassword@localhost:8080/test.git +git clone http://gituser:gitpassword@localhost:80/test.git cd test git branch master git checkout master @@ -82,4 +82,7 @@ git commit -m "commit 56" --allow-empty git commit -m "commit 57" --allow-empty git commit -m "commit 58" --allow-empty git commit -m "commit 59" --allow-empty -git push \ No newline at end of file +git push +git add remote gitweb-test2 https://gituser:gitpassword@gitweb-test1:80/path/test2.git +git push --all gitweb-test2 + diff --git a/test/remotes.txt b/test/remotes.txt index 06b4e39..c7bc95a 100644 --- a/test/remotes.txt +++ b/test/remotes.txt @@ -1,3 +1 @@ -gitweb-test1 https://gituser:gitpassword@gitweb-test1 -gitweb-test2 https://gituser:gitpassword@gitweb-test2 -gitweb-test3 https://gituser:gitpassword@gitweb-test3 \ No newline at end of file +gitweb-test1 https://gituser:gitpassword@gitweb-test1:80/test1.git \ No newline at end of file From f7ac8db3a1a90388a88a25137b7fa8bc6c0c6765 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 06:33:20 +0800 Subject: [PATCH 55/82] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=B8=AD=E5=87=BA=E7=8E=B0=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 1 + README.md | 2 +- docker-compose.test.yaml | 18 +++++++++++------- test/load.sh | 4 ++-- test/remotes.txt | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index f384d23..51292ca 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -87,6 +87,7 @@ jobs: - name: Test run: | docker compose -f ./docker-compose.test.yaml up -d + sleep 10 docker exec -t gitweb-test3 chmod +x /opt/gitweb/test/load.sh docker exec -t gitweb-test3 /opt/gitweb/test/load.sh diff --git a/README.md b/README.md index 7ad56f4..ee7de7d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ load when start image load file in - GITUSER (default gituser) - GITPASSWORD (default gitpassword) - GITHIGHLIGHT (default `0`) -- IHM (default "") +- IHM (default "no-mdl") - FORCEPUSH ("" or every not blank string) manage force push to upstream when Downstream branch push ## Volume diff --git a/docker-compose.test.yaml b/docker-compose.test.yaml index a1cd69e..befe660 100644 --- a/docker-compose.test.yaml +++ b/docker-compose.test.yaml @@ -9,14 +9,14 @@ volumes: services: gitweb-test1: - image: fraoustin/gitweb + image: fraoustin/gitweb:test container_name: gitweb-test1 hostname: gitweb-test1 environment: - CONTAINER_TIMEZONE=Europe/Paris - GITUSER=gituser - GITPASSWORD=gitpassword - - GITPROJECT=test1 + - GITPROJECT=test - URLPATH=/ - GITHIGHLIGHT=1 - IHM=mdl @@ -25,33 +25,37 @@ services: - gitweb-1:/var/lib/git/ gitweb-test2: - image: fraoustin/gitweb + image: fraoustin/gitweb:test container_name: gitweb-test2 hostname: gitweb-test2 environment: - CONTAINER_TIMEZONE=Europe/Paris - GITUSER=gituser - GITPASSWORD=gitpassword - - GITPROJECT=test2 + - GITPROJECT=test - FORCEPUSH="true" - URLPATH=/path/ restart: always volumes: - gitweb-2:/var/lib/git/ - ./test/:/opt/gitweb/remote/ - + links : + - gitweb-test1 gitweb-test3: - image: fraoustin/gitweb + image: fraoustin/gitweb:test container_name: gitweb-test3 hostname: gitweb-test3 environment: - CONTAINER_TIMEZONE=Europe/Paris - GITUSER=gituser - GITPASSWORD=gitpassword - - GITPROJECT=test + - GITPROJECT=test3 - FORCEPUSH="" - URLPATH=/ restart: always volumes: - gitweb-3:/var/lib/git/ - ./test/:/opt/gitweb/test/ + links : + - gitweb-test1 + - gitweb-test2 \ No newline at end of file diff --git a/test/load.sh b/test/load.sh index 47b4dd0..5cdccf4 100755 --- a/test/load.sh +++ b/test/load.sh @@ -1,6 +1,6 @@ #!/bin/bash cd /tmp -git clone http://gituser:gitpassword@localhost:80/test.git +git clone http://gituser:gitpassword@gitweb-test3:80/test3.git cd test git branch master git checkout master @@ -83,6 +83,6 @@ git commit -m "commit 57" --allow-empty git commit -m "commit 58" --allow-empty git commit -m "commit 59" --allow-empty git push -git add remote gitweb-test2 https://gituser:gitpassword@gitweb-test1:80/path/test2.git +git add remote gitweb-test2 https://gituser:gitpassword@gitweb-test1:80/path/test.git git push --all gitweb-test2 diff --git a/test/remotes.txt b/test/remotes.txt index c7bc95a..8aa9713 100644 --- a/test/remotes.txt +++ b/test/remotes.txt @@ -1 +1 @@ -gitweb-test1 https://gituser:gitpassword@gitweb-test1:80/test1.git \ No newline at end of file +gitweb-test1 https://gituser:gitpassword@gitweb-test1:80 \ No newline at end of file From 11a0f7db08386afc2c334a5264ad0eea664fc563 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 06:38:16 +0800 Subject: [PATCH 56/82] =?UTF-8?q?pr=E6=8F=90=E4=BA=A4=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E4=B8=8D=E9=80=9A=E8=BF=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 5 +++-- docker-compose.test.yaml | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 51292ca..0e5f449 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -37,7 +37,7 @@ jobs: # Install the cosign tool except on PR # https://github.com/sigstore/cosign-installer - name: Install cosign - if: github.event_name != 'pull_request' + if: ${{ github.event_name != 'pull_request' }} uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 with: cosign-release: "v1.9.0" @@ -54,7 +54,7 @@ jobs: # Login against a Docker registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' + if: ${{ github.event_name != 'pull_request' }} uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c with: registry: ${{ env.REGISTRY }} @@ -86,6 +86,7 @@ jobs: - name: Test run: | + export ${IMAGE_NAME}=${{ env.IMAGE_NAME }} docker compose -f ./docker-compose.test.yaml up -d sleep 10 docker exec -t gitweb-test3 chmod +x /opt/gitweb/test/load.sh diff --git a/docker-compose.test.yaml b/docker-compose.test.yaml index befe660..c278f5a 100644 --- a/docker-compose.test.yaml +++ b/docker-compose.test.yaml @@ -9,7 +9,7 @@ volumes: services: gitweb-test1: - image: fraoustin/gitweb:test + image: ${IMAGE_NAME}:test container_name: gitweb-test1 hostname: gitweb-test1 environment: @@ -25,7 +25,7 @@ services: - gitweb-1:/var/lib/git/ gitweb-test2: - image: fraoustin/gitweb:test + image: ${IMAGE_NAME}:test container_name: gitweb-test2 hostname: gitweb-test2 environment: @@ -42,7 +42,7 @@ services: links : - gitweb-test1 gitweb-test3: - image: fraoustin/gitweb:test + image: ${IMAGE_NAME}:test container_name: gitweb-test3 hostname: gitweb-test3 environment: From 09a196471ded499ae578b66ae1fa643329e00427 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 06:39:35 +0800 Subject: [PATCH 57/82] =?UTF-8?q?=20pr=E6=8F=90=E4=BA=A4=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E4=B8=8D=E9=80=9A=E8=BF=87=E9=97=AE=E9=A2=98:=20IMAGE=5FNAME?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 0e5f449..33f321d 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -86,7 +86,6 @@ jobs: - name: Test run: | - export ${IMAGE_NAME}=${{ env.IMAGE_NAME }} docker compose -f ./docker-compose.test.yaml up -d sleep 10 docker exec -t gitweb-test3 chmod +x /opt/gitweb/test/load.sh From d096ae1221548144e61a75e1f85500c030a405b9 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 06:42:14 +0800 Subject: [PATCH 58/82] =?UTF-8?q?fixbug:=20pr=E6=8F=90=E4=BA=A4=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E4=B8=8D=E9=80=9A=E8=BF=87=E9=97=AE=E9=A2=98:=20test3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 1 + test/load.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 33f321d..9d8165b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -86,6 +86,7 @@ jobs: - name: Test run: | + docker compose -f ./docker-compose.test.yaml config docker compose -f ./docker-compose.test.yaml up -d sleep 10 docker exec -t gitweb-test3 chmod +x /opt/gitweb/test/load.sh diff --git a/test/load.sh b/test/load.sh index 5cdccf4..cdb636d 100755 --- a/test/load.sh +++ b/test/load.sh @@ -1,7 +1,7 @@ #!/bin/bash cd /tmp git clone http://gituser:gitpassword@gitweb-test3:80/test3.git -cd test +cd test3 git branch master git checkout master git commit -m "branch master" --allow-empty From c0813298d1356e04c833a104dea6289161438d37 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 06:44:26 +0800 Subject: [PATCH 59/82] =?UTF-8?q?fixbug:=20pr=E6=8F=90=E4=BA=A4=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E4=B8=8D=E9=80=9A=E8=BF=87=E9=97=AE=E9=A2=98:=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/load.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/load.sh b/test/load.sh index cdb636d..704b5a0 100755 --- a/test/load.sh +++ b/test/load.sh @@ -83,6 +83,6 @@ git commit -m "commit 57" --allow-empty git commit -m "commit 58" --allow-empty git commit -m "commit 59" --allow-empty git push -git add remote gitweb-test2 https://gituser:gitpassword@gitweb-test1:80/path/test.git +git add remote gitweb-test2 https://gituser:gitpassword@gitweb-test:80/path/test.git git push --all gitweb-test2 From 80a8511870eb93f9a8f1693c6508c041b8146179 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 06:48:38 +0800 Subject: [PATCH 60/82] =?UTF-8?q?fixbug:=20pr=E6=8F=90=E4=BA=A4=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E4=B8=8D=E9=80=9A=E8=BF=87=E9=97=AE=E9=A2=98:=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/load.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/load.sh b/test/load.sh index 704b5a0..74d7e49 100755 --- a/test/load.sh +++ b/test/load.sh @@ -1,4 +1,5 @@ #!/bin/bash +sed -x cd /tmp git clone http://gituser:gitpassword@gitweb-test3:80/test3.git cd test3 @@ -83,6 +84,6 @@ git commit -m "commit 57" --allow-empty git commit -m "commit 58" --allow-empty git commit -m "commit 59" --allow-empty git push -git add remote gitweb-test2 https://gituser:gitpassword@gitweb-test:80/path/test.git +git add remote gitweb-test2 https://gituser:gitpassword@gitweb-test2:80/path/test.git git push --all gitweb-test2 From afa49ffa261fc46052fbf4118c0ccfce60ec233b Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 06:55:45 +0800 Subject: [PATCH 61/82] set -x --- test/load.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/load.sh b/test/load.sh index 74d7e49..14fb9fa 100755 --- a/test/load.sh +++ b/test/load.sh @@ -1,5 +1,9 @@ #!/bin/bash -sed -x +set -x + +git config --global user.email "you@example.com" +git config --global user.name "Your Name" + cd /tmp git clone http://gituser:gitpassword@gitweb-test3:80/test3.git cd test3 From b6915ff78205cd8c1386e8faee2fb7b5190c0473 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 06:59:26 +0800 Subject: [PATCH 62/82] fixbug: add remote - git remote add --- test/load.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/load.sh b/test/load.sh index 14fb9fa..e20c0e5 100755 --- a/test/load.sh +++ b/test/load.sh @@ -88,6 +88,7 @@ git commit -m "commit 57" --allow-empty git commit -m "commit 58" --allow-empty git commit -m "commit 59" --allow-empty git push -git add remote gitweb-test2 https://gituser:gitpassword@gitweb-test2:80/path/test.git + +git remote add gitweb-test2 https://gituser:gitpassword@gitweb-test2:80/path/test.git git push --all gitweb-test2 From 9aed30c299a29c5bccc8f81430e68dc0e49c26c8 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 07:01:24 +0800 Subject: [PATCH 63/82] fixbug: remote not https --- test/load.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/load.sh b/test/load.sh index e20c0e5..d2dd77b 100755 --- a/test/load.sh +++ b/test/load.sh @@ -89,6 +89,6 @@ git commit -m "commit 58" --allow-empty git commit -m "commit 59" --allow-empty git push -git remote add gitweb-test2 https://gituser:gitpassword@gitweb-test2:80/path/test.git +git remote add gitweb-test2 http://gituser:gitpassword@gitweb-test2:80/path/test.git git push --all gitweb-test2 From 5940307eabee81bed26b46215a44bfde7090d674 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 08:22:20 +0800 Subject: [PATCH 64/82] =?UTF-8?q?fixbug:=20pr=E6=8F=90=E4=BA=A4=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E4=B8=8D=E9=80=9A=E8=BF=87=E9=97=AE=E9=A2=98:=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 5 +++-- Dockerfile | 2 +- README.md | 3 ++- docker-compose.test.yaml | 25 ++++++++++++++++--------- docker-compose.yaml | 2 +- src/entrypoint.sh | 4 ++-- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index cab7fc7..8dcb405 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,11 +40,12 @@ jobs: if: ${{ github.event_name != 'pull_request' }} uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 with: - cosign-release: "v1.13.1" - + cosign-release: "v1.9.0" + # You may pin to the exact commit or the version. # uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 - name: Set up QEMU + if: ${{ false }} # do not need uses: docker/setup-qemu-action@v2 # Workaround: https://github.com/docker/build-push-action/issues/461 diff --git a/Dockerfile b/Dockerfile index c11caef..9066c39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,7 +61,7 @@ RUN chmod +x /opt/gitweb/post-receive ENV FORCEPUSH "" # Setting base url via Docker -ENV URLPATH / +ENV my_uri / VOLUME /opt/gitweb/remote/ diff --git a/README.md b/README.md index ee7de7d..99c1d39 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ load when start image load file in - GITHIGHLIGHT (default `0`) - IHM (default "no-mdl") - FORCEPUSH ("" or every not blank string) manage force push to upstream when Downstream branch push +- my_uri set base url `/path/to/` `/` ## Volume @@ -134,7 +135,7 @@ if don't want force push, **DO NOT** set environment: FORCEPUSH ## Setting base url via Docker environment -use environment *URLPATH* to set base url +use environment `my_uri` to set base url `/path/to/` `/` ## Usage by Dockerfile diff --git a/docker-compose.test.yaml b/docker-compose.test.yaml index c278f5a..13ac03c 100644 --- a/docker-compose.test.yaml +++ b/docker-compose.test.yaml @@ -9,7 +9,8 @@ volumes: services: gitweb-test1: - image: ${IMAGE_NAME}:test + build: . + image: ${IMAGE_NAME} container_name: gitweb-test1 hostname: gitweb-test1 environment: @@ -17,15 +18,17 @@ services: - GITUSER=gituser - GITPASSWORD=gitpassword - GITPROJECT=test - - URLPATH=/ + - my_uri=/ - GITHIGHLIGHT=1 - IHM=mdl restart: always volumes: - gitweb-1:/var/lib/git/ + ports: + - 8080:80 gitweb-test2: - image: ${IMAGE_NAME}:test + image: ${IMAGE_NAME} container_name: gitweb-test2 hostname: gitweb-test2 environment: @@ -34,15 +37,17 @@ services: - GITPASSWORD=gitpassword - GITPROJECT=test - FORCEPUSH="true" - - URLPATH=/path/ + - my_uri=/path/to/ restart: always volumes: - gitweb-2:/var/lib/git/ - ./test/:/opt/gitweb/remote/ - links : + links: - gitweb-test1 + ports: + - 8081:80 gitweb-test3: - image: ${IMAGE_NAME}:test + image: ${IMAGE_NAME} container_name: gitweb-test3 hostname: gitweb-test3 environment: @@ -51,11 +56,13 @@ services: - GITPASSWORD=gitpassword - GITPROJECT=test3 - FORCEPUSH="" - - URLPATH=/ + - my_uri=/ restart: always volumes: - gitweb-3:/var/lib/git/ - ./test/:/opt/gitweb/test/ - links : + links: - gitweb-test1 - - gitweb-test2 \ No newline at end of file + - gitweb-test2 + ports: + - 8082:80 diff --git a/docker-compose.yaml b/docker-compose.yaml index c3a3845..e06489f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -18,7 +18,7 @@ services: - GITPASSWORD=gitpassword - GITPROJECT=test - FORCEPUSH="" - - URLPATH=/ + - my_uri=/ - GITHIGHLIGHT=1 ports: - 80:80 diff --git a/src/entrypoint.sh b/src/entrypoint.sh index dae2d20..7757986 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -35,9 +35,9 @@ if [ "$1" = 'app' ]; then echo '# enable syntax highlighting' >> /etc/gitweb.conf echo "\$feature{'highlight'}{'default'} = [1];" >> /etc/gitweb.conf fi - if [ -n "${URLPATH}" ]; then + if [ -n "${my_uri}" ]; then sed -n '10p' /etc/nginx/conf.d/default.conf - sed -i "10s|.*| location ${URLPATH} {|" /etc/nginx/conf.d/default.conf + sed -i "10s|.*| location ${my_uri} {|" /etc/nginx/conf.d/default.conf sed -n '10p' /etc/nginx/conf.d/default.conf fi service fcgiwrap start From c59e16a84f5ca61ef91bdf0ac2c7506340d4d792 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 08:24:33 +0800 Subject: [PATCH 65/82] test tag --- docker-compose.test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.test.yaml b/docker-compose.test.yaml index 13ac03c..f0cdeb1 100644 --- a/docker-compose.test.yaml +++ b/docker-compose.test.yaml @@ -10,7 +10,7 @@ services: gitweb-test1: build: . - image: ${IMAGE_NAME} + image: ${IMAGE_NAME}:test container_name: gitweb-test1 hostname: gitweb-test1 environment: @@ -28,7 +28,7 @@ services: - 8080:80 gitweb-test2: - image: ${IMAGE_NAME} + image: ${IMAGE_NAME}:test container_name: gitweb-test2 hostname: gitweb-test2 environment: @@ -47,7 +47,7 @@ services: ports: - 8081:80 gitweb-test3: - image: ${IMAGE_NAME} + image: ${IMAGE_NAME}:test container_name: gitweb-test3 hostname: gitweb-test3 environment: From c6cec91fa6d01fb858ba237ae022298632f684d7 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 09:03:35 +0800 Subject: [PATCH 66/82] bug --- docker-compose.test.yaml | 2 +- test/load.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docker-compose.test.yaml b/docker-compose.test.yaml index f0cdeb1..2b521e1 100644 --- a/docker-compose.test.yaml +++ b/docker-compose.test.yaml @@ -37,7 +37,7 @@ services: - GITPASSWORD=gitpassword - GITPROJECT=test - FORCEPUSH="true" - - my_uri=/path/to/ + - my_uri=/ restart: always volumes: - gitweb-2:/var/lib/git/ diff --git a/test/load.sh b/test/load.sh index d2dd77b..138ddd0 100755 --- a/test/load.sh +++ b/test/load.sh @@ -89,6 +89,11 @@ git commit -m "commit 58" --allow-empty git commit -m "commit 59" --allow-empty git push + +# not working mabe /etc/gitweb.conf need change git remote add gitweb-test2 http://gituser:gitpassword@gitweb-test2:80/path/test.git + +git remote add gitweb-test2 http://gituser:gitpassword@gitweb-test2:80/test.git + git push --all gitweb-test2 From 800b574842258c17c58efed4899557afba0acb1c Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 09:06:31 +0800 Subject: [PATCH 67/82] bug --- docker-compose.test.yaml | 2 ++ test/load.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.test.yaml b/docker-compose.test.yaml index 2b521e1..613c7bd 100644 --- a/docker-compose.test.yaml +++ b/docker-compose.test.yaml @@ -37,6 +37,8 @@ services: - GITPASSWORD=gitpassword - GITPROJECT=test - FORCEPUSH="true" + # NOT WORK + # - my_uri=/path/to/ - my_uri=/ restart: always volumes: diff --git a/test/load.sh b/test/load.sh index 138ddd0..313999b 100755 --- a/test/load.sh +++ b/test/load.sh @@ -91,7 +91,7 @@ git push # not working mabe /etc/gitweb.conf need change -git remote add gitweb-test2 http://gituser:gitpassword@gitweb-test2:80/path/test.git +# git remote add gitweb-test2 http://gituser:gitpassword@gitweb-test2:80/path/to/test.git git remote add gitweb-test2 http://gituser:gitpassword@gitweb-test2:80/test.git From 82e32286693d92c1fc34c8aab138e90cda3587ba Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 09:16:32 +0800 Subject: [PATCH 68/82] formate --- Dockerfile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9066c39..b771caa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,23 +4,23 @@ LABEL maintainer "fraoustin@gmail.com" COPY ./src/default.conf /etc/nginx/conf.d/default.conf -COPY ./src/entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh +COPY ./src/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh ENV SET_CONTAINER_TIMEZONE false ENV CONTAINER_TIMEZONE "" RUN apt-get update \ - && apt-get install -y \ - apache2-utils \ - fcgiwrap \ - git \ - git-core \ - gitweb \ - highlight \ - libcgi-pm-perl \ - mime-support \ - spawn-fcgi \ + && apt-get install -y \ + apache2-utils \ + fcgiwrap \ + git \ + git-core \ + gitweb \ + highlight \ + libcgi-pm-perl \ + mime-support \ + spawn-fcgi \ && apt-get autoclean \ && rm -rf /var/lib/apt/lists/* From 3dce3a6e324a5efe8df39a00c2b0e7e93e84456a Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 09:26:03 +0800 Subject: [PATCH 69/82] some platforms build faild --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8dcb405..2549112 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -102,10 +102,10 @@ jobs: with: context: . push: ${{ github.event_name != 'pull_request' }} - platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/arm/v7,linux/arm/v5 + platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache + cache-from: type=inline cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max # Sign the resulting Docker image digest except on PRs. # This will only write to the public Rekor transparency log when the Docker From 142b5b93f05c52582276aa69f5ba6da38101729b Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 09:30:14 +0800 Subject: [PATCH 70/82] change nginx to stable --- .github/workflows/docker-publish.yml | 1 + Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 2549112..3ee3ef1 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -102,6 +102,7 @@ jobs: with: context: . push: ${{ github.event_name != 'pull_request' }} + # platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/arm/v7,linux/arm/v5 platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index b771caa..cbc3bcc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:latest +FROM nginx:stable LABEL maintainer "fraoustin@gmail.com" From 28b89fddc9bdf9a9bc00e638a45a4e3cb18fb7f8 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 09:34:33 +0800 Subject: [PATCH 71/82] build no-cache: true --- .github/workflows/docker-publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 3ee3ef1..a7c6afb 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -106,6 +106,7 @@ jobs: platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + no-cache: true cache-from: type=inline cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max # Sign the resulting Docker image digest except on PRs. From 3ad433ecfdfc15f216b46f46e575292d526cb219 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 12:41:00 +0800 Subject: [PATCH 72/82] why can't build pass --- .github/workflows/docker-publish.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a7c6afb..756dfc4 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -82,8 +82,8 @@ jobs: context: . load: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test - cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache - cache-to: type=inline + # cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache + # cache-to: type=inline - name: Test run: | @@ -103,12 +103,12 @@ jobs: context: . push: ${{ github.event_name != 'pull_request' }} # platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/arm/v7,linux/arm/v5 - platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7 + platforms: linux/386,linux/arm64,linux/amd64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} no-cache: true - cache-from: type=inline - cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max + # cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache + # cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max # Sign the resulting Docker image digest except on PRs. # This will only write to the public Rekor transparency log when the Docker # repository is public to avoid leaking data. If you would like to publish From 70a903416c53bdcfdcbc8cad273c1802fbce9756 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 12:51:17 +0800 Subject: [PATCH 73/82] use nginx :1.23 --- .github/workflows/docker-publish.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 756dfc4..2572df7 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -98,7 +98,7 @@ jobs: - name: Build and push Docker image if: ${{ github.event_name != 'pull_request' }} id: build-and-push - uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + uses: docker/build-push-action@v3 with: context: . push: ${{ github.event_name != 'pull_request' }} diff --git a/Dockerfile b/Dockerfile index cbc3bcc..81f9be5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:stable +FROM nginx:1.23 LABEL maintainer "fraoustin@gmail.com" From 38566429374554c01eb2ed9513dfb70e143936ff Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 12:55:27 +0800 Subject: [PATCH 74/82] use build-push-action@v2 --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 2572df7..9a0a505 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -98,7 +98,7 @@ jobs: - name: Build and push Docker image if: ${{ github.event_name != 'pull_request' }} id: build-and-push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v2 with: context: . push: ${{ github.event_name != 'pull_request' }} From 25d26bdb9395dc6bc264bcae613ed8ed5a066514 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 13:14:27 +0800 Subject: [PATCH 75/82] Who broke it Who broke it --- .github/workflows/docker-publish.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 9a0a505..efc81ee 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -38,25 +38,25 @@ jobs: # https://github.com/sigstore/cosign-installer - name: Install cosign if: ${{ github.event_name != 'pull_request' }} - uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25 + uses: sigstore/cosign-installer@main with: - cosign-release: "v1.9.0" + cosign-release: "v1.13.1" # You may pin to the exact commit or the version. - # uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 + # uses: docker/setup-qemu-action@2 - name: Set up QEMU if: ${{ false }} # do not need uses: docker/setup-qemu-action@v2 # Workaround: https://github.com/docker/build-push-action/issues/461 - name: Setup Docker buildx - uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + uses: docker/setup-buildx-action@2 # Login against a Docker registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} if: ${{ github.event_name != 'pull_request' }} - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + uses: docker/login-action@2 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -66,7 +66,7 @@ jobs: # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@4 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | @@ -98,12 +98,12 @@ jobs: - name: Build and push Docker image if: ${{ github.event_name != 'pull_request' }} id: build-and-push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: . push: ${{ github.event_name != 'pull_request' }} # platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/arm/v7,linux/arm/v5 - platforms: linux/386,linux/arm64,linux/amd64 + platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} no-cache: true From 83ac41ddb40af90cae67f36d9701e59650181ef5 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 13:16:41 +0800 Subject: [PATCH 76/82] action v --- .github/workflows/docker-publish.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index efc81ee..c31c03b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -43,20 +43,20 @@ jobs: cosign-release: "v1.13.1" # You may pin to the exact commit or the version. - # uses: docker/setup-qemu-action@2 + # uses: docker/setup-qemu-action@v2 - name: Set up QEMU if: ${{ false }} # do not need uses: docker/setup-qemu-action@v2 # Workaround: https://github.com/docker/build-push-action/issues/461 - name: Setup Docker buildx - uses: docker/setup-buildx-action@2 + uses: docker/setup-buildx-action@v2 # Login against a Docker registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} if: ${{ github.event_name != 'pull_request' }} - uses: docker/login-action@2 + uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -66,7 +66,7 @@ jobs: # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta - uses: docker/metadata-action@4 + uses: docker/metadata-action@v4 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | From 52778577d8fa84a35da763e541064b0695a1b763 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 14:00:44 +0800 Subject: [PATCH 77/82] install bash --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 81f9be5..a867f9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:1.23 +FROM nginx:stable LABEL maintainer "fraoustin@gmail.com" @@ -12,6 +12,7 @@ ENV CONTAINER_TIMEZONE "" RUN apt-get update \ && apt-get install -y \ + bash \ apache2-utils \ fcgiwrap \ git \ From 193dd083671a87555d1e74491b94961bcc74b18e Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 14:17:48 +0800 Subject: [PATCH 78/82] step apt-get --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index a867f9a..58caeb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,8 @@ RUN chmod +x /entrypoint.sh ENV SET_CONTAINER_TIMEZONE false ENV CONTAINER_TIMEZONE "" -RUN apt-get update \ - && apt-get install -y \ +RUN apt-get -qq update +RUN apt-get -qq install -y \ bash \ apache2-utils \ fcgiwrap \ @@ -21,9 +21,9 @@ RUN apt-get update \ highlight \ libcgi-pm-perl \ mime-support \ - spawn-fcgi \ - && apt-get autoclean \ - && rm -rf /var/lib/apt/lists/* + spawn-fcgi +RUN apt-get autoclean +RUN rm -rf /var/lib/apt/lists/* # manage user load fcgiwrap RUN sed -i "s/www-data/nginx/g" /etc/init.d/fcgiwrap From a9cc09c855baec62ec9373c6238207db44475ff2 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 14:20:23 +0800 Subject: [PATCH 79/82] DEBIAN_FRONTEND=noninteractive --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 58caeb8..0714071 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN chmod +x /entrypoint.sh ENV SET_CONTAINER_TIMEZONE false ENV CONTAINER_TIMEZONE "" - +ARG DEBIAN_FRONTEND=noninteractive RUN apt-get -qq update RUN apt-get -qq install -y \ bash \ From 1e3f5648e224b67cd7c52315b6a9ae30eefb9707 Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 15:33:26 +0800 Subject: [PATCH 80/82] local build test pass --- Dockerfile | 5 ++- Dockerfile.CN | 80 +++++++++++++++++++++++++++++++++++++++ README.md | 2 + docker-compose.build.yaml | 13 +++++-- docker-compose.test.yaml | 16 +++++--- src/entrypoint.sh | 30 ++++++++------- test/load.sh | 10 ++--- 7 files changed, 124 insertions(+), 32 deletions(-) create mode 100644 Dockerfile.CN diff --git a/Dockerfile b/Dockerfile index 0714071..7d52fc5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM nginx:stable LABEL maintainer "fraoustin@gmail.com" - +# RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list +# RUN sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list COPY ./src/default.conf /etc/nginx/conf.d/default.conf COPY ./src/entrypoint.sh /entrypoint.sh @@ -59,7 +60,7 @@ RUN mkdir /usr/share/gitweb/ihm WORKDIR /opt/gitweb/ COPY ./src/hooks/post-receive /opt/gitweb/post-receive RUN chmod +x /opt/gitweb/post-receive -ENV FORCEPUSH "" +ENV FORCEPUSH '' # Setting base url via Docker ENV my_uri / diff --git a/Dockerfile.CN b/Dockerfile.CN new file mode 100644 index 0000000..f08562e --- /dev/null +++ b/Dockerfile.CN @@ -0,0 +1,80 @@ +FROM nginx:stable + +LABEL maintainer "fraoustin@gmail.com" +RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list +RUN sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list +COPY ./src/default.conf /etc/nginx/conf.d/default.conf +WORKDIR /opt/gitweb/ +COPY ./src/entrypoint.sh /opt/gitweb/ +RUN chmod 0755 /opt/gitweb/entrypoint.sh +RUN cat /opt/gitweb/entrypoint.sh + +ENV SET_CONTAINER_TIMEZONE false +ENV CONTAINER_TIMEZONE '' +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get -qq update +RUN apt-get -qq install -y \ + bash \ + apache2-utils \ + fcgiwrap \ + git \ + git-core \ + gitweb \ + highlight \ + libcgi-pm-perl \ + mime-support \ + spawn-fcgi + +RUN apt-get autoclean +RUN rm -rf /var/lib/apt/lists/* + +# manage user load fcgiwrap +RUN sed -i "s/www-data/nginx/g" /etc/init.d/fcgiwrap + +# manage start container +RUN mkdir /usr/share/gitweb/docker-entrypoint.pre +RUN mkdir /usr/share/gitweb/docker-entrypoint.post +COPY ./src/00_init.sh /usr/share/gitweb/docker-entrypoint.pre/00_init.sh +RUN chmod +x -R /usr/share/gitweb/docker-entrypoint.pre + +# add cmd gitweb +COPY ./src/cmd/addrepos.sh /usr/bin/addrepos +COPY ./src/cmd/addauth.sh /usr/bin/addauth +COPY ./src/cmd/rmrepos.sh /usr/bin/rmrepos +COPY ./src/cmd/rmauth.sh /usr/bin/rmauth +RUN chmod +x /usr/bin/addrepos +RUN chmod +x /usr/bin/addauth +RUN chmod +x /usr/bin/rmrepos +RUN chmod +x /usr/bin/rmauth + +# manage default value +ENV GITUSER gituser +ENV GITPASSWORD gitpassword +ENV GITHIGHLIGHT 0 + +# add ihm mdl +ENV IHM no-mdl +COPY ./src/ihm /mdl-ihm +RUN cp /usr/share/gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css.original +RUN mkdir /usr/share/gitweb/ihm + +# force push to upstream +WORKDIR /opt/gitweb/ +COPY ./src/hooks/post-receive /opt/gitweb/ +RUN chmod +x /opt/gitweb/post-receive +ENV FORCEPUSH '' + +# Setting base url via Docker +ENV my_uri '/' + +VOLUME /opt/gitweb/remote/ + +VOLUME /var/lib/git/ + +WORKDIR /var/lib/git/ + +EXPOSE 80 + +# ENTRYPOINT [ ] + +CMD ["/opt/gitweb/entrypoint.sh" ,"app"] diff --git a/README.md b/README.md index 99c1d39..01aeb4a 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,8 @@ if don't want force push, **DO NOT** set environment: FORCEPUSH ## Setting base url via Docker environment use environment `my_uri` to set base url `/path/to/` `/` + but not support clone or push + PLEASE HELP FIX IT ## Usage by Dockerfile diff --git a/docker-compose.build.yaml b/docker-compose.build.yaml index d4da3e4..8fb29cd 100644 --- a/docker-compose.build.yaml +++ b/docker-compose.build.yaml @@ -1,4 +1,4 @@ -version: "3" +version: "3.8" volumes: gitweb: @@ -6,16 +6,21 @@ volumes: services: gitweb: - image: ${REGISTRY}${REGISTRY+/}fraoustin/gitweb + image: ${REGISTRY}${REGISTRY+/}fraoustin/gitweb${TAG+:}${TAG} container_name: gitweb hostname: gitweb-test build: # context: https://github.com/fraoustin/gitweb.git context: . - dockerfile: Dockerfile + dockerfile: Dockerfile.CN + platforms: + - "linux/amd64" + - "linux/386" + - "linux/arm64/v8" + - "linux/arm/v7" # e.g # linux: export REGISTRY=docker.io -# powershell: $env:registry.your.domain +# powershell: $env:REGISTRY='registry.your.domain' # docker compose -f .\docker-compose.build.yaml build # docker compose -f .\docker-compose.build.yaml push \ No newline at end of file diff --git a/docker-compose.test.yaml b/docker-compose.test.yaml index 613c7bd..b0578d1 100644 --- a/docker-compose.test.yaml +++ b/docker-compose.test.yaml @@ -9,7 +9,11 @@ volumes: services: gitweb-test1: - build: . + build: + # context: https://github.com/fraoustin/gitweb.git + context: . + dockerfile: Dockerfile.CN + image: ${IMAGE_NAME}:test container_name: gitweb-test1 hostname: gitweb-test1 @@ -18,7 +22,8 @@ services: - GITUSER=gituser - GITPASSWORD=gitpassword - GITPROJECT=test - - my_uri=/ + - my_uri='/' + - FORCEPUSH="1" - GITHIGHLIGHT=1 - IHM=mdl restart: always @@ -38,8 +43,8 @@ services: - GITPROJECT=test - FORCEPUSH="true" # NOT WORK - # - my_uri=/path/to/ - - my_uri=/ + - my_uri=/path/to/ + # - my_uri='/' restart: always volumes: - gitweb-2:/var/lib/git/ @@ -57,8 +62,7 @@ services: - GITUSER=gituser - GITPASSWORD=gitpassword - GITPROJECT=test3 - - FORCEPUSH="" - - my_uri=/ + - my_uri='/' restart: always volumes: - gitweb-3:/var/lib/git/ diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 7757986..f9b3572 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -1,7 +1,9 @@ #!/bin/bash + +set -x set -e -if [ $CONTAINER_TIMEZONE ] && [ "$SET_CONTAINER_TIMEZONE" = "false" ]; then +if [ $CONTAINER_TIMEZONE ] && [ "$SET_CONTAINER_TIMEZONE" = "false" ]; then echo ${CONTAINER_TIMEZONE} >/etc/timezone && dpkg-reconfigure -f noninteractive tzdata echo "Container timezone set to: $CONTAINER_TIMEZONE" export SET_CONTAINER_TIMEZONE=true @@ -22,27 +24,27 @@ if [ "$1" = 'app' ]; then if [ "$IHM" = 'mdl' ]; then # add IHM cp -R /mdl-ihm/* /usr/share/gitweb/ihm/ - echo '' >> /etc/gitweb.conf - echo '# add conf for IHM mdl' >> /etc/gitweb.conf - echo '$home_text="ihm/hometext.html";' >> /etc/gitweb.conf - echo '$site_header="ihm/header.html";' >> /etc/gitweb.conf - echo '$site_footer="ihm/footer.html";' >> /etc/gitweb.conf - cat /usr/share/gitweb/ihm/headstring.conf >> /etc/gitweb.conf + echo '' >>/etc/gitweb.conf + echo '# add conf for IHM mdl' >>/etc/gitweb.conf + echo '$home_text="ihm/hometext.html";' >>/etc/gitweb.conf + echo '$site_header="ihm/header.html";' >>/etc/gitweb.conf + echo '$site_footer="ihm/footer.html";' >>/etc/gitweb.conf + cat /usr/share/gitweb/ihm/headstring.conf >>/etc/gitweb.conf cp /usr/share/gitweb/ihm/gitweb.css /usr/share/gitweb/static/gitweb.css fi if [ "$GITHIGHLIGHT" = "1" ]; then - echo '' >> /etc/gitweb.conf - echo '# enable syntax highlighting' >> /etc/gitweb.conf - echo "\$feature{'highlight'}{'default'} = [1];" >> /etc/gitweb.conf + echo '' >>/etc/gitweb.conf + echo '# enable syntax highlighting' >>/etc/gitweb.conf + echo "\$feature{'highlight'}{'default'} = [1];" >>/etc/gitweb.conf fi if [ -n "${my_uri}" ]; then - sed -n '10p' /etc/nginx/conf.d/default.conf - sed -i "10s|.*| location ${my_uri} {|" /etc/nginx/conf.d/default.conf - sed -n '10p' /etc/nginx/conf.d/default.conf + sed -n '10p' /etc/nginx/conf.d/default.conf + sed -i "10s|.*| location ${my_uri} {|" /etc/nginx/conf.d/default.conf + sed -n '10p' /etc/nginx/conf.d/default.conf fi service fcgiwrap start nginx -g "daemon off;" /bin/run-parts --verbose --regex '\.(sh)$' "/usr/share/gitweb/docker-entrypoint.post" fi -exec "$@" +eval "$@" diff --git a/test/load.sh b/test/load.sh index 313999b..50c67d1 100755 --- a/test/load.sh +++ b/test/load.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -x +set -x git config --global user.email "you@example.com" git config --global user.name "Your Name" @@ -15,7 +15,7 @@ git branch develop git checkout develop git commit -m "branch develop" --allow-empty git push --set-upstream origin develop -echo "modif 1" >> README.rst +echo "modif 1" >>README.rst git add README.rst git commit -m "modif 1" git push @@ -26,7 +26,7 @@ git push git tag V1 git push origin V1 git checkout develop -echo "modif 2" >> README.rst +echo "modif 2" >>README.rst git add README.rst git commit -m "modif 2" git push @@ -89,11 +89,9 @@ git commit -m "commit 58" --allow-empty git commit -m "commit 59" --allow-empty git push - -# not working mabe /etc/gitweb.conf need change +# not working mabe /etc/gitweb.conf need change # git remote add gitweb-test2 http://gituser:gitpassword@gitweb-test2:80/path/to/test.git git remote add gitweb-test2 http://gituser:gitpassword@gitweb-test2:80/test.git git push --all gitweb-test2 - From 0651d0f0d9b01be77383490a064a4308f054d4fd Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 15:55:42 +0800 Subject: [PATCH 81/82] update Dockerfile.CN --- Dockerfile.CN | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile.CN b/Dockerfile.CN index f08562e..b3cc97b 100644 --- a/Dockerfile.CN +++ b/Dockerfile.CN @@ -1,13 +1,14 @@ FROM nginx:stable LABEL maintainer "fraoustin@gmail.com" + RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list RUN sed -i 's|security.debian.org/debian-security|mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list + COPY ./src/default.conf /etc/nginx/conf.d/default.conf -WORKDIR /opt/gitweb/ -COPY ./src/entrypoint.sh /opt/gitweb/ -RUN chmod 0755 /opt/gitweb/entrypoint.sh -RUN cat /opt/gitweb/entrypoint.sh + +COPY ./src/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh ENV SET_CONTAINER_TIMEZONE false ENV CONTAINER_TIMEZONE '' @@ -60,12 +61,12 @@ RUN mkdir /usr/share/gitweb/ihm # force push to upstream WORKDIR /opt/gitweb/ -COPY ./src/hooks/post-receive /opt/gitweb/ +COPY ./src/hooks/post-receive /opt/gitweb/post-receive RUN chmod +x /opt/gitweb/post-receive ENV FORCEPUSH '' # Setting base url via Docker -ENV my_uri '/' +ENV my_uri / VOLUME /opt/gitweb/remote/ @@ -75,6 +76,6 @@ WORKDIR /var/lib/git/ EXPOSE 80 -# ENTRYPOINT [ ] +ENTRYPOINT ["/entrypoint.sh"] -CMD ["/opt/gitweb/entrypoint.sh" ,"app"] +CMD ["app"] From c28fc1dc85c5b702afe472356ce98a8511168e7c Mon Sep 17 00:00:00 2001 From: ZCTMDC Date: Fri, 4 Nov 2022 15:58:46 +0800 Subject: [PATCH 82/82] =?UTF-8?q?=E4=B8=8D=E9=9C=80=E8=A6=81=E7=9A=84=20se?= =?UTF-8?q?t=20-x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index f9b3572..df0f1cd 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -x +# set -x set -e if [ $CONTAINER_TIMEZONE ] && [ "$SET_CONTAINER_TIMEZONE" = "false" ]; then