Parcourir la source

:hammer: add vagrant env

Jeremy Zheng il y a 1 an
Parent
commit
e5f8b449b0
4 fichiers modifiés avec 136 ajouts et 0 suppressions
  1. 1 0
      vagrant/.gitignore
  2. 19 0
      vagrant/README.md
  3. 116 0
      vagrant/Vagrantfile
  4. 0 0
      vagrant/mnt/.gitkeep

+ 1 - 0
vagrant/.gitignore

@@ -0,0 +1 @@
+/.vagrant/

+ 19 - 0
vagrant/README.md

@@ -0,0 +1,19 @@
+# Spring development
+
+## Usage
+
+```bash
+# start the virtual machine
+vagrant up
+# connect to the virtual machine
+vagrant ssh
+# showdown the virtual machine
+vagrant down
+# destroy the virtual machine
+vagrant destroy
+```
+
+## Documents
+
+- [Install VirtualBox](https://www.virtualbox.org/wiki/Downloads)
+- [Install Vagrant](https://developer.hashicorp.com/vagrant/tutorials/getting-started/getting-started-install)

+ 116 - 0
vagrant/Vagrantfile

@@ -0,0 +1,116 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# All Vagrant configuration is done below. The "2" in Vagrant.configure
+# configures the configuration version (we support older styles for
+# backwards compatibility). Please don't change it unless you know what
+# you're doing.
+Vagrant.configure("2") do |config|
+  # The most common configuration options are documented and commented below.
+  # For a complete reference, please see the online documentation at
+  # https://docs.vagrantup.com.
+
+  # Every Vagrant development environment requires a box. You can search for
+  # boxes at https://vagrantcloud.com/search.
+  config.vm.box = "archlinux/archlinux"
+  config.vm.box_version = "20241001.267073"
+
+  # Disable automatic box update checking. If you disable this, then
+  # boxes will only be checked for updates when the user runs
+  # `vagrant box outdated`. This is not recommended.
+  # config.vm.box_check_update = false
+
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine. In the example below,
+  # accessing "localhost:8080" will access port 80 on the guest machine.
+  # NOTE: This will enable public access to the opened port
+  config.vm.network "forwarded_port", guest: 8000, host: 8000
+  config.vm.network "forwarded_port", guest: 3000, host: 3000
+  config.vm.network "forwarded_port", id: "ssh", guest: 22, host: 10022
+
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine and only allow access
+  # via 127.0.0.1 to disable public access
+  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
+
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  # config.vm.network "private_network", ip: "192.168.33.10"
+
+  # Create a public network, which generally matched to bridged network.
+  # Bridged networks make the machine appear as another physical device on
+  # your network.
+  config.vm.network "public_network"
+
+  # Share an additional folder to the guest VM. The first argument is
+  # the path on the host to the actual folder. The second argument is
+  # the path on the guest to mount the folder. And the optional third
+  # argument is a set of non-required options.
+  config.vm.synced_folder "./mnt", "/mnt"
+
+  # Disable the default share of the current code directory. Doing this
+  # provides improved isolation between the vagrant box and your host
+  # by making sure your Vagrantfile isn't accessible to the vagrant box.
+  # If you use this you may want to enable additional shared subfolders as
+  # shown above.
+  # config.vm.synced_folder ".", "/vagrant", disabled: true
+
+  # Provider-specific configuration so you can fine-tune various
+  # backing providers for Vagrant. These expose provider-specific options.
+  # Example for VirtualBox:
+  #
+  config.vm.provider "virtualbox" do |vb|
+    vb.name = "spring"
+  #   # Display the VirtualBox GUI when booting the machine
+  #   vb.gui = true
+  #
+    # Customize the amount of memory on the VM:
+    vb.memory = "4096"
+  end
+  #
+  # View the documentation for the provider you are using for more
+  # information on available options.
+
+  config.ssh.insert_key = false
+  config.ssh.password = "123456"
+
+  # Enable provisioning with a shell script. Additional provisioners such as
+  # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
+  # documentation for more information about their specific syntax and use.
+  config.vm.provision "shell", inline: <<-SHELL
+    pacman-key --init
+    pacman -Sy --noconfirm archlinux-keyring
+    pacman-key --populate
+    pacman -Syu --noconfirm
+    pacman -S --needed --noconfirm base-devel bzip2 bzip3 p7zip unarchiver vim git cmake wget zsh man-db man-pages \
+      pwgen sshpass openssl openssh rsync zip unzip tree tmux asciidoc doxygen cpio net-tools bind-tools \
+      imagemagick ffmpeg xorg-font-util \
+      ttf-dejavu wqy-bitmapfont wqy-microhei wqy-zenhei \
+      composer xdebug php-fpm php-pgsql php-sqlite php-redis php-mongodb php-imagick php-gd php-intl php-enchant php-snmp php-tidy php-xsl php-sodium php-odbc php-pspell \
+      hspell nuspell libvoikko hunspell hunspell-en_us \
+      nodejs npm yarn \
+      postgresql rabbitmq redis
+    pacman -Scc --noconfirm
+    
+    echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
+    systemctl enable postgresql
+    systemctl eanble redis
+    systemctl enable rabbitmq
+
+    su -c vagrant -l mkdir -p ~/downloads ~/build ~/local ~/tmp
+    su -c vagrant -l git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
+    su -c vagrant -l cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
+    su -c vagrant -l echo 'export LANG=en_US.UTF-8' >> ~/.zshrc
+    su -c vagrant -l echo 'export LC_ALL=en_US.UTF-8' >> ~/.zshrc
+    su -c vagrant -l echo 'export EDITOR=vim' >> ~/.zshrc
+
+    su -c vagrant -l git config --global core.quotepath false
+    su -c vagrant -l git config --global http.version HTTP/1.1
+    su -c vagrant -l git config --global pull.rebase false
+
+    su -c vagrant -l echo 'set-option -g history-limit 102400' > ~/.tmux.conf
+    su -c vagrant -l echo 'set-option -g default-shell "/bin/zsh"' >> ~/.tmux.conf
+    
+    chsh -s /bin/zsh vagrant
+  SHELL
+end

+ 0 - 0
vagrant/mnt/.gitkeep