added basic setup script

This commit is contained in:
2025-12-03 12:47:30 +00:00
parent 1203c2ffeb
commit dd7c05789b
4 changed files with 127 additions and 0 deletions

0
.env Normal file
View File

View File

@@ -0,0 +1,25 @@
services:
gitea:
image: gitea/gitea:latest
container_name: gitea
restart: always
environment:
- ROOT_URL=${IPV4_ADDRESS}:3000/
ports:
# - "2222:22" # <-- SSH access is disabled for initial setup, uncomment if needed
- "3000:3000" # Uncomment if you want to expose Gitea web interface directly (needed if not rooted behind a reverse proxy or for initial setup)
volumes:
# Persistent storage for Gitea data, configuration, repositories, etc.
# Maps a named volume 'gitea_data' to the container's /data directory.
- ./data:/data
- /etc/timezone:/etc/timezone:ro # <--- Timezone settings
- /etc/localtime:/etc/localtime:ro # <--- Timezone settings
- ./data/git:/data/host_repos:ro # <--- Mount for Git repositories
- ./logs/:/data/gitea/log/:rw # <--- Mount for Gitea logs (neccessary for debugging and fail2ban)
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
interval: 1m30s
timeout: 10s
retries: 3

56
docker-compose.runner.yml Normal file
View File

@@ -0,0 +1,56 @@
services:
runner:
image: docker.io/gitea/act_runner:nightly
environment:
CONFIG_FILE: /config.yaml # <-- Path to the runner configuration file inside the container
GITEA_INSTANCE_URL: http://gitea:3000/ # <-- Use the internal Docker network URL
GITEA_RUNNER_REGISTRATION_TOKEN: asdasd # <-- REPLACE WITH YOUR REGISTRATION TOKEN
GITEA_RUNNER_NAME: FastFlaskRunner
volumes:
- ./config/runner.yaml:/config.yaml # <-- Mount for runner configuration
- ./data/prod/pkgs:/prod/pkgs # <-- Mount for production packages
- ./data/prod/data:/prod/data # <-- Mount for production data
- ./data/develop:/develop/data # <-- Mount for development data
- /var/run/docker.sock:/var/run/docker.sock # <-- Mount Docker socket for Docker-in-Docker functionality (DoNotChange)
depends_on:
- gitea
restart: always
networks:
- fast-services
gitea:
image: gitea/gitea:latest
container_name: gitea
restart: always
environment:
- ROOT_URL=https://git.nxs.solutions/ # <-- Change to your Gitea URL either Domain or IP with protocol
ports:
- "2222:22" # <-- SSH access for Git operations (Change if needed to your preferred port)
# - "3000:3000" # Uncomment if you want to expose Gitea web interface directly (needed if not rooted behind a reverse proxy)
volumes:
# Persistent storage for Gitea data, configuration, repositories, etc.
# Maps a named volume 'gitea_data' to the container's /data directory.
- ./data:/data
- /etc/timezone:/etc/timezone:ro # <--- Timezone settings
- /etc/localtime:/etc/localtime:ro # <--- Timezone settings
- ./data/git:/data/host_repos:ro # <--- Mount for Git repositories
- ./logs/:/data/gitea/log/:rw # <--- Mount for Gitea logs (neccessary for debugging and fail2ban)
networks:
- fast-services
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
interval: 1m30s
timeout: 10s
retries: 3
networks:
fast-services:
external: true

46
setup.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
# Ask the user if they want to start the initial setup or they want to migrate from an existing installation
read -r -p "Do you want to start the initial setup? (y/n): " INSTALL_GITEA
if [ -z "$INSTALL_GITEA" ] || [[ "$INSTALL_GITEA" != "y" && "$INSTALL_GITEA" != "n" ]]; then
echo "Skipping inital setup. Exiting..."
exit 1
else
touch .env
IPV4_ADDRESS=$(hostname -I | awk '{print $1}')
export IPV4_ADDRESS
echo "Current IPv4 Address: $IPV4_ADDRESS"
echo "Temporary enable port 3000 for initial setup ..."
sudo ufw allow 3000/tcp
sudo ufw reload
sudo ufw status
# Start the initial setup docker compose file
echo "Starting initial setup container ..."
docker compose -f config/docker-compose.init.yml up -d
echo "Container is running at http://$IPV4_ADDRESS:3000"
echo "Please complete the setup in the web interface."
read -r -p "Please add a runner key or press any key to continue after completing the setup..." RUNNER_KEY
if [ -n "$RUNNER_KEY" ]; then
echo "Runner key provided: $RUNNER_KEY"
echo "RUNNER_KEY=$RUNNER_KEY" >> .env
else
echo "No runner key provided. Continuing..."
fi
echo "ROOT_URL=http://$IPV4_ADDRESS:3000" >> .env
echo "Stopping initial setup container ..."
docker compose -f config/docker-compose.init.yml down
echo "Disabling temporary port 3000 ..."
sudo ufw delete allow 3000/tcp
sudo ufw reload
sudo ufw status
fi
# Get the current IPv4 address