+
Skip to content

push to upstream, build use github actions,Setting base url via Docker #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
deef012
add docker-compose.yaml
zctmdc Jun 19, 2022
bed5ad9
add china - docker.cn
zctmdc Jun 19, 2022
63b3695
add docker-compose-CN.yaml for china
zctmdc Jun 19, 2022
571a583
build don't use remote
zctmdc Jun 19, 2022
84a9f59
mor deamo
zctmdc Jun 19, 2022
bb40fa0
Merge branch 'fraoustin:master' into master
zctmdc Aug 12, 2022
f26f790
add: push to upstream
zctmdc Aug 12, 2022
cfb9125
add: add remote and push to upstream when downstream push
zctmdc Aug 12, 2022
b535d07
Create docker-publish.yml
zctmdc Aug 12, 2022
884f758
set latest tag for master branch
zctmdc Aug 12, 2022
13602da
lf to crlf
zctmdc Aug 12, 2022
35955c1
Update docker-publish.yml
zctmdc Aug 12, 2022
b0ed668
why 0755 not working ?
zctmdc Aug 12, 2022
ffd2b99
show more log
zctmdc Aug 12, 2022
1ef8464
chmod -R g+ws .
zctmdc Aug 12, 2022
ecc1791
chmod and chgrp when addrepos
zctmdc Aug 12, 2022
7890af6
use cache
zctmdc Aug 12, 2022
68ca015
change cache name ref
zctmdc Aug 12, 2022
2288669
CRLF to LF
zctmdc Aug 12, 2022
321c015
Merge branch 'master' into develop
zctmdc Aug 12, 2022
a3092c4
Merge branch 'master' into develop
zctmdc Aug 12, 2022
e973cd6
rm docker-compose-CN
zctmdc Aug 12, 2022
a1b8943
Merge branch 'master' of https://github.com/zctmdc/gitweb
zctmdc Aug 12, 2022
2f45f34
add action "develop"
zctmdc Aug 12, 2022
d675222
Setting base url via Docker
zctmdc Aug 12, 2022
101e89c
hand tag for other branch
zctmdc Aug 12, 2022
b882df5
why https://github.com/Mars-Sea/phddns-docker is working
zctmdc Aug 12, 2022
0f9cc08
CRLF to LF
zctmdc Aug 12, 2022
351ce27
re creat it
zctmdc Aug 12, 2022
7e18184
update
zctmdc Aug 12, 2022
18fef60
delete CN
zctmdc Aug 12, 2022
e6eed0c
Delete docker-publish.yml
zctmdc Aug 12, 2022
c8e18b7
Create docker-publish.yml
zctmdc Aug 12, 2022
ae6f045
update
zctmdc Aug 12, 2022
802964a
Merge branch 'master' into develop
zctmdc Aug 12, 2022
5f47fa0
hand other branch
zctmdc Aug 12, 2022
e6cf569
other branch
zctmdc Aug 13, 2022
97e3889
added syntax highlighting feature
rohm1 Aug 27, 2022
2db1cfe
document new GITHIGHLIGHT option
rohm1 Aug 27, 2022
7cf808a
try build arm
zctmdc Sep 4, 2022
a653ea1
add platforms
zctmdc Sep 4, 2022
748a358
change platforms
zctmdc Sep 4, 2022
6a8998c
use nginx:latest
zctmdc Sep 4, 2022
5dab073
Merge branch 'master' into develop
zctmdc Sep 4, 2022
9e7d479
sync nginx platforms
zctmdc Sep 4, 2022
386350d
Merge branch 'pr/9' into develop
zctmdc Sep 4, 2022
8d3cf0b
>Format Document
zctmdc Sep 4, 2022
3e4ddaa
>inline_html-allowed_elements: kbd
zctmdc Sep 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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" , "patch-*" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "master", "develop" , "patch-*" ]

env:
# Use docker.io for Docker Hub if empty
# REGISTRY: ghcr.io
REGISTRY: docker.io
# github.repository as <account>/<repo>
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'

# 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

# 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' }}
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
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 }}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"markdownlint.config": {
"default": true,
"MD033": {
"allowed_elements": ["kbd"]
}
}
}
28 changes: 23 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 \
Expand All @@ -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
Expand All @@ -43,16 +46,31 @@ 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

VOLUME /var/lib/git
WORKDIR /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 ""

# Setting base url via Docker
ENV URLPATH /

VOLUME /opt/gitweb/remote/

VOLUME /var/lib/git/

WORKDIR /var/lib/git/

EXPOSE 80

ENTRYPOINT ["/entrypoint.sh"]

CMD ["app"]
115 changes: 105 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <http://127.0.0.1/>

load when start image load file in

Expand All @@ -14,11 +14,14 @@ load when start image load file in
- GITPROJECT
- GITUSER (default gituser)
- GITPASSWORD (default gitpassword)
- GITHIGHLIGHT (default `0`)
- 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

Expand All @@ -35,29 +38,117 @@ load when start image load file in

run image fraoustin/gitweb

docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITPROJECT=test" -v <localpath>:/var/lib/git --name test -p 80:80 fraoustin/gitweb
```bash
docker run -d -e "CONTAINER_TIMEZONE=Europe/Paris" -e "GITPROJECT=test" \
-v <localpath>:/var/lib/git --name test -p 80:80 fraoustin/gitweb
```

> use <kbd>^</kbd> for *CMD* OR <kbd>`</kbd> for *Powershell*

user default is gituser and password default is gitpassword

you use http://localhost/ for access gitweb
- 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
```

other branch

```bash
git branch --set-upstream-to=<remote>/<branch> <branch>

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

You can change user and password by variable environment
```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 <localpath>:/var/lib/git/ \
-v </path/to/remote/>:/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` ...

## Setting base url via Docker environment

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'
if [ ! -d $REPOS ]; then
Expand All @@ -67,23 +158,27 @@ 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 <localpath>:/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 <localpath>:/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 <localpath>:/var/lib/git --name test -p 80:80 fraoustin/gitweb

```
28 changes: 28 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3"

volumes:
gitweb:


services:
gitweb:
image: fraoustin/gitweb
container_name: gitweb
hostname: gitweb-test
# build:
# context: https://github.com/fraoustin/gitweb.git
# dockerfile: Dockerfile
environment:
- CONTAINER_TIMEZONE=Europe/Paris
- 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/
2 changes: 0 additions & 2 deletions src/00_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载