From 4c6ddebd1bc6cda6ed83655a54c5bc277aa3fe2c Mon Sep 17 00:00:00 2001 From: Chad Date: Wed, 1 Jan 2025 22:04:41 +0000 Subject: [PATCH] Add Git Servers (#22) * Create files for two possible Git server frontends for moving off of GitHub. * Add test results and uncomment preferred configuration style. * Add example for Git repo server. * Add details on how the connection alias is used. * Finalize testing and provide recommended setups. --- Config/Gitea/docker-compose.micro.yml | 71 +++++++++++++++++++ Config/Gogs/docker-compose.micro.yml | 70 ++++++++++++++++++ .../config/conf.d/git.example.com | 58 +++++++++++++++ Config/ReverseProxy/config/hosts/example.com | 8 +++ 4 files changed, 207 insertions(+) create mode 100644 Config/Gitea/docker-compose.micro.yml create mode 100644 Config/Gogs/docker-compose.micro.yml create mode 100644 Config/ReverseProxy/config/conf.d/git.example.com diff --git a/Config/Gitea/docker-compose.micro.yml b/Config/Gitea/docker-compose.micro.yml new file mode 100644 index 0000000..cecb619 --- /dev/null +++ b/Config/Gitea/docker-compose.micro.yml @@ -0,0 +1,71 @@ +# 2024-12-30 Hyperling +# Gitea self-hosted git server! +# https://hub.docker.com/r/gitea/gitea +# https://docs.gitea.com/installation/install-with-docker + +# Takes nearly double the resources of Gogs. +# Has a nicer UI and more features. Can anyone say, "Dark Theme"? ;D + +services: + + app: + ## Database ## + # SQL Lite + + ## App ## + container_name: gitea-app + image: gitea/gitea:latest + restart: always + ports: + - "3001:3000" + - "2201:22" + volumes: + - ../../Volumes/Gitea/gitea:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + environment: + - USER_UID=1000 + - USER_GID=1000 + #networks: + # - gitea + deploy: + mode: global + resources: + limits: + # Minimum requirements for processes to start properly. + # Takes a while to start up and migrate projects, but does work. + ###cpus: '0.05' + ###memory: 64M + # Production-quality performance. + ###cpus: '0.10' + ###memory: 128M + # Extra! Idles around 120M but exceeds 170M sometimes after busy. + ###cpus: '0.25' + ###memory: 192M + # Final thoughts after tests. + cpus: '0.50' + memory: 192M + +## Test Results ## +# 0.05 CPU, 64MB RAM +# - Migrate https://github.com/hyperling/ansible +# - Page: 10512ms Template: 2111ms +# - Migrate https://github.com/hyperling/website +# - Page: 6514ms Template: 807ms +# - Migrate https://github.com/hyperling/docker +# - Page: 8105ms Template: 1201ms +# 0.10 CPU, 128MB RAM +# - Migrate https://github.com/hyperling/ansible +# - Page: 2501ms Template: 294ms +# - Migrate https://github.com/hyperling/website +# - Page: 786ms Template: 194ms +# - Migrate https://github.com/hyperling/docker +# - Page: 1283ms Template: 87ms +# 0.25 CPU, 192MB RAM +# - Migrate https://github.com/hyperling/ansible +# - Page: 439ms Template: 101ms +# - Migrate https://github.com/hyperling/website +# - Page: 541ms Template: 2ms +# - Migrate https://github.com/hyperling/docker +# - Page: 254ms Template: 86ms +## ## diff --git a/Config/Gogs/docker-compose.micro.yml b/Config/Gogs/docker-compose.micro.yml new file mode 100644 index 0000000..8c5a25f --- /dev/null +++ b/Config/Gogs/docker-compose.micro.yml @@ -0,0 +1,70 @@ +# 2024-12-30 Hyperling +# Gogs self-hosted git server! +# https://hub.docker.com/r/gogs/gogs +# https://gist.github.com/ahromis/4ce4a58623847ca82cb1b745c2f83c82 + +# Takes nearly half the resources of Gitea. +# Has a more basic UI and may be lacking features. So slim though!! + +services: + + app: + ## Database ## + # SQL Lite + + ## App ## + container_name: gogs-app + image: gogs/gogs:latest + restart: always + ports: + - "3000:3000" + - "2202:22" + volumes: + - ../../Volumes/Gogs/gogs:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + environment: + - "RUN_CROND=true" + #networks: + # - gogs + deploy: + mode: global + resources: + limits: + # Minimum requirements for processes to start properly. + # Works pretty well! Takes a little to migrate, otherwise snappy! + ###cpus: '0.02' + ###memory: 32M + # Seamless performance. + ###cpus: '0.05' + ###memory: 64M + # Extra! Idles at 50M, will probably never use all this for 1 user. + ###cpus: '0.25' + ###memory: 192M + # Final thoughts after tests. + cpus: '0.50' + memory: 96M + +## Test Results ## +# 0.02 CPU, 32MB RAM +# - Migrate https://github.com/hyperling/ansible +# - Page: 20684ms Template: 3001ms, Page: 16503ms Template: 492ms +# - Migrate https://github.com/hyperling/website +# - Page: 12495ms Template: 800ms +# - Migrate https://github.com/hyperling/docker +# - Page: 9591ms Template: 591ms +# 0.05 CPU, 64MB RAM +# - Migrate https://github.com/hyperling/ansible +# - Page: 4602ms Template: 2ms +# - Migrate https://github.com/hyperling/website +# - Page: 3269ms Template: 1ms +# - Migrate https://github.com/hyperling/docker +# - Page: 2481ms Template: 1ms +# 0.25 CPU, 192MB RAM +# - Migrate https://github.com/hyperling/ansible +# - Page: 575ms Template: 2ms +# - Migrate https://github.com/hyperling/website +# - Page: 131ms Template: 4ms +# - Migrate https://github.com/hyperling/docker +# - Page: 350ms Template: 1ms +## ## diff --git a/Config/ReverseProxy/config/conf.d/git.example.com b/Config/ReverseProxy/config/conf.d/git.example.com new file mode 100644 index 0000000..5559cc5 --- /dev/null +++ b/Config/ReverseProxy/config/conf.d/git.example.com @@ -0,0 +1,58 @@ +# 2024-12-31 Hyperling +# A dummy test file since true scripts are being kept private. +# This should help anyone understand how the project is being used. + +## Instructions ## +# Add this without the comment to your /etc/hosts to test that it is working, +# YOUR_DOCKER_SERVER_IP git.example.com +# If testing locally on a workstation, +# 127.0.0.1 git.example.com +# Then to test, first start the container, +# cd $DOCKER_HOME/Config/ReverseProxy && docker compose build && docker compose up -d +# Then from the system with the modified /etc/hosts, +# curl --insecure git.example.com +# You should see activity in the container log as well as the contents of the +# proxied website in the terminal, NOT git.example.com. If using a browser then you +# should notice that the URL is still git.example.com but the website is correct. + +# Force HTTPS +server { + + listen 80; + server_name git.example.com; + + location /.well-known/acme-challenge/ { + default_type "text/plain"; + root /etc/nginx/letsencrypt/; + } + + # Redirect to a more secure protocol. + location / { + return 301 https://$host$request_uri; + } + +} + +# Serve Resource +server { + + listen 443 ssl; + server_name git.example.com; + + # The certs being used for the website. + ssl_certificate /etc/nginx/certs/git.example.com/fullchain.pem; + ssl_certificate_key /etc/nginx/certs/git.example.com/privkey.pem; + + location /.well-known/acme-challenge/ { + default_type "text/plain"; + root /etc/nginx/letsencrypt/; + } + + # Send traffic to upstream server + location / { + ## General format is PROTOCOL://SERVER:PORT. + # This server connection is managed in the 'hosts/example.com' file. + proxy_pass http://example-git-site; + } + +} diff --git a/Config/ReverseProxy/config/hosts/example.com b/Config/ReverseProxy/config/hosts/example.com index 21d9e34..1998525 100644 --- a/Config/ReverseProxy/config/hosts/example.com +++ b/Config/ReverseProxy/config/hosts/example.com @@ -1,7 +1,15 @@ # Local servers for everything related to `example.com`. # If specific ports are needed they will go here instead of the `conf.d` file(s). +# NOTE: 'server hyperling.com;' is used so that the file works in production, +# it is not part of the example, the commented value is what's important. + upstream example-proxy-site { #server 127.0.0.1:8080; server hyperling.com; } + +upstream example-git-site { + #server 127.0.0.1:3000; + server hyperling.com; +}