Skip to content

Commit 814868b

Browse files
committed
Merge branch 'develop'
2 parents a0c4579 + 502b35d commit 814868b

File tree

7 files changed

+431
-0
lines changed

7 files changed

+431
-0
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,12 @@ set-upstream-feature-branches:
9898
git branch --set-upstream-to=origin/develop "$$branch" || echo "Failed to set upstream for $$branch"; \
9999
done
100100
@echo "Done setting upstreams for feature branches."
101+
102+
# setting up executable permissions for shell scripts
103+
set-script-permissions:
104+
@echo "Setting up executable permissions for shell scripts..."
105+
@find scripts base_vm/scripts -name "*.sh" -type f -exec git update-index --chmod=+x {} \;
106+
@echo "Adding executable files to git..."
107+
@git add --chmod=+x scripts/*.sh base_vm/scripts/*.sh 2>/dev/null || true
108+
@echo "Shell script permissions fixed. Run 'git status' to see changes."
109+
@echo "Note: If any script is missing a shebang, add '#!/bin/bash' as the first line."

Vagrantfile

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# Environment variables
5+
VAGRANT_BOX = "vbox-docker-ubuntu2404" # Standard Ubuntu 22.04 LTS box
6+
VAGRANT_BOX_VERSION = "0"
7+
VM_NAME = "mkdocforge.local"
8+
VM_IP = "192.168.56.150"
9+
VM_MEMORY = 4096 # MB
10+
VM_CPUS = 2
11+
VM_CPUEXECUTIONCAP = 100 # CPU execution cap (percentage)
12+
13+
Vagrant.configure("2") do |config|
14+
# Basic box configuration
15+
config.vm.box = VAGRANT_BOX
16+
config.vm.box_version = VAGRANT_BOX_VERSION
17+
config.vm.hostname = VM_NAME
18+
config.vm.boot_timeout = 600
19+
config.vm.box_check_update = false
20+
21+
# Network configuration
22+
config.vm.network :private_network,
23+
ip: VM_IP,
24+
netmask: "24",
25+
auto_config: true,
26+
hostname: true
27+
28+
# Synced folder configuration with performance optimizations
29+
config.vm.synced_folder ".", "/home/vagrant/mkdocforge",
30+
type: "rsync",
31+
disabled: false,
32+
rsync__chown: true,
33+
owner: "vagrant",
34+
group: "vagrant",
35+
mount_options: ["dmode=775,fmode=777"],
36+
rsync__args: ["--verbose", "--archive", "--delete", "-z", "--compress-level=9"],
37+
rsync__exclude: [
38+
".git/", \
39+
".github/", \
40+
".vscode/", \
41+
"node_modules/", \
42+
".DS_Store", \
43+
".cache/", \
44+
".qodo/", \
45+
".ruff_cache/", \
46+
".vagrant/", \
47+
".venv/", \
48+
"venv/", \
49+
"site/", \
50+
"mkdocforge.egg-info/", \
51+
]
52+
53+
# HostManager plugin configuration
54+
if Vagrant.has_plugin?("vagrant-hostmanager")
55+
config.hostmanager.enabled = true
56+
config.hostmanager.manage_host = false
57+
# config.hostmanager.manage_host = true
58+
config.hostmanager.manage_guest = true
59+
config.hostmanager.ignore_private_ip = false
60+
config.hostmanager.include_offline = true
61+
config.hostmanager.elevate_commands = true
62+
config.vm.provision :hostmanager
63+
end
64+
65+
# VirtualBox provider configuration with advanced performance optimizations
66+
config.vm.provider "virtualbox" do |vb|
67+
vb.name = VM_NAME
68+
vb.memory = VM_MEMORY
69+
vb.cpus = VM_CPUS
70+
vb.check_guest_additions = false
71+
72+
# CPU optimizations
73+
vb.customize ["modifyvm", :id, "--cpuexecutioncap", VM_CPUEXECUTIONCAP]
74+
vb.customize ["modifyvm", :id, "--nestedpaging", "on"]
75+
vb.customize ["modifyvm", :id, "--largepages", "on"]
76+
vb.customize ["modifyvm", :id, "--vtxvpid", "on"]
77+
vb.customize ["modifyvm", :id, "--vtxux", "on"]
78+
vb.customize ["modifyvm", :id, "--pae", "on"]
79+
vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
80+
81+
# I/O optimizations
82+
vb.customize ["modifyvm", :id, "--ioapic", "on"]
83+
vb.customize ["modifyvm", :id, "--hpet", "on"]
84+
# vb.customize ["storagectl", :id, "--name", "SATA Controller", "--hostiocache", "on"]
85+
86+
# Memory optimizations
87+
vb.customize ["modifyvm", :id, "--pagefusion", "on"]
88+
89+
# Network optimizations
90+
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
91+
vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
92+
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
93+
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
94+
95+
# Other optimizations
96+
vb.customize ['modifyvm', :id, '--tpm-type', '2.0']
97+
vb.customize ['modifyvm', :id, '--chipset', 'ich9'] # Changed from piix3 to ich9 for better performance
98+
vb.customize ['modifyvm', :id, '--vm-process-priority', 'high']
99+
vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
100+
vb.customize ["modifyvm", :id, "--accelerate3d", "off"]
101+
vb.customize ["modifyvm", :id, "--audio", "none"]
102+
vb.customize ["modifyvm", :id, "--usb", "off"]
103+
vb.customize ["modifyvm", :id, "--clipboard-mode", "bidirectional"]
104+
vb.customize ["modifyvm", :id, "--draganddrop", "hosttoguest"]
105+
106+
# Disk I/O optimizations - specify SSD if applicable
107+
# vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", "0", "--nonrotational", "on", "--discard", "on"]
108+
end
109+
110+
# Disable automatic VBGuest updates if plugin is installed
111+
if Vagrant.has_plugin?("vagrant-vbguest")
112+
config.vbguest.auto_update = false
113+
end
114+
115+
# TCP offloading and custom NIC settings
116+
config.vm.provision "shell", path: "scripts/tune_performance.sh", privileged: true
117+
118+
# Optional: Run system update s
119+
config.vm.provision "shell", path: "scripts/update_system.sh", privileged: true
120+
121+
# Optional: Install common development tools
122+
config.vm.provision "shell", path: "scripts/install_dev_tools.sh", privileged: true
123+
124+
# Boot time optimization - disable GUI
125+
config.vm.provider "virtualbox" do |vb|
126+
vb.gui = false
127+
end
128+
129+
# Additional port forwarding for web services
130+
config.vm.network "forwarded_port", guest: 8000, host: 8000
131+
132+
# Display post-up message with relevant information
133+
config.vm.post_up_message = <<-MESSAGE
134+
135+
Access your virtual machine:
136+
* SSH: vagrant ssh
137+
* Web: http://#{VM_IP}:8000/ or http://localhost:8000/
138+
139+
140+
VM Info:
141+
* OS: Ubuntu 22.04 LTS
142+
* Hostname: #{VM_NAME}
143+
* IP Address: #{VM_IP}
144+
* Memory: #{VM_MEMORY}MB
145+
* CPUs: #{VM_CPUS}
146+
147+
Your files are synced to: /home/vagrant/mkdocforge
148+
MESSAGE
149+
end

scripts/base_provision.sh

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
#
3+
# Development Environment Setup Script for Ubuntu 24.04 (Noble)
4+
# For use with Vagrant
5+
# Following official Docker installation guide:
6+
# https://docs.docker.com/engine/install/ubuntu/
7+
8+
# Error handling
9+
set -e
10+
trap 'echo "Error occurred at line $LINENO. Command: $BASH_COMMAND"' ERR
11+
12+
# Log function
13+
log() {
14+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
15+
}
16+
17+
log "Beginning setup for Ubuntu 24.04 development environment"
18+
19+
# Update and upgrade system
20+
log "Updating package repositories"
21+
sudo apt-get update
22+
log "Upgrading existing packages"
23+
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
24+
25+
# Install development tools
26+
log "Installing development tools and libraries"
27+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
28+
linux-headers-$(uname -r) \
29+
build-essential \
30+
dkms \
31+
tree \
32+
gcc \
33+
make \
34+
automake \
35+
cmake \
36+
libssl-dev \
37+
libnghttp2-dev
38+
39+
# Install Docker prerequisites
40+
log "Installing Docker prerequisites"
41+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
42+
ca-certificates \
43+
curl \
44+
gnupg
45+
46+
# Add Docker's official GPG key (official method)
47+
log "Adding Docker's official GPG key"
48+
sudo install -m 0755 -d /etc/apt/keyrings
49+
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
50+
-o /etc/apt/keyrings/docker.asc
51+
sudo chmod a+r /etc/apt/keyrings/docker.asc
52+
53+
# Add Docker repository (official method)
54+
log "Adding Docker repository"
55+
echo \
56+
"deb [arch=$(dpkg --print-architecture) \
57+
signed-by=/etc/apt/keyrings/docker.asc] \
58+
https://download.docker.com/linux/ubuntu \
59+
$(. /etc/os-release && echo \
60+
"${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
61+
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
62+
63+
# Update apt repositories with Docker repo
64+
log "Updating package lists with Docker repository"
65+
sudo apt-get update
66+
67+
# Install Docker packages (official method)
68+
log "Installing Docker Engine and related tools"
69+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
70+
docker-ce \
71+
docker-ce-cli \
72+
containerd.io \
73+
docker-buildx-plugin \
74+
docker-compose-plugin
75+
76+
# Configure Docker for Vagrant user
77+
log "Configuring Docker user permissions"
78+
sudo groupadd docker 2>/dev/null || true
79+
80+
# In Vagrant, use 'vagrant' user, otherwise use current user
81+
if id vagrant &>/dev/null; then
82+
DOCKER_USER="vagrant"
83+
else
84+
DOCKER_USER=$USER
85+
fi
86+
87+
log "Adding user '$DOCKER_USER' to docker group"
88+
sudo usermod -aG docker $DOCKER_USER
89+
90+
# Start and enable Docker service
91+
log "Enabling and starting Docker service"
92+
sudo systemctl enable docker
93+
sudo systemctl start docker
94+
95+
# Verify Docker installation
96+
log "Verifying Docker installation"
97+
if sudo docker run --rm hello-world > /dev/null 2>&1; then
98+
log "Docker installation verified successfully"
99+
else
100+
log "WARNING: Docker verification failed."
101+
log "Please check Docker installation manually."
102+
fi
103+
104+
log "Installation complete!"
105+
log "You may need to log out and back in for Docker group changes to" \
106+
" take effect."
107+
log "Alternatively, run 'newgrp docker' to apply group changes"
108+
log "in current session."

scripts/install_dev_tools.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
#
3+
# Development Tools Installation Script for Vagrant
4+
# Installs common development tools
5+
6+
# Error handling
7+
set -e
8+
trap 'echo "Error occurred at line $LINENO. Command: $BASH_COMMAND"' ERR
9+
10+
# Log function
11+
log() {
12+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
13+
}
14+
15+
log "Starting installation of development tools"
16+
17+
# Install development tools
18+
log "Installing development tools"
19+
sudo apt-get install -y \
20+
build-essential \
21+
git \
22+
curl \
23+
wget \
24+
unzip \
25+
zip \
26+
htop \
27+
iotop \
28+
iftop
29+
30+
log "Development tools installation completed successfully"

scripts/provision.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
#
3+
# Main Provisioning Script for Vagrant
4+
# Orchestrates the execution of other specialized scripts
5+
6+
# Error handling
7+
set -e
8+
trap 'echo "Error occurred at line $LINENO. Command: $BASH_COMMAND"' ERR
9+
10+
# Log function
11+
log() {
12+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
13+
}
14+
15+
log "Starting main provisioning process"
16+
17+
# Change to project directory
18+
PROJECT_DIR="/home/vagrant/mkdocforge"
19+
cd ${PROJECT_DIR}
20+
21+
# Execute commands using Makefile
22+
log "Building Docker containers"
23+
make docker-build
24+
25+
log "Starting Docker containers in detached mode"
26+
make docker-up
27+
28+
log "Listing all Docker containers"
29+
make docker-ps
30+
31+
log "Displaying Docker container logs"
32+
make docker-logs
33+
34+
log "Docker provisioning completed successfully"

0 commit comments

Comments
 (0)