bash# 记录下 UID/GID 替换中的 USER_UID USER_GID
sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
# 生成 SSH 密钥对
sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key"
# ----------------------------------------------------------------
sudo -u git cat /home/git/.ssh/id_rsa.pub | sudo -u git tee -a /home/git/.ssh/authorized_keys
sudo -u git chmod 600 /home/git/.ssh/authorized_keys
cat <<"EOF" | sudo tee /usr/local/bin/gitea
#!/bin/sh
ssh -p 2222 -o StrictHostKeyChecking=no git@127.0.0.1 "SSH_ORIGINAL_COMMAND=\"$SSH_ORIGINAL_COMMAND\" $0 $@"
EOF
sudo chmod +x /usr/local/bin/gitea
yamlversion: "3"
services:
caddy:
container_name: caddy
image: caddy:alpine
restart: unless-stopped
ports:
- "80:80"
- "80:80/udp"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
gitea:
container_name: gitea
image: gitea/gitea:latest
restart: unless-stopped
# depends_on:
# - redis
environment:
- USER=git
- USER_UID=111
- USER_GID=122
volumes:
- ./gitea:/data
- /home/git/.ssh:/data/git/.ssh
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "127.0.0.1:2222:22"
# redis:
# container_name: redis
# image: redis:alpine
# restart: unless-stopped
# volumes:
# - ./redis:/data
Caddyfile:80 { redir https://{host}{uri} } gitea.uing.vip { log { output stdout format console level ERROR } reverse_proxy gitea:3000 }
bashcat << EOF >> gitea/gitea/conf/app.ini
[actions]
ENABLED=true
EOF
docker-compose restart gitea
mkdir gitea_runner && cd gitea_runner docker run --entrypoint="" --rm -it gitea/act_runner:latest act_runner generate-config > config.yaml
yamlversion: "3"
services:
gitea_runner:
container_name: gitea_runner
image: gitea/act_runner:latest
# 如果使用服务器容器名称作为 URL HOST 的话,需要先启动 Gitea
depends_on:
- gitea
environment:
CONFIG_FILE: /config.yaml
# Gitea 服务器地址(也可以是内网地址或者容器内部地址)
GITEA_INSTANCE_URL: https://gitea.uing.vip
# 获取地址 https://gitea.uing.vip/admin/actions/runners/
GITEA_RUNNER_REGISTRATION_TOKEN: ""
# Runner名称(可选)。如果留空,将使用主机名
GITEA_RUNNER_NAME: ""
GITEA_RUNNER_LABELS: ""
volumes:
- ./gitea_runner/config.yaml:/config.yaml
- ./gitea_runner/data:/data
- /var/run/docker.sock:/var/run/docker.sock
bashgit clone git@gitea.uing.vip:cainiao/gitea_runner.git
cd gitea_runner && mkdir -p .gitea/workflows/
cat <<"EOF" > .gitea/workflows/demo.yaml
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
EOF
git add .gitea/workflows/demo.yaml
git commit -m "add .gitea/workflows/demo.yaml"
git push
本文作者:菜鸟
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 许可协议。转载请注明出处!