From 78015bee80c1bb84da478ac1f9cf4c433b1d7a75 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 29 May 2025 10:57:45 -0600 Subject: [PATCH] added gitea and fixed the config script up --- add-cname-records.sh | 3 +- config.sh | 71 +++++++++++++++++++++++++- configs/cloudflare/tunnel-config.yml | 21 ++++---- configs/homepage/bookmarks.yaml | 6 +++ configs/homepage/services.yaml | 21 +++++--- configs/homepage/widgets.yaml | 4 ++ docker-compose.yml | 76 ++++++++++++++++++++++++---- mkdocs/docs/overrides/main.html | 2 +- 8 files changed, 174 insertions(+), 30 deletions(-) diff --git a/add-cname-records.sh b/add-cname-records.sh index 1b8c475..5e26427 100755 --- a/add-cname-records.sh +++ b/add-cname-records.sh @@ -61,6 +61,7 @@ SUBDOMAINS=( "docs" "n8n" "db" + "git" ) # Function to check if DNS record already exists @@ -155,7 +156,7 @@ fi PROTECTED_SERVICES=("dashboard" "code") # Services that should have bypass policies (public access) - updated for our use case -BYPASS_SERVICES=("listmonk" "docs" "n8n" "db") +BYPASS_SERVICES=("listmonk" "docs" "n8n" "db" "git") # Function to create access application with email authentication create_protected_app() { diff --git a/config.sh b/config.sh index 1906dd7..3287cdf 100755 --- a/config.sh +++ b/config.sh @@ -24,6 +24,7 @@ MKDOCS_YML="$SCRIPT_DIR/mkdocs/docs/mkdocs.yml" TUNNEL_CONFIG_DIR="$SCRIPT_DIR/configs/cloudflare" TUNNEL_CONFIG_FILE="$TUNNEL_CONFIG_DIR/tunnel-config.yml" SERVICES_YAML="$SCRIPT_DIR/configs/homepage/services.yaml" +MAIN_HTML="$SCRIPT_DIR/mkdocs/docs/overrides/main.html" echo "Looking for .env file at: $ENV_FILE" @@ -102,12 +103,16 @@ MKDOCS_SITE_SERVER_PORT=4001 N8N_PORT=5678 NOCODB_PORT=8090 HOMEPAGE_PORT=3010 +GITEA_WEB_PORT=3030 +GITEA_SSH_PORT=2222 # Domain Configuration BASE_DOMAIN=https://changeme.org DOMAIN=changeme.org LISTMONK_HOSTNAME=listmonk.changeme.org N8N_HOST=n8n.changeme.org +GITEA_DOMAIN=git.changeme.org +GITEA_ROOT_URL=https://git.changeme.org # Cloudflare Configuration CF_API_TOKEN=your_cloudflare_api_token @@ -208,6 +213,33 @@ update_services_yaml() { return 0 } +# Function to update the login URL in main.html +update_main_html() { + local new_domain=$1 + + if [ ! -f "$MAIN_HTML" ]; then + echo "Warning: main.html not found at $MAIN_HTML" + return 1 + fi + + echo "Updating login URL in main.html..." + + # Create a backup of the main.html file + local timestamp=$(date +"%Y%m%d_%H%M%S") + local backup_file="${MAIN_HTML}.backup_${timestamp}" + cp "$MAIN_HTML" "$backup_file" + echo "Created backup of main.html at $backup_file" + + # Update the login button href to use the new domain + sed -i "s|href=\"https://homepage\.test\.com\"|href=\"https://homepage.$new_domain\"|g" "$MAIN_HTML" + + # Also update any other test.com references + sed -i "s|homepage\.test\.com|homepage.$new_domain|g" "$MAIN_HTML" + + echo "Updated login URL in main.html to: https://homepage.$new_domain" + return 0 +} + # Function to check if a port is in use check_port() { local port=$1 @@ -239,6 +271,8 @@ check_port_conflicts() { "${N8N_PORT:-5678}:N8N" "${NOCODB_PORT:-8090}:NocoDB" "${HOMEPAGE_PORT:-3010}:Homepage" + "${GITEA_WEB_PORT:-3030}:Gitea Web" + "${GITEA_SSH_PORT:-2222}:Gitea SSH" ) local conflicts_found=false @@ -340,6 +374,22 @@ configure_alternative_ports() { fi fi + # Gitea Web + if check_port "${GITEA_WEB_PORT:-3030}"; then + read -p "Enter alternative port for Gitea Web [current: ${GITEA_WEB_PORT:-3030}]: " new_gitea_web_port + if [ ! -z "$new_gitea_web_port" ]; then + update_env_var "GITEA_WEB_PORT" "$new_gitea_web_port" + fi + fi + + # Gitea SSH + if check_port "${GITEA_SSH_PORT:-2222}"; then + read -p "Enter alternative port for Gitea SSH [current: ${GITEA_SSH_PORT:-2222}]: " new_gitea_ssh_port + if [ ! -z "$new_gitea_ssh_port" ]; then + update_env_var "GITEA_SSH_PORT" "$new_gitea_ssh_port" + fi + fi + echo "Port configuration completed." } @@ -366,7 +416,7 @@ tunnel: $tunnel_id # e.g. 1234567890abcdef credentials-file: /home/coder/.cloudflared/$tunnel_id.json # e.g. /home/coder/.cloudflared/[insert tunnel number].json ingress: - - hostname: dashboard.$domain + - hostname: homepage.$domain service: http://localhost:${HOMEPAGE_PORT:-3010} - hostname: code.$domain @@ -387,6 +437,9 @@ ingress: - hostname: db.$domain service: http://localhost:${NOCODB_PORT:-8090} + - hostname: git.$domain + service: http://localhost:${GITEA_WEB_PORT:-3030} + # Catch-all rule (required) - service: http_status:404 EOL @@ -429,12 +482,13 @@ show_tunnel_instructions() { echo "" echo "7. Your services will be available at the following URLs:" echo " - Documentation: https://$domain" - echo " - Dashboard: https://dashboard.$domain" + echo " - Homepage: https://homepage.$domain" echo " - Code Server: https://code.$domain" echo " - Listmonk: https://listmonk.$domain" echo " - N8N: https://n8n.$domain" echo " - NocoDB: https://db.$domain" echo " - MkDocs Dev: https://docs.$domain" + echo " - Gitea: https://git.$domain" echo "" } @@ -484,6 +538,8 @@ update_env_var "HOMEPAGE_VAR_BASE_URL" "https://$domain_name" update_env_var "LISTMONK_HOSTNAME" "listmonk.$domain_name" update_env_var "N8N_HOST" "n8n.$domain_name" update_env_var "CF_DOMAIN" "$domain_name" +update_env_var "GITEA_DOMAIN" "git.$domain_name" +update_env_var "GITEA_ROOT_URL" "https://git.$domain_name" echo "Domain settings updated successfully!" @@ -581,6 +637,10 @@ update_mkdocs_yml "$domain_name" echo -e "\nUpdating service URLs in services.yaml..." update_services_yaml "$domain_name" +# Update the login URL in main.html +echo -e "\nUpdating login URL in main.html..." +update_main_html "$domain_name" + # Listmonk Admin Credentials configuration echo -e "\n---- Listmonk Admin Credentials ----" read -p "Enter Listmonk admin email/username [default: admin@example.com]: " listmonk_user @@ -638,6 +698,13 @@ update_env_var "NOCODB_JWT_SECRET" "$nocodb_jwt_secret" nocodb_db_password=$(generate_password 20) update_env_var "NOCODB_DB_PASSWORD" "$nocodb_db_password" +# Generate and update Gitea passwords +gitea_db_password=$(generate_password 20) +update_env_var "GITEA_DB_PASSWD" "$gitea_db_password" + +gitea_db_root_password=$(generate_password 20) +update_env_var "GITEA_DB_ROOT_PASSWORD" "$gitea_db_root_password" + echo "Secure passwords generated and updated." echo -e "\n✅ Configuration completed successfully!" diff --git a/configs/cloudflare/tunnel-config.yml b/configs/cloudflare/tunnel-config.yml index 3406466..c4ea466 100644 --- a/configs/cloudflare/tunnel-config.yml +++ b/configs/cloudflare/tunnel-config.yml @@ -2,30 +2,33 @@ # Cloudflare Tunnel Configuration # Auto-generated by Changemaker Configuration Wizard -tunnel: test # e.g. 1234567890abcdef -credentials-file: /home/coder/.cloudflared/test.json # e.g. /home/coder/.cloudflared/[insert tunnel number].json +tunnel: 4948fed8-3fd4-4562-ace7-d3e9ebc590b0 # e.g. 1234567890abcdef +credentials-file: /home/coder/.cloudflared/4948fed8-3fd4-4562-ace7-d3e9ebc590b0.json # e.g. /home/coder/.cloudflared/[insert tunnel number].json ingress: - - hostname: dashboard.savetheostriches.com + - hostname: homepage.albertademocracytaskforce.org service: http://localhost:3010 - - hostname: code.savetheostriches.com + - hostname: code.albertademocracytaskforce.org service: http://localhost:8888 - - hostname: listmonk.savetheostriches.com + - hostname: listmonk.albertademocracytaskforce.org service: http://localhost:9000 - - hostname: docs.savetheostriches.com + - hostname: docs.albertademocracytaskforce.org service: http://localhost:4000 - - hostname: savetheostriches.com + - hostname: albertademocracytaskforce.org service: http://localhost:4001 - - hostname: n8n.savetheostriches.com + - hostname: n8n.albertademocracytaskforce.org service: http://localhost:5678 - - hostname: db.savetheostriches.com + - hostname: db.albertademocracytaskforce.org service: http://localhost:8090 + - hostname: git.albertademocracytaskforce.org + service: http://localhost:3030 + # Catch-all rule (required) - service: http_status:404 diff --git a/configs/homepage/bookmarks.yaml b/configs/homepage/bookmarks.yaml index 544bf52..8dd2fd9 100755 --- a/configs/homepage/bookmarks.yaml +++ b/configs/homepage/bookmarks.yaml @@ -12,6 +12,9 @@ - Homepage: - abbr: HP href: https://gethomepage.dev/ + - Gitea: + - abbr: GT + href: https://docs.gitea.io/ - Services: - Listmonk: @@ -26,6 +29,9 @@ - PostgreSQL: - abbr: PG href: https://www.postgresql.org/docs/ + - Gitea: + - abbr: GT + href: https://gitea.io/ - Resources: - Docker: diff --git a/configs/homepage/services.yaml b/configs/homepage/services.yaml index c81b9de..ea833ac 100644 --- a/configs/homepage/services.yaml +++ b/configs/homepage/services.yaml @@ -4,7 +4,7 @@ - Essential Tools: - Code Server: href: "http://localhost:8888" - # href: "https://code.reed.com" # Uncomment for public access + # href: "https://code.albertademocracytaskforce.org" # Uncomment for public access description: VS Code in the browser icon: mdi-code-braces widget: @@ -13,7 +13,7 @@ server: my-docker - Listmonk: href: "http://localhost:9000" - # href: "https://listmonk.reed.com" # Uncomment for public access + # href: "https://listmonk.albertademocracytaskforce.org" # Uncomment for public access description: Newsletter & mailing list manager icon: mdi-email-newsletter widget: @@ -22,18 +22,27 @@ server: my-docker - NocoDB: href: "http://localhost:8090" - # href: "https://db.reed.com" # Uncomment for public access + # href: "https://db.albertademocracytaskforce.org" # Uncomment for public access description: No-code database platform icon: mdi-database widget: type: docker container: changemakerlite-nocodb-1 server: my-docker + - Gitea: + href: "http://localhost:3030" + # href: "https://git.albertademocracytaskforce.org" # Uncomment for public access + description: Git repository hosting + icon: mdi-git + widget: + type: docker + container: gitea_changemaker + server: my-docker - Content & Documentation: - MkDocs (Live): href: "http://localhost:4000" - # href: "https://docs.reed.com" # Uncomment for public access + # href: "https://docs.albertademocracytaskforce.org" # Uncomment for public access description: Live documentation server with hot reload icon: mdi-book-open-page-variant widget: @@ -42,7 +51,7 @@ server: my-docker - Static Site: href: "http://localhost:4001" - # href: "https://reed.com" # Uncomment for public access + # href: "https://albertademocracytaskforce.org" # Uncomment for public access description: Built documentation hosting icon: mdi-web widget: @@ -53,7 +62,7 @@ - Automation & Infrastructure: - n8n: href: "http://localhost:5678" - # href: "https://n8n.reed.com" # Uncomment for public access + # href: "https://n8n.albertademocracytaskforce.org" # Uncomment for public access description: Workflow automation platform icon: mdi-workflow widget: diff --git a/configs/homepage/widgets.yaml b/configs/homepage/widgets.yaml index 0c2fc24..6b53a00 100644 --- a/configs/homepage/widgets.yaml +++ b/configs/homepage/widgets.yaml @@ -21,3 +21,7 @@ - search: provider: duckduckgo target: _blank + +- unifi_console: + text_size: md + text: "Services Available: Code Server, Listmonk, NocoDB, MkDocs, n8n, Gitea" diff --git a/docker-compose.yml b/docker-compose.yml index 40cc83c..ce44715 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,7 @@ services: - "${CODE_SERVER_PORT:-8888}:8080" restart: unless-stopped networks: - - changemaker + - changemaker-lite listmonk-app: image: listmonk/listmonk:latest @@ -30,7 +30,7 @@ services: ports: - "${LISTMONK_PORT:-9000}:9000" networks: - - changemaker + - changemaker-lite hostname: ${LISTMONK_HOSTNAME} depends_on: - listmonk-db @@ -59,7 +59,7 @@ services: ports: - "127.0.0.1:${LISTMONK_DB_PORT:-5432}:5432" networks: - - changemaker + - changemaker-lite environment: <<: *db-credentials healthcheck: @@ -85,7 +85,7 @@ services: - SITE_URL=${BASE_DOMAIN:-https://changeme.org} command: serve --dev-addr=0.0.0.0:8000 --watch-theme --livereload networks: - - changemaker + - changemaker-lite restart: unless-stopped mkdocs-site-server: @@ -101,7 +101,7 @@ services: - "${MKDOCS_SITE_SERVER_PORT:-4001}:80" # Exposes Nginx's port 80 to host port 4001 restart: unless-stopped networks: - - changemaker + - changemaker-lite n8n: image: docker.n8n.io/n8nio/n8n @@ -124,7 +124,7 @@ services: - n8n_data:/home/node/.n8n - ./local-files:/files networks: - - changemaker + - changemaker-lite nocodb: depends_on: @@ -139,7 +139,7 @@ services: volumes: - "nc_data:/usr/app/data" networks: - - changemaker + - changemaker-lite root_db: environment: POSTGRES_DB: root_db @@ -155,7 +155,7 @@ services: volumes: - "db_data:/var/lib/postgresql/data" networks: - - changemaker + - changemaker-lite # Homepage App homepage-changemaker: @@ -176,14 +176,68 @@ services: - HOMEPAGE_VAR_BASE_URL=${HOMEPAGE_VAR_BASE_URL:-http://localhost} restart: unless-stopped networks: - - changemaker + - changemaker-lite + + # Gitea - Git service + gitea-app: + image: gitea/gitea:1.23.7 + container_name: gitea_changemaker + environment: + - USER_UID=${USER_ID:-1000} + - USER_GID=${GROUP_ID:-1000} + - GITEA__database__DB_TYPE=${GITEA_DB_TYPE:-mysql} + - GITEA__database__HOST=${GITEA_DB_HOST:-gitea-db:3306} + - GITEA__database__NAME=${GITEA_DB_NAME:-gitea} + - GITEA__database__USER=${GITEA_DB_USER:-gitea} + - GITEA__database__PASSWD=${GITEA_DB_PASSWD} + - GITEA__server__ROOT_URL=${GITEA_ROOT_URL} + - GITEA__server__HTTP_PORT=3000 + - GITEA__server__PROTOCOL=http + - GITEA__server__DOMAIN=${GITEA_DOMAIN} + - GITEA__server__ENABLE_GZIP=true + - GITEA__server__PROXY_PROTOCOL=true + - GITEA__server__PROXY_PROXY_PROTOCOL_TLS=true + - GITEA__server__PROXY_ALLOW_SUBNET=0.0.0.0/0 + restart: unless-stopped + networks: + - changemaker-lite + volumes: + - gitea_data:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + - "${GITEA_WEB_PORT:-3030}:3000" + - "${GITEA_SSH_PORT:-2222}:22" + depends_on: + - gitea-db + + gitea-db: + image: mysql:8 + container_name: gitea_mysql_changemaker + restart: unless-stopped + environment: + - MYSQL_ROOT_PASSWORD=${GITEA_DB_ROOT_PASSWORD} + - MYSQL_USER=${GITEA_DB_USER:-gitea} + - MYSQL_PASSWORD=${GITEA_DB_PASSWD} + - MYSQL_DATABASE=${GITEA_DB_NAME:-gitea} + networks: + - changemaker-lite + volumes: + - mysql_data:/var/lib/mysql + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "${GITEA_DB_USER:-gitea}", "-p${GITEA_DB_PASSWD}"] + interval: 10s + timeout: 5s + retries: 5 networks: - changemaker: + changemaker-lite: driver: bridge volumes: listmonk-data: n8n_data: nc_data: - db_data: \ No newline at end of file + db_data: + gitea_data: + mysql_data: \ No newline at end of file diff --git a/mkdocs/docs/overrides/main.html b/mkdocs/docs/overrides/main.html index 81a640e..732197a 100644 --- a/mkdocs/docs/overrides/main.html +++ b/mkdocs/docs/overrides/main.html @@ -4,6 +4,6 @@ {% endblock %} {% block announce %} -Login +Login Changemaker Archive. Learn more {% endblock %}