-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: joshua <i@joshua.su>
- Loading branch information
0 parents
commit 0cf9afb
Showing
8 changed files
with
282 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.github/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Build dev image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Docker metadata | ||
id: metadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: ./Dockerfile | ||
push: true | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
platforms: linux/amd64 | ||
tags: ${{ steps.metadata.outputs.tags }} | ||
annotations: ${{ steps.metadata.outputs.annotations }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# | ||
# Project specific excludes | ||
# | ||
|
||
tomcat | ||
|
||
# | ||
# Default excludes | ||
# | ||
|
||
# Binaries | ||
*.7z | ||
*.dmg | ||
*.gz | ||
*.iso | ||
*.jar | ||
*.rar | ||
*.tar | ||
*.zip | ||
*.war | ||
*.ear | ||
*.sar | ||
*.class | ||
|
||
# Maven | ||
target/ | ||
|
||
# IntelliJ project files | ||
*.iml | ||
*.iws | ||
*.ipr | ||
.idea/ | ||
|
||
# eclipse project file | ||
.settings/ | ||
.classpath | ||
.project | ||
|
||
# NetBeans specific | ||
nbproject/private/ | ||
build/ | ||
nbbuild/ | ||
dist/ | ||
nbdist/ | ||
nbactions.xml | ||
nb-configuration.xml | ||
|
||
|
||
# OS | ||
.DS_Store | ||
|
||
# Misc | ||
*.swp | ||
release.properties | ||
pom.xml.releaseBackup | ||
pom.xml.tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
FROM golang:1.23.0-bookworm AS builder | ||
|
||
|
||
# 是否开启go构建代理,如果在本机构建,这可能有用 | ||
ARG ENABLE_MIRROR=false | ||
RUN if [ ${ENABLE_MIRROR} = true ];then \ | ||
go env -w GOPROXY=https://goproxy.cn,direct; \ | ||
fi | ||
|
||
# 添加 xcaddy | ||
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest | ||
|
||
WORKDIR /build | ||
|
||
COPY . /build/ | ||
|
||
RUN ./build.sh | ||
|
||
|
||
FROM gcr.io/distroless/static-debian12 | ||
|
||
WORKDIR /caddy | ||
|
||
COPY --from=builder /build/caddy /usr/bin/caddy | ||
|
||
|
||
EXPOSE 80 | ||
EXPOSE 443 | ||
EXPOSE 443/udp | ||
EXPOSE 2019 | ||
|
||
CMD ["caddy", "run", "--config", "/etc/frontConfig"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Caddy | ||
|
||
CI repository,basing mirror site requirements of function, performance, scenerio, customizes and package caddy. It adds some useful plugins and parameters optimization. | ||
|
||
CI configuration is automatically generated basing on the below section, so please keep below format stable. | ||
|
||
## Modification Content | ||
|
||
### Based caddy version | ||
|
||
`v2.8.4` | ||
|
||
### Plugins | ||
|
||
| name | operation | description | url | | ||
|:-----------------:|:---------:|:-------------------------------------------------------------------------------------------------------------:|:---------------------------------------------:| | ||
| caddy-logger-loki | add | log.writer plugin able to send log directly to loki without promtail help. This reduce unnecessary contaienrs | https://github.com/sujoshua/caddy-logger-loki | | ||
|
||
### Images | ||
|
||
1. Using distroless base image and multi-stage build to reduce image size. | ||
2. Change default cmd to `caddy run --config /etc/frontConfig`, to fit kubesync default config. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
plugin_urls_file=$(./get_plugins.sh) | ||
trap "rm $plugin_urls_file" EXIT | ||
caddy_version=$(./get_caddy_version.sh) | ||
|
||
declare -a plugin_urls | ||
while IFS= read -r url; do | ||
echo "detected plugin url: " $url | ||
plugin_urls+=("$url") | ||
done < $plugin_urls_file | ||
|
||
|
||
plugin_cmd="" | ||
for url in "${plugin_urls[@]}";do | ||
plugin_cmd+=" --with $url" | ||
done | ||
|
||
build_cmd=$(echo xcaddy build $caddy_version $plugin_cmd) | ||
echo "build_cmd: $build_cmd" | ||
|
||
# we use distroless image, so static is needed. | ||
export CGO_ENABLED=0 | ||
eval "$build_cmd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
TARGET_FILE="README_english.md" | ||
|
||
version_line=$(awk '/^### Based caddy version/{getline; getline; print; exit}' $TARGET_FILE) | ||
|
||
version_line_tripped=$(echo $version_line | xargs) | ||
|
||
echo ${version_line_tripped:1:${#version_line_tripped}-2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash | ||
|
||
# 从README中的plugin表格解析出需要添加的插件的url | ||
|
||
# 从READMEi_english读取要添加的plugin. english版本好处理一些 | ||
TARGET_FILE='README_english.md' | ||
|
||
# 提取plugin表格 | ||
function extract_plugin_table(){ | ||
in_file=$1 | ||
out_file=$2 | ||
while IFS= read -r line; do | ||
# 如果遇到标题 "### Plugins",标记为开始提取 | ||
if [[ "$line" == "### Plugins" ]]; then | ||
in_table=1 | ||
continue | ||
fi | ||
|
||
# 如果已在表格部分并遇到空行,则增加换行计数器 | ||
if [[ $in_table -eq 1 ]]; then | ||
if [[ -z "$line" ]]; then | ||
newline_count=$((newline_count + 1)) | ||
if [[ $newline_count -ge 2 ]]; then | ||
# 遇到第二个空行,停止提取 | ||
in_table=0 | ||
break | ||
fi | ||
else | ||
echo "$line" >> "$out_file" | ||
fi | ||
fi | ||
done < $in_file | ||
|
||
# 处理提取的内容,去掉首尾的空行 | ||
sed -i '/^\s*$/d' "$out_file" | ||
} | ||
|
||
# 将md table的一行转换成数组 | ||
function parse_array(){ | ||
local line="$1" | ||
line=${line:1:${#line}-2} | ||
IFS='|' read -r -a columns <<< "$line" | ||
echo ${columns[@]} | ||
} | ||
|
||
# 获取第i个参数 | ||
function get_index(){ | ||
local line="$1" | ||
line=${line:1:${#line}-2} | ||
IFS='|' read -r -a columns <<< "$line" | ||
echo ${columns[$2]} | ||
} | ||
|
||
# 遍历array,找出指定的value的位置 | ||
function index_array(){ | ||
local target=$1 | ||
shift | ||
local arrays=("$@") | ||
if [ ${#arrays[@]} -eq 0 ];then | ||
echo "please input array!" | ||
return 2 | ||
fi | ||
|
||
for i in "${!arrays[@]}";do | ||
if [ "${arrays[$i]}" == "$target" ]; then | ||
echo $i | ||
return 0 | ||
fi | ||
done | ||
|
||
echo "not found." | ||
return 1 | ||
} | ||
|
||
tmp_file=$(mktemp) | ||
trap "rm $out_file" EXIT | ||
|
||
extract_plugin_table $TARGET_FILE $tmp_file | ||
head_a=$(parse_array "$(head -n1 $tmp_file)") | ||
url_index=$(index_array url $head_a) | ||
|
||
result_file=$(mktemp) | ||
skip_line=2 | ||
while IFS= read -r line; do | ||
if [ ! "$skip_line" -eq 0 ];then | ||
skip_line=$((skip_line-1)) | ||
continue | ||
fi | ||
raw_url=$(get_index "$line" $url_index) | ||
echo ${raw_url#https://} >> $result_file | ||
done < $tmp_file | ||
|
||
echo $result_file | ||
|
||
|
||
rm $tmp_file |