From 47a1f83a16b0b2aec6cb9ed31789a7a86f2b9846 Mon Sep 17 00:00:00 2001 From: "Evan W. Patton" Date: Tue, 10 Dec 2019 11:47:24 -0500 Subject: [PATCH] Add Vagrantfile for development environment bootstrapping (#1540) * Add Vagrantfile for development environment bootstrapping Change-Id: I2fb08206d96f2ff0da73954f820134b7a0684aef --- README.md | 33 ++++++++++++++++++++++++++++++++- Vagrantfile | 30 ++++++++++++++++++++++++++++++ bootstrap.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 Vagrantfile create mode 100644 bootstrap.sh diff --git a/README.md b/README.md index 8b61f3c71fc..0fe746d16d3 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,38 @@ If you have skipped this step and have gone ahead and made your changes already, Check out our open source [site](http://appinventor.mit.edu/appinventor-sources/) to find a lot more information about the project and how to contribute to it. -## Setup instructions +## Setup instructions (Vagrant) + +The easiest way to get a development environment up and running is to use the provided Vagrantfile. Install [Vagrant](https://vagrantup.com) and open a terminal in the root directory of this repository. Run the following commands + +```bash +vagrant plugin install vagrant-vbguest # optionally for virtualbox users, and only once +vagrant up # initializes the VM +``` + +It may take a few minutes for Vagrant to initialize as it will pull down a virtual machine image from the Internet and configure it with all of the App Inventor dependencies. Subsequent start-ups will be faster. Next, enter the virtual machine by running: + +```bash +vagrant ssh +``` + +This should open up a terminal within the virtual machine in the directory `/vagrant/appinventor`. This directory is the same as the `appinventor` directory in this repository, shared between your host machine and the virtual machine. Any changes made on one side will be visible in the other. This allows you to edit files on your host machine with your preferred editor, while keeping the build environment relegated to the virtual machine. To build App Inventor, you may now run: + +```bash +ant +``` + +and to run App Inventor: + +```bash +start_appinventor +``` + +Press Ctrl+C to quit the server. Enter exit at the prompt to leave the virtual machine. To reclaim resources when you are not actively developing, you can run `vagrant halt` to stop the virtual machine. To completely remove the virtual machine, run `vagrant destroy`. If you destroy the VM, you will need to start these instructions from the top. + +For better performance, consider using the manual instructions. + +## Setup instructions (manual) This is a quick guide to get started with the sources. More detailed instructions can be found [here](https://docs.google.com/document/pub?id=1Xc9yt02x3BRoq5m1PJHBr81OOv69rEBy8LVG_84j9jc), a slide show can be seen [here](http://josmas.github.io/contributingToAppInventor2/#/), and all the [documentation](http://appinventor.mit.edu/appinventor-sources/#documentation) for the project is available in our [site](http://appinventor.mit.edu/appinventor-sources/). diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000000..daf38c9a606 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,30 @@ +# -*- 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| + + config.vm.box = "ubuntu/bionic64" + + config.vm.boot_timeout = 400 + + config.vm.provider "virtualbox" do |v| + v.name = "ForAppinventor2-bionic64" + v.memory = "4096" + v.customize ["modifyvm", :id, "--usb", "on"] + # fix for slow network + v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + v.customize ["modifyvm", :id, "--natdnsproxy1", "on"] + v.customize ["modifyvm", :id, "--nictype1", "virtio"] + end + + config.vm.provision :shell, path: "bootstrap.sh" + + config.vm.network :forwarded_port, guest: 8888, host: 8888 + config.vm.network :forwarded_port, guest: 9990, host: 9990 + +end diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 00000000000..2d10183aa35 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +dpkg --add-architecture i386 + +# Install dependencies +apt-get update +apt-get upgrade -y +apt-get install -y libc6:i386 libstdc++6:i386 glibc-doc:i386 gcc-5-base:i386 gcc-6-base:i386 libgcc1:i386 \ + openjdk-8-jdk zip unzip ant lib32z1 adb phantomjs + +# Install App Engine +mkdir -p /opt/appengine +cd /opt/appengine +wget --no-verbose -O /tmp/appengine.zip https://storage.googleapis.com/appengine-sdks/featured/appengine-java-sdk-1.9.68.zip +unzip -o /tmp/appengine.zip + +# Configure shell +echo "export PATH=$PATH:/opt/appengine/appengine-java-sdk-1.9.68/bin" >> /home/vagrant/.bashrc +echo "cd /vagrant/appinventor" >> /home/vagrant/.bashrc + +# Configure java +update-java-alternatives -s java-1.8.0-openjdk-amd64 + +# Make the auth key in advance +cd /vagrant/appinventor +sudo -u vagrant ant MakeAuthKey + +# Helper script for starting App Inventor dev server +cat < /usr/local/bin/start_appinventor +ant RunLocalBuildServer &> buildserver.log & +BUILDSERVER=$! +dev_appserver.sh -p 8888 -a 0.0.0.0 appengine/build/war +kill -9 -- -$BUILDSERVER +EOF +chmod +x /usr/local/bin/start_appinventor