dockerized #1

Merged
e merged 8 commits from dockerized into main 2024-08-02 01:01:08 +00:00
Showing only changes of commit aa1ca23652 - Show all commits

42
gitea
View File

@ -3,7 +3,8 @@
set -e
CONTAINER_NAME="gitea"
WEB_PORT="3000"
HTTP_PORT="80"
HTTPS_PORT="443"
SSH_PORT="2222"
PROFILE_NAME="gitea-profile"
ROOT_DISK_SIZE="20GB"
@ -51,6 +52,9 @@ install_gitea() {
exit 1
fi
# Ask for the domain name
read -p "Enter your domain name (e.g., gitea.example.com): " DOMAIN_NAME
echo "Creating Incus container..."
incus launch images:ubuntu/22.04 $CONTAINER_NAME -p $PROFILE_NAME
@ -61,7 +65,8 @@ install_gitea() {
incus config set $CONTAINER_NAME security.nesting=true
incus config set $CONTAINER_NAME linux.kernel_modules=overlay,nf_nat
incus config device add $CONTAINER_NAME gitea-ssh proxy listen=tcp:0.0.0.0:$SSH_PORT connect=tcp:127.0.0.1:22
incus config device add $CONTAINER_NAME gitea-web proxy listen=tcp:0.0.0.0:$WEB_PORT connect=tcp:127.0.0.1:3000
incus config device add $CONTAINER_NAME gitea-http proxy listen=tcp:0.0.0.0:$HTTP_PORT connect=tcp:127.0.0.1:80
incus config device add $CONTAINER_NAME gitea-https proxy listen=tcp:0.0.0.0:$HTTPS_PORT connect=tcp:127.0.0.1:443
echo "Waiting for network to be ready..."
sleep 10
@ -69,7 +74,7 @@ install_gitea() {
echo "Installing Docker and Docker Compose..."
incus exec $CONTAINER_NAME -- bash -c "
apt update
apt install -y docker.io docker-compose
apt install -y docker.io docker-compose nginx certbot python3-certbot-nginx
"
echo "Creating Docker Compose file..."
@ -118,15 +123,43 @@ services:
- /var/lib/postgresql/data:/var/lib/postgresql/data
EOL"
echo "Creating Nginx configuration..."
incus exec $CONTAINER_NAME -- bash -c "cat > /etc/nginx/sites-available/gitea << EOL
server {
listen 80;
server_name $DOMAIN_NAME;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host \\\$host;
proxy_set_header X-Real-IP \\\$remote_addr;
}
}
EOL"
echo "Enabling Nginx configuration..."
incus exec $CONTAINER_NAME -- bash -c "
ln -s /etc/nginx/sites-available/gitea /etc/nginx/sites-enabled/
rm /etc/nginx/sites-enabled/default
nginx -t && systemctl reload nginx
"
echo "Starting Gitea and PostgreSQL with Docker Compose..."
incus exec $CONTAINER_NAME -- bash -c "
cd /root
docker-compose up -d
"
echo "Configuring SSL with Certbot..."
incus exec $CONTAINER_NAME -- certbot --nginx -d $DOMAIN_NAME --non-interactive --agree-tos --email admin@$DOMAIN_NAME
CONTAINER_IP=$(incus exec $CONTAINER_NAME -- ip addr show eth0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1)
echo "Gitea setup complete!"
echo "Access Gitea at http://$(incus exec $CONTAINER_NAME -- ip addr show eth0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1):$WEB_PORT"
echo "Access Gitea at https://$DOMAIN_NAME"
echo "SSH access available on port $SSH_PORT"
echo ""
echo "Important: Make sure your domain ($DOMAIN_NAME) is pointed to this server's IP address: $CONTAINER_IP"
}
# Function to display usage
@ -195,3 +228,4 @@ case "$1" in
esac
exit 0