first commit

This commit is contained in:
Digital Studium 2023-03-25 12:07:14 +00:00
commit a5a50d0e02
8 changed files with 89 additions and 0 deletions

3
.env Normal file
View File

@ -0,0 +1,3 @@
GITEA_HOSTNAME=git.digitalstudium.com
GITEA_TOKEN=RlFiK2uUK0w8RJ98nfKhJdrcAFeKL7Se8cw2N3ts
EMAIL=digitalstudium001@gmail.com

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.runner

12
act-runner.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=Act Runner for Gitea
[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/gitea
ExecStart=/usr/local/bin/act_runner daemon
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target

12
git.conf Normal file
View File

@ -0,0 +1,12 @@
server {
server_name GITEA_HOSTNAME;
listen 80;
location / {
proxy_pass http://127.0.0.1:5000/;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
}

16
prepare.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
# Update repo cache and install packages
sudo apt update
sudo apt install -y nginx-light certbot python3-certbot-nginx docker.io
# Add current user to `docker` group and switch to this group
sudo usermod -a -G docker $USER
newgrp docker
# Init docker swarm mode if not yet initialized
docker swarm init || true
# Deploy docker stack
docker stack deploy -c stack.yaml gitea

15
setup_act_runner.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
source .env
# Download and install act_runner
wget https://dl.gitea.com/act_runner/main/act_runner-main-linux-amd64 -O act_runner
chmod +x ./act_runner
sudo mv ./act_runner /usr/local/bin/
# Register server as runner on Gitea
act_runner register --instance https://$GITEA_HOSTNAME --token $GITEA_TOKEN --no-interactive
# Create act-runner systemd service and start it
sudo cp ./act-runner.service /lib/systemd/system/act-runner.service
sudo systemctl enable --now act-runner

12
setup_nginx.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
source .env
# Copy config to nginx, substitute and reload it
sudo cp git.conf /etc/nginx/conf.d
sudo sed -i s/GITEA_HOSTNAME/$GITEA_HOSTNAME/g
sudo service nginx reload
# Get ssl certificate
sudo certbot --non-interactive --agree-tos -m $EMAIL

18
stack.yaml Normal file
View File

@ -0,0 +1,18 @@
version: "3"
services:
server:
image: gitea/gitea:1.19.0
environment:
- GITEA__actions__ENABLED=true
- GITEA__indexer__REPO_INDEXER_ENABLED=true
- GITEA__server__SSH_PORT=2222
volumes:
- gitea-data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "5000:3000"
- "2222:2222"
volumes:
gitea-data: