diff --git a/dev.md b/dev.md index 255cc84..ed1d589 100644 --- a/dev.md +++ b/dev.md @@ -9,7 +9,13 @@ 1. The `vagrant up` command starts the VM and runs `provision.sh` as user `root`. The `provision.sh` installs Docker and minikube and pulls related Docker images. It also generates a `start.sh`. Users should run `vagrant ssh` and execute `start.sh` inside the VM as user `vagrant`. The `start.sh` starts minikube, deploys Argo/Tekton, and run all the services in the VM. 1. Every time we edit the `provison.sh`, we can run `vagrant provision` to rerun `provision.sh` as root. This rerun would see the previously installed software. So `provision.sh` contains some `if..else` structures to skip reinstalling software. 1. To suspend the VM, run `vagrant halt`. You can run `vagrant up` later to resume it. -1. To completely destroy the VM and re-provision it, run `vagrant reload`. +1. To completely destroy the VM and re-provision it, run `vagrant destroy` and `vagrant up`. + +We have provided an install shell script for you to get an easy initialization. You can run it with: +```bash +./install.sh [inchina] +``` +It will guide you to setup the vagrant environment. Especially, for developers in China, you may add the `inchina` param to download the ubuntu box for vagrant beforehand. After the initialization, you will have a virtual machine named `playground_default...` in VirtualBox which is already provisioned. You may follow the direction of the output to get things done. ### For Releaser @@ -41,5 +47,5 @@ Or, if s/he has an AWS or Google Cloud account, s/he could upload the `.ova` fil Anyway, given a running VM, the end-user can run the following command to connect to it: ```bash -sqlflow -server=my-vm.aws.com:3306 +sqlflow --sqlflow_server=my-vm.aws.com:50051 ``` diff --git a/install.bash b/install.bash new file mode 100755 index 0000000..9501845 --- /dev/null +++ b/install.bash @@ -0,0 +1,53 @@ +#!/bin/bash + +# Copyright 2020 The SQLFlow Authors. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +if [[ "$1" == "inchina" ]]; then + export WE_ARE_IN_CHINA=true +fi + +echo +echo "Welcome to SQLFlow playground!" +echo + +if ! which vagrant >/dev/null; then + echo "Install vagrant first, please refer to https://www.vagrantup.com/downloads.html" + echo + echo "If you are using macOS, the operation system may prevent you from installing the web-downloaded package, you can try use brew to install vagrant. like:" + echo "brew cask install vagrant" + echo + echo "Fix this and re-run this script again please!" + exit 0 +fi + +if [[ -n "$(vagrant global-status --prune | grep -o 'playground')" ]]; then + echo "It seems you have already installed our playground, exiting..." + exit 0 +fi + +if [[ "$WE_ARE_IN_CHINA" ]]; then + if [[ -z "$(vagrant box list | grep -o ubuntu/bionic64)" ]]; then + echo "Download ubuntu box beforehand..." + mkdir -p downloads + # try with https://mirrors.ustc.edu.cn/ if below not work + wget -c -nv --show-progress -O downloads/ubuntu-bionic64.box "https://mirrors.ustc.edu.cn/ubuntu-cloud-images/bionic/current/bionic-server-cloudimg-amd64-vagrant.box" + vagrant box add ubuntu/bionic64 downloads/ubuntu-bionic64.box + fi +fi + +echo "Start and provision the playgound now..." +vagrant up +