Inicjalizacja repozytorium po uporządkowaniu Gitea; dodanie gitignore
This commit is contained in:
4
gitea/.env
Normal file
4
gitea/.env
Normal file
@@ -0,0 +1,4 @@
|
||||
DB_PASSWORD=899fa3aa3cf344b6659b256b1f16be8b
|
||||
GITEA_DOMAIN=gitea.example.com
|
||||
GITEA_URL=https://gitea.example.com/
|
||||
RUNNER_TOKEN=4fLWQRGyi2Pv2VCrzFLWz6TFgElbrslz0hMjg4p5
|
||||
25
gitea/compose-db.yml
Normal file
25
gitea/compose-db.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
networks:
|
||||
central_dogma:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15-alpine
|
||||
container_name: gitea-db
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: gitea
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||
POSTGRES_DB: gitea
|
||||
networks:
|
||||
- central_dogma
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U gitea"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
40
gitea/compose-gitea.yml
Normal file
40
gitea/compose-gitea.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
networks:
|
||||
central_dogma:
|
||||
external: true
|
||||
runner_net:
|
||||
name: runner_net
|
||||
|
||||
volumes:
|
||||
gitea-data:
|
||||
|
||||
services:
|
||||
gitea:
|
||||
image: gitea/gitea:latest
|
||||
container_name: gitea
|
||||
restart: always
|
||||
environment:
|
||||
GITEA__database__DB_TYPE: postgres
|
||||
GITEA__database__HOST: gitea-db:5432
|
||||
GITEA__database__USER: gitea
|
||||
GITEA__database__PASSWD: ${DB_PASSWORD}
|
||||
GITEA__database__NAME: gitea
|
||||
GITEA__database__SSL_MODE: disable
|
||||
GITEA__security__INSTALL_LOCK: "false"
|
||||
GITEA__actions__ENABLED: "true"
|
||||
GITEA__server__DOMAIN: ${GITEA_DOMAIN}
|
||||
GITEA__server__ROOT_URL: ${GITEA_URL}
|
||||
GITEA__server__SSH_PORT: 22
|
||||
GITEA__server__SSH_DOMAIN: ${GITEA_DOMAIN}
|
||||
GITEA__repository__DEFAULT_BRANCH: main
|
||||
GITEA__service__DISABLE_REGISTRATION: "false"
|
||||
GITEA__service__REGISTER_EMAIL_CONFIRM_REQUIRED: "false"
|
||||
networks:
|
||||
- central_dogma
|
||||
- runner_net
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "222:22"
|
||||
volumes:
|
||||
- gitea-data:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
22
gitea/compose-runner.yml
Normal file
22
gitea/compose-runner.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
networks:
|
||||
runner_net:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
runner-data:
|
||||
|
||||
services:
|
||||
runner:
|
||||
image: gitea/act_runner:latest
|
||||
container_name: gitea-runner
|
||||
restart: always
|
||||
environment:
|
||||
GITEA_INSTANCE_URL: http://gitea:3000
|
||||
GITEA_RUNNER_REGISTRATION_TOKEN: ${RUNNER_TOKEN}
|
||||
GITEA_RUNNER_NAME: docker-runner
|
||||
GITEA_RUNNER_LABELS: "docker:docker,ubuntu-latest:docker://gitea/runner-images:ubuntu-latest"
|
||||
networks:
|
||||
- runner_net
|
||||
volumes:
|
||||
- runner-data:/data
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
11
gitea/init-env.sh
Normal file
11
gitea/init-env.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -f .env ]; then
|
||||
DB_PASS=$(openssl rand -hex 16)
|
||||
echo "Creating .env..."
|
||||
echo "DB_PASSWORD=$DB_PASS" > .env
|
||||
echo "GITEA_DOMAIN=gitea.example.com" >> .env
|
||||
echo "GITEA_URL=https://gitea.example.com/" >> .env
|
||||
echo "RUNNER_TOKEN=" >> .env
|
||||
echo "Update GITEA_DOMAIN and GITEA_URL in .env"
|
||||
fi
|
||||
15
gitea/init-runner-token.sh
Normal file
15
gitea/init-runner-token.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Generating runner token..."
|
||||
TOKEN=$(openssl rand -hex 32)
|
||||
|
||||
if grep -q "RUNNER_TOKEN=" .env; then
|
||||
sed -i "s/RUNNER_TOKEN=.*/RUNNER_TOKEN=$TOKEN/" .env
|
||||
else
|
||||
echo "RUNNER_TOKEN=$TOKEN" >> .env
|
||||
fi
|
||||
|
||||
echo "Token: $TOKEN"
|
||||
echo "Restarting runner..."
|
||||
docker compose -f compose-runner.yml restart
|
||||
|
||||
75
gitea/justfile
Normal file
75
gitea/justfile
Normal file
@@ -0,0 +1,75 @@
|
||||
set shell := ["bash", "-c"]
|
||||
|
||||
default:
|
||||
@just --list
|
||||
|
||||
init-env:
|
||||
@bash init-env.sh
|
||||
|
||||
init-network:
|
||||
@docker network inspect central_dogma >/dev/null 2>&1 || \
|
||||
(docker network create central_dogma && echo "Network central_dogma created")
|
||||
|
||||
|
||||
up: init-env init-network
|
||||
@echo "Starting Gitea infrastructure..."
|
||||
docker compose -f compose-db.yml up -d
|
||||
@echo "Waiting for database..."
|
||||
@for i in 1 2 3 4 5; do \
|
||||
if docker exec gitea-db pg_isready -U gitea >/dev/null 2>&1; then \
|
||||
break; \
|
||||
fi; \
|
||||
echo "Attempt $$i/5..."; \
|
||||
sleep 2; \
|
||||
done
|
||||
docker compose -f compose-gitea.yml up -d
|
||||
@echo "Waiting for Gitea to be ready..."
|
||||
@until curl -sf http://localhost:3000 > /dev/null 2>&1; do \
|
||||
echo "Waiting..."; \
|
||||
sleep 5; \
|
||||
done
|
||||
@echo "Gitea is ready!"
|
||||
@if ! grep -q "RUNNER_TOKEN=.\+" .env; then \
|
||||
echo "RUNNER_TOKEN not set. Run: just init-runner-token"; \
|
||||
else \
|
||||
docker compose -f compose-runner.yml up -d; \
|
||||
echo "Runner started"; \
|
||||
fi
|
||||
@echo ""
|
||||
@echo "SETUP COMPLETE"
|
||||
@echo "Gitea: http://localhost:3000"
|
||||
@echo "SSH: localhost:222"
|
||||
|
||||
down:
|
||||
docker compose -f compose-runner.yml down || true
|
||||
docker compose -f compose-gitea.yml down || true
|
||||
docker compose -f compose-db.yml down || true
|
||||
|
||||
stop:
|
||||
docker compose -f compose-runner.yml stop || true
|
||||
docker compose -f compose-gitea.yml stop || true
|
||||
docker compose -f compose-db.yml stop || true
|
||||
|
||||
start:
|
||||
docker compose -f compose-db.yml start
|
||||
docker compose -f compose-gitea.yml start
|
||||
docker compose -f compose-runner.yml start
|
||||
|
||||
logs-gitea:
|
||||
docker compose -f compose-gitea.yml logs -f --tail=100 gitea
|
||||
|
||||
logs-runner:
|
||||
docker compose -f compose-runner.yml logs -f --tail=100 runner
|
||||
|
||||
logs-db:
|
||||
docker compose -f compose-db.yml logs -f --tail=100 postgres
|
||||
|
||||
init-runner-token:
|
||||
@bash init-runner-token.sh
|
||||
|
||||
clean:
|
||||
docker compose -f compose-runner.yml down -v || true
|
||||
docker compose -f compose-gitea.yml down -v || true
|
||||
docker compose -f compose-db.yml down -v || true
|
||||
rm -f .env
|
||||
echo "Cleaned up"
|
||||
Reference in New Issue
Block a user