diff --git a/container/git-proxy/build b/container/git-proxy/build new file mode 100755 index 0000000000000000000000000000000000000000..748a4fa1738fe711c63a0bea8cb8a5338731d4b3 --- /dev/null +++ b/container/git-proxy/build @@ -0,0 +1,18 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2024 Huawei Technologies Co., Ltd. All rights reserved. + +. ../defconfig.sh + +docker_skip_rebuild "git-proxy" + +load_cci_defaults + +if [ ! -d git-mirror-server.git ]; then + git clone https://gitee.com/chengli132/git-mirror-server.git +fi + +cd git-mirror-server && docker build -t git-proxy . + +push_image git-proxy:latest + diff --git a/container/git-proxy/config.toml b/container/git-proxy/config.toml new file mode 100644 index 0000000000000000000000000000000000000000..6242fc4df7b7321cedd9ffb8d87000dfeb2b9c3e --- /dev/null +++ b/container/git-proxy/config.toml @@ -0,0 +1,29 @@ +# ListenAddr is the address the web server listens on for serving the mirrors. +# Defaults to :8080 +ListenAddr = ":8888" +# Interval is the default interval for updating mirrors, can be overridden per +# repo. Defaults to 15 seconds. +Interval = "12h" +# Base path for storing mirrors, absolute or relative. Defaults to "." +BasePath = "/git-mirror/data" + +# An example of a public mirror taking defaults from above. The Name is +# generated from the URL by just taking the host and path. +# +# Will be mirrored at http://localhost:8080/github.com/espressif/git-mirror-server.git +[[Repo]] +Origin = "https://gitee.com/openeuler/kernel.git" + +# It is also possible to set custom names for accessing the repos. +# +# Will be mirrored at http://localhost:8080/custom-name +[[Repo]] +Origin = "https://mirrors.tuna.tsinghua.edu.cn/git/linux-next.git" + +[[Repo]] +Origin = "https://mirrors.tuna.tsinghua.edu.cn/git/linux-stable.git" + +[[Repo]] +Origin = "https://mirrors.tuna.tsinghua.edu.cn/git/linux.git" + + diff --git a/container/git-proxy/start b/container/git-proxy/start new file mode 100755 index 0000000000000000000000000000000000000000..3e6c273205f17d2302a094a960d7313ad72a96e0 --- /dev/null +++ b/container/git-proxy/start @@ -0,0 +1,37 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +. $CCI_SRC/container/defconfig.sh + + +docker_rm git-proxy + +DEFAULT_GIT_CACHE='/srv/git/git-proxy' +DEFAULT_GIT_CONFIG_DIR='/srv/git/git-proxy/config' + +# Ensure the host directories exist +mkdir -p "$DEFAULT_GIT_CACHE" +mkdir -p "$DEFAULT_GIT_CONFIG_DIR" + +# Copy the config file to the expected host location if it's not there. +# This makes the start script more robust. +if [ ! -f "$DEFAULT_GIT_CONFIG_DIR/config.toml" ]; then + echo "Config file not found in $DEFAULT_GIT_CONFIG_DIR, copying from source..." + cp "$(dirname "$0")/config.toml" "$DEFAULT_GIT_CONFIG_DIR/config.toml" +fi + +cmd=( + docker run + --restart=always + -d + --name git-proxy + -v "$DEFAULT_GIT_CACHE":/git-mirror/data + -v "$DEFAULT_GIT_CONFIG_DIR/config.toml":/etc/git-mirror/config.toml + -p 8888:8888 + git-proxy + /etc/git-mirror/config.toml +) + +"${cmd[@]}" +