initial commit

This commit is contained in:
Gilles Mouchet 2025-10-16 17:50:23 +02:00
commit cfbada8473
4 changed files with 229 additions and 0 deletions

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"editor.fontSize": 13,
"terminal.integrated.fontSize": 13,
"window.zoomLevel": 1.4,
}

48
README-CICD.md Normal file
View File

@ -0,0 +1,48 @@
## How to use CICD on gitea
In this example we create an example project with a simple cicd. The CICD will be run
when you push the project
## Procedure
* create a project in gitea
* clone it on local pc
* goto project folder on local
* create folder `.gitea/workflows`
* create `README.md` file
* create file `gitea-ci.yml` on the foder create above with the next content:
```yaml
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on:
push:
branches:
- main
# efinition of the job(s)
jobs:
test-runner:
# Indicates on which runner label to run the job (must match one of the labels defined in the runner)
runs-on: [ubuntu-latest]
steps:
- name: Check runner
run: |
echo "✅ The runner is working properly!"
echo "User running this job : $(whoami)"
echo "Contents of current directory :"
ls -la
- name: Test Docker
run: |
echo "🐳 Checking Docker in the runner"
docker version || echo "⚠️ Docker not accessible in this runner"
- name: Network test
run: |
echo "🌐 Testing the connection to gitea.io"
curl -I https://gitea.io || echo "⚠️ Unable to contact gitea.io"
```
```bash
git add .
git commit -m "first commit`
git push
```
To see the CICD click on **Actions** in your project

103
README.md Normal file
View File

@ -0,0 +1,103 @@
# Gitea
## Description
This docker compose run gitea and his runner on docker
## Requierments
### Folder
```bash
sudo mkdir -p /home/docker/gitea/data
sudo mkdir -p /home/docker/gitea/postgres
sudo mkdir -p /home/docker/gitea/runner/data
```
### Files
```bash
sudo touch /home/docker/gitea/runner/config.yaml
```
### Certificats
Copy crt and key files on `/home/docker/certs/`
## Apache
### http-gitea.conf
```
<VirtualHost *:80>
ServerName gitea.gmolab.net
ServerAlias gitea
CustomLog logs/gitea_access_log common
ErrorLog logs/gitea_error_log
# redirect to https
RewriteEngine on
RewriteCond %{SERVER_NAME} =gitea [OR]
RewriteCond %{SERVER_NAME} =gitea.gmolab.net
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
```
### https-gitea.conf
```
##
## SSL Virtual Host Context
##
# General setup for the virtual host
<VirtualHost *:443>
ServerName gitea.gmolab.net
ServerAlias gitea
CustomLog logs/gitea_access_log common
ErrorLog logs/gitea_error_log
# SSL
SSLEngine on
SSLHonorCipherOrder on
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder on
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4
# Enable HTTP/2, if available
Protocols h2 http/1.1
# HTTP Strict Transport Security (mod_headers is required) (63072000 seconds)
Header always set Strict-Transport-Security "max-age=63072000"
# certificats
SSLCertificateFile "/etc/httpd/auth/cert/gmolab.net.crt"
SSLCertificateKeyFile "/etc/httpd/auth/cert/gmolab.net.key"
SSLCertificateChainFile "/etc/httpd/auth/cert/gmolabCA.crt"
# proxy
SSLProxyEngine On
ProxyPreserveHost On
ProxyRequests off
ProxyPass "/" "http://127.0.0.1:3000/"
ProxyPassReverse "/" "https://127.0.0.1:3000/"
</VirtualHost>
```
### Start gitea for config
```bash
docker compose up web db
```
## Access
https://gitea.gmolab.net
## Config
Login on https://gitea.gmolab.net
Adapt the configuration as you need
**Do not forget** to config user and password admin in section `Administrator Account Settings`
### Create runner
* click on the user name at the top right of the page, **Settings** -> **Actions** -> **Runners**
* click on **Create new Runner** and copy **Registration Token**
* edit file `docker-copose.yml`and
- set variable `GITEA_RUNNER_REGISTRATION_TOKEN` with the token copied above
- set variable `GITEA_INSTANCE_URL` with URL
- set variable `GITEA_RUNNER_NAME` with the name that you want
* stop gitea
```bash
docker compose down
```
## Start gitea stack
```bash
docker compose up -d
```
---
### [1.0.0] - 2025-10-16
#### Added
- initial version by [GMo](mailto:gilles.mouchet@gmail.com)

73
docker-compose.yml Normal file
View File

@ -0,0 +1,73 @@
version: "3"
networks:
gitea:
external: false
services:
web:
image: docker.gitea.com/gitea:1.24.6
container_name: gitea-web
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=postgres
- GITEA__database__HOST=db:5432
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=gitea
restart: always
networks:
- gitea
volumes:
#- ./gitea:/data
- /home/docker/gitea/data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
depends_on:
- db
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:3000/"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
db:
image: docker.io/library/postgres:14
container_name: gitea-db
restart: always
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=gitea
- POSTGRES_DB=gitea
networks:
- gitea
volumes:
- /home/docker/gitea/postgres:/var/lib/postgresql/data
runner:
image: docker.io/gitea/act_runner:nightly
container_name: gitea-run
environment:
CONFIG_FILE: /config.yaml
GITEA_INSTANCE_URL: "${INSTANCE_URL}"
#GITEA_INSTANCE_URL: "http://172.31.10.15:3000"
GITEA_RUNNER_REGISTRATION_TOKEN: "${RUNNER_TOKEN}"
#GITEA_RUNNER_REGISTRATION_TOKEN: "afg...gzh"
GITEA_RUNNER_NAME: "${RUNNER_NAME}"
#GITEA_RUNNER_NAME: "gitea_runner_1"
GITEA_RUNNER_LABELS: "${RUNNER_LABELS}"
networks:
- gitea
volumes:
- /home/docker/gitea/runner/config.yaml:/config.yaml
- /home/docker/gitea/runner/data:/data
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
web:
condition: service_healthy