mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-24 10:17:15 +08:00
gitea
This commit is contained in:
parent
38350ececd
commit
8d16ebb9db
@ -1,9 +1,7 @@
|
|||||||
APP_NAME=gitea
|
APP_NAME=gitea
|
||||||
APP_VERSION=1.20.4
|
APP_VERSION=1.20.4
|
||||||
# port, APP_PORT is need at leaset
|
|
||||||
APP_HTTP_PORT=3000
|
|
||||||
APP_NETWORK=websoft9
|
APP_NETWORK=websoft9
|
||||||
APP_URL=gitea.example.com
|
APP_URL=
|
||||||
|
|
||||||
INSTALL_LOCK=true
|
INSTALL_LOCK=true
|
||||||
DISABLE_SSH=true
|
DISABLE_SSH=true
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
# step1: build hook-api exe
|
# step1: build hook-api exe
|
||||||
FROM docker.io/library/golang:1.21-alpine3.18 as build-hook
|
FROM docker.io/library/golang:1.21-alpine3.18 as build-hook
|
||||||
WORKDIR /
|
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 ...
|
# step2: from gitea image clone library, copy hook, s6 run script ...
|
||||||
FROM gitea/gitea:1.20.4
|
FROM gitea/gitea:${GITEA_VERSION}
|
||||||
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
|
|
||||||
COPY init.sh /usr/local/bin/init.sh
|
COPY init.sh /usr/local/bin/init.sh
|
||||||
COPY ./hook /etc/s6/hook
|
|
||||||
COPY ./init /etc/s6/init
|
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:
|
From official Gitea image, and:
|
||||||
|
|
||||||
- Add docker-library to this image
|
- 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
|
- Create admin credential by admin cli
|
||||||
- Disable user register
|
- Disable user register
|
||||||
- Disable Gravatar
|
- Disable Gravatar
|
||||||
|
@ -18,8 +18,6 @@ services:
|
|||||||
- gitea:/data
|
- gitea:/data
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
ports:
|
|
||||||
- "$APP_HTTP_PORT:3000"
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
default:
|
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
|
#!/bin/bash
|
||||||
|
|
||||||
if [ -e "/credential" ]; then
|
set -e
|
||||||
echo "File /credential exists. Exiting script."
|
|
||||||
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create admin credential by admin cli
|
echo "create diretory"
|
||||||
su -c '
|
mkdir -p "$(dirname "$cred_path")"
|
||||||
gitea admin user create --admin --username websoft9 --random-password --email help@websoft9.com > /tmp/credential
|
|
||||||
' git
|
|
||||||
|
|
||||||
# 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 '//")
|
username=$(grep -o "New user '[^']*" /tmp/credential | sed "s/New user '//")
|
||||||
if [ -z "$username" ]; then
|
if [ -z "$username" ]; then
|
||||||
username="websoft9"
|
username="websoft9"
|
||||||
fi
|
fi
|
||||||
password=$(grep -o "generated random password is '[^']*" /tmp/credential | sed "s/generated random password is '//")
|
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\"}"
|
json="{\"username\":\"$username\",\"password\":\"$password\"}"
|
||||||
# Save to json
|
echo "$json" > "$cred_path"
|
||||||
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"
|
|
||||||
|
@ -10,7 +10,6 @@ services:
|
|||||||
container_name: ${APP_NAME}
|
container_name: ${APP_NAME}
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "${APP_HTTP_PORT}:81"
|
|
||||||
- "443:443"
|
- "443:443"
|
||||||
volumes:
|
volumes:
|
||||||
- nginx_data:/data
|
- nginx_data:/data
|
||||||
|
@ -14,8 +14,6 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- portainer:/data
|
- portainer:/data
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
ports:
|
|
||||||
- 9091:9000
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user