mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-24 01:50:19 +08:00
gitea
This commit is contained in:
parent
38350ececd
commit
8d16ebb9db
@ -1,9 +1,7 @@
|
||||
APP_NAME=gitea
|
||||
APP_VERSION=1.20.4
|
||||
# port, APP_PORT is need at leaset
|
||||
APP_HTTP_PORT=3000
|
||||
APP_NETWORK=websoft9
|
||||
APP_URL=gitea.example.com
|
||||
APP_URL=
|
||||
|
||||
INSTALL_LOCK=true
|
||||
DISABLE_SSH=true
|
||||
|
@ -1,15 +1,12 @@
|
||||
# step1: build hook-api exe
|
||||
FROM docker.io/library/golang:1.21-alpine3.18 as build-hook
|
||||
WORKDIR /
|
||||
COPY hook.go /
|
||||
RUN go build -o hook /hook.go
|
||||
|
||||
# 定义构建参数
|
||||
ARG GITEA_VERSION=1.20.4
|
||||
|
||||
# step2: from gitea image clone library, copy hook, s6 run script ...
|
||||
FROM gitea/gitea:1.20.4
|
||||
RUN cd / && git clone --depth=1 https://github.com/Websoft9/docker-library.git \
|
||||
&& mv docker-library library
|
||||
COPY --from=build-hook /hook /usr/local/bin/hook
|
||||
FROM gitea/gitea:${GITEA_VERSION}
|
||||
COPY init.sh /usr/local/bin/init.sh
|
||||
COPY ./hook /etc/s6/hook
|
||||
COPY ./init /etc/s6/init
|
||||
RUN chmod -R 755 /etc/s6/hook /etc/s6/init /usr/local/bin/init.sh
|
||||
RUN chmod -R 755 /etc/s6/init /usr/local/bin/init.sh
|
||||
|
@ -3,7 +3,7 @@
|
||||
From official Gitea image, and:
|
||||
|
||||
- Add docker-library to this image
|
||||
- Complete install wizard automaticlly by enviroment INSTALL_LOC
|
||||
- Complete install wizard automaticlly by enviroment INSTALL_LOCK
|
||||
- Create admin credential by admin cli
|
||||
- Disable user register
|
||||
- Disable Gravatar
|
||||
|
@ -18,8 +18,6 @@ services:
|
||||
- gitea:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- "$APP_HTTP_PORT:3000"
|
||||
|
||||
networks:
|
||||
default:
|
||||
|
@ -1,26 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handleRequest)
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
|
||||
func handleRequest(w http.ResponseWriter, r *http.Request) {
|
||||
// 打印请求行和头部信息
|
||||
requestDump, err := httputil.DumpRequest(r, true)
|
||||
if err != nil {
|
||||
log.Println("Error dumping request:", err)
|
||||
return
|
||||
}
|
||||
log.Println(string(requestDump))
|
||||
|
||||
log.Println("-----------------------接口被调用了一次!---------")
|
||||
fmt.Fprintf(w, "--Hello, World!")
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
s6-svwait -u /etc/s6/gitea
|
||||
|
||||
pushd /root >/dev/null
|
||||
exec su-exec $USER /usr/local/bin/hook
|
||||
popd
|
@ -1,43 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -e "/credential" ]; then
|
||||
echo "File /credential exists. Exiting script."
|
||||
set -e
|
||||
|
||||
cred_path="/var/websoft9/credential"
|
||||
admin_username="websoft9"
|
||||
admin_email="help@websoft9.com"
|
||||
|
||||
if [ -e "$cred_path" ]; then
|
||||
echo "File $cred_path exists. Exiting script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create admin credential by admin cli
|
||||
su -c '
|
||||
gitea admin user create --admin --username websoft9 --random-password --email help@websoft9.com > /tmp/credential
|
||||
' git
|
||||
echo "create diretory"
|
||||
mkdir -p "$(dirname "$cred_path")"
|
||||
|
||||
# Read credential from tmp
|
||||
|
||||
# TODO IF admin is exists, echo it to cred_path
|
||||
|
||||
echo "Create admin credential by admin cli"
|
||||
su -c "
|
||||
gitea admin user create --admin --username '$admin_username' --random-password --email '$admin_email' > /tmp/credential
|
||||
" git
|
||||
|
||||
echo "Read credential from tmp"
|
||||
username=$(grep -o "New user '[^']*" /tmp/credential | sed "s/New user '//")
|
||||
if [ -z "$username" ]; then
|
||||
username="websoft9"
|
||||
fi
|
||||
password=$(grep -o "generated random password is '[^']*" /tmp/credential | sed "s/generated random password is '//")
|
||||
# Create template credential
|
||||
|
||||
echo "Save to credential"
|
||||
json="{\"username\":\"$username\",\"password\":\"$password\"}"
|
||||
# Save to json
|
||||
filename="/credential"
|
||||
echo "$json" > "$filename"
|
||||
|
||||
# Config webhook url at Gitea admin
|
||||
|
||||
# Gitea API URL
|
||||
api_url="http://localhost:3000/api/v1"
|
||||
hook_url="http://gitea:8080"
|
||||
|
||||
# Param data
|
||||
hook_data='{
|
||||
"type": "gitea",
|
||||
"config": {
|
||||
"url": "'"$hook_url"'",
|
||||
"content_type": "json"
|
||||
},
|
||||
"events": ["push"],
|
||||
"active": true
|
||||
}'
|
||||
|
||||
# Create a hook
|
||||
curl -s -u "$username:$password" -X POST -H "Content-Type: application/json" -d "$hook_data" "$api_url/user/hooks"
|
||||
echo "$json" > "$cred_path"
|
||||
|
@ -10,7 +10,6 @@ services:
|
||||
container_name: ${APP_NAME}
|
||||
ports:
|
||||
- "80:80"
|
||||
- "${APP_HTTP_PORT}:81"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- nginx_data:/data
|
||||
|
@ -14,8 +14,6 @@ services:
|
||||
volumes:
|
||||
- portainer:/data
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
ports:
|
||||
- 9091:9000
|
||||
|
||||
networks:
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user