matching_app/template/gitea_docker.yaml
phattt2901 8686e225b0
Some checks failed
Go CI Pipeline / Lint Code (push) Failing after 5s
Go CI Pipeline / Security Scan (SCA) (push) Failing after 10s
Go CI Pipeline / Run Tests (push) Failing after 3s
Go CI Pipeline / Build Application (push) Has been skipped
Network Connectivity Test (Updated) / Check Runner to Server Connectivity (push) Successful in 10s
DNS & Network Test / network-test (push) Successful in 17s
Test CI v2.1.13
2025-05-03 23:02:41 +07:00

78 lines
3.4 KiB
YAML

version: "3.8" # Nên dùng phiên bản mới hơn nếu có thể
networks: # Khai báo network trước để các service có thể tham chiếu
gitea_network: # Đổi tên network để rõ ràng hơn (tùy chọn)
external: false
services:
db:
image: postgres:14
restart: always
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=gitea
- POSTGRES_DB=gitea
volumes:
- ./postgres:/var/lib/postgresql/data # Đảm bảo thư mục ./postgres tồn tại hoặc Docker sẽ tạo với quyền root
networks:
- gitea_network
# Thêm healthcheck cho DB (rất nên có)
healthcheck:
test: ["CMD-SHELL", "pg_isready -U gitea -d gitea"]
interval: 10s
timeout: 5s
retries: 5
server:
image: gitea/gitea:latest # Cân nhắc dùng phiên bản cụ thể thay vì latest cho production
container_name: gitea_server # Đổi tên container để rõ ràng hơn
restart: always
environment:
- USER_UID=118 # Đảm bảo UID/GID này tồn tại và có quyền ghi vào volume ./gitea trên host
- USER_GID=124
- GITEA__database__DB_TYPE=postgres
- GITEA__database__HOST=db:5432
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=gitea
# --- BIẾN MÔI TRƯỜNG MỚI ĐỂ BẬT ACTIONS ---
- GITEA__actions__ENABLED=true
# ----------------------------------------
# (Optional) Cấu hình URL gốc của Gitea nếu cần thiết cho Actions/Runner biết
# - GITEA__server__ROOT_URL=http://<Your_VPS_IP_or_Domain>:4441
depends_on:
db:
condition: service_healthy # Sử dụng healthcheck của db
volumes:
- ./gitea:/data # Đảm bảo thư mục ./gitea tồn tại và có quyền ghi đúng
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "4441:3000" # Cổng truy cập Gitea Web UI
- "2222:22" # Cổng SSH của Gitea
networks:
- gitea_network
runner:
image: gitea/act_runner:latest # Image chính thức
container_name: gitea_runner
restart: always
depends_on:
- server # Đảm bảo Gitea server đã chạy trước
environment:
# URL của Gitea server mà runner sẽ kết nối TỪ BÊN TRONG network 'gitea'
- GITEA_INSTANCE_URL=https://gitea.tuvanwebsite.com
# Token đăng ký bạn lấy từ Gitea UI ở Bước 2
- GITEA_RUNNER_REGISTRATION_TOKEN=O3zZ057mfaayCGkqJEqkXsdWKgs62ETjg1A4mS1U
# Tên hiển thị cho runner này trên Gitea UI
- GITEA_RUNNER_NAME=ulflow_runner1
# Các nhãn (labels) cho runner. Workflow sẽ dùng label để chọn runner phù hợp.
# Ví dụ: cho phép chạy job Docker trên Ubuntu
- GITEA_RUNNER_LABELS=ubuntu-latest:docker://node:16-bullseye,linux-amd64:host
volumes:
# Mount Docker socket để runner có thể chạy các job dùng Docker
- /var/run/docker.sock:/var/run/docker.sock
# Mount thư mục để runner lưu file cấu hình và định danh sau khi đăng ký
- ./runner-data:/data # Đảm bảo thư mục ./runner-data tồn tại và có quyền ghi # native:host cho phép chạy job trực tiếp trên host (nếu cần)
networks:
- gitea_network
# --- KẾT THÚC PHẦN THÊM RUNNER ---