diff --git a/docker/w9gitea/.env b/docker/w9gitea/.env index 29687388..47a05df5 100644 --- a/docker/w9gitea/.env +++ b/docker/w9gitea/.env @@ -1,15 +1,15 @@ APP_NAME=gitea -APP_VERSION=latest +APP_VERSION=1.20.4 # port, APP_PORT is need at leaset APP_HTTP_PORT=3000 APP_NETWORK=websoft9 -APP_URL=119.8.96.66 +APP_URL=example INSTALL_LOCK=true DISABLE_SSH=true DISABLE_REGISTRATION=true RUN_MODE=prod -HTTP_PORT = 3000 +HTTP_PORT=3000 DOMAIN=$APP_URL SSH_DOMAIN=$APP_URL ROOT_URL=http://$APP_URL:$HTTP_PORT diff --git a/docker/w9gitea/Dockerfile b/docker/w9gitea/Dockerfile index 5ab5bd7a..ecafa2c4 100644 --- a/docker/w9gitea/Dockerfile +++ b/docker/w9gitea/Dockerfile @@ -1 +1,16 @@ -FROM gitea/gitea:latest \ No newline at end of file +# 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 + +# step2: from gitea image clone library, copy hook, s6 run script ... +FROM gitea/gitea:1.20.4 +RUN git clone --depth=1 https://github.com/Websoft9/docker-library.git \ + && mv docker-library library \ + && cp -r library / \ + && rm -rf library +COPY --from=build-hook /hook /usr/local/bin/hook + +COPY hook /etc/s6 +RUN chmod -R 755 /etc/s6/hook diff --git a/docker/w9gitea/docker-compose.yml b/docker/w9gitea/docker-compose.yml index 4676329a..fb39e6ca 100644 --- a/docker/w9gitea/docker-compose.yml +++ b/docker/w9gitea/docker-compose.yml @@ -1,15 +1,16 @@ # image: https://hub.docker.com/r/gitea/gitea # docs: https://docs.gitea.io/zh-cn/install-with-docker +# gitea admin user create --admin --username websoft9 --random-password --email help@websoft9.com version: '3.8' services: gitea: - image: gitea/gitea:$APP_VERSION container_name: $APP_NAME - environment: - - USER_UID=1000 - - USER_GID=1000 + image: websoft9dev/portainer:1.20.4 + build: + context: . + dockerfile: Dockerfile restart: unless-stopped env_file: - .env diff --git a/docker/w9gitea/hook.go b/docker/w9gitea/hook.go new file mode 100644 index 00000000..71103251 --- /dev/null +++ b/docker/w9gitea/hook.go @@ -0,0 +1,26 @@ +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!") +} \ No newline at end of file diff --git a/docker/w9gitea/hook/run b/docker/w9gitea/hook/run new file mode 100644 index 00000000..449cf45f --- /dev/null +++ b/docker/w9gitea/hook/run @@ -0,0 +1,5 @@ +#!/bin/bash + +pushd /root >/dev/null +exec su-exec $USER /usr/local/bin/hook +popd diff --git a/docker/w9gitea/src/config/app.ini.example b/docker/w9gitea/src/config/app.ini.example new file mode 100644 index 00000000..afd3ce02 --- /dev/null +++ b/docker/w9gitea/src/config/app.ini.example @@ -0,0 +1,98 @@ +APP_NAME = gitea +RUN_MODE = prod +RUN_USER = git +WORK_PATH = /data/gitea + +[repository] +ROOT = /data/git/repositories + +[repository.local] +LOCAL_COPY_PATH = /data/gitea/tmp/local-repo + +[repository.upload] +TEMP_PATH = /data/gitea/uploads + +[server] +APP_DATA_PATH = /data/gitea +DOMAIN = 119.8.96.66 +SSH_DOMAIN = 119.8.96.66 +HTTP_PORT = 3000 +ROOT_URL = http://119.8.96.66:3000/ +DISABLE_SSH = true +SSH_PORT = 22 +SSH_LISTEN_PORT = 22 +LFS_START_SERVER = true +LFS_JWT_SECRET = prcv5KuvKilAB_369Vr4saJf4QBdlMwD-vOXD2l7IHo +OFFLINE_MODE = false + +[database] +PATH = /data/gitea/gitea.db +DB_TYPE = sqlite3 +HOST = localhost:3306 +NAME = gitea +USER = root +PASSWD = +LOG_SQL = false +SCHEMA = +SSL_MODE = disable + +[indexer] +ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve + +[session] +PROVIDER_CONFIG = /data/gitea/sessions +PROVIDER = file + +[picture] +AVATAR_UPLOAD_PATH = /data/gitea/avatars +REPOSITORY_AVATAR_UPLOAD_PATH = /data/gitea/repo-avatars + +[attachment] +PATH = /data/gitea/attachments + +[log] +MODE = console +LEVEL = info +ROOT_PATH = /data/gitea/log + +[security] +INSTALL_LOCK = true +SECRET_KEY = +REVERSE_PROXY_LIMIT = 1 +REVERSE_PROXY_TRUSTED_PROXIES = * +INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE2OTQ1NzI0NDN9.kzFr-t0io9M_XQWojbvG20KPiXIZPS2GMadRBgR9xMM +PASSWORD_HASH_ALGO = pbkdf2 + +[service] +DISABLE_REGISTRATION = false +REQUIRE_SIGNIN_VIEW = false +REGISTER_EMAIL_CONFIRM = false +ENABLE_NOTIFY_MAIL = false +ALLOW_ONLY_EXTERNAL_REGISTRATION = false +ENABLE_CAPTCHA = false +DEFAULT_KEEP_EMAIL_PRIVATE = false +DEFAULT_ALLOW_CREATE_ORGANIZATION = true +DEFAULT_ENABLE_TIMETRACKING = true +NO_REPLY_ADDRESS = noreply.119.8.96.66 + +[lfs] +PATH = /data/git/lfs + +[mailer] +ENABLED = false + +[openid] +ENABLE_OPENID_SIGNIN = true +ENABLE_OPENID_SIGNUP = true + +[cron.update_checker] +ENABLED = false + +[repository.pull-request] +DEFAULT_MERGE_STYLE = merge + +[repository.signing] +DEFAULT_TRUST_MODEL = committer + +[oauth2] +JWT_SECRET = vIGxNkS5o0NYgDZwxMIcS_zXbbN3GBLCTO5MseHgO8Q \ No newline at end of file diff --git a/docker/w9gitea/src/gitea.conf b/docker/w9gitea/src/gitea.conf deleted file mode 100644 index e69de29b..00000000