Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
```
53 changes: 53 additions & 0 deletions install.bash
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we know that we are in China? And, users in other regions around the world might also need to use their local mirrors. How about we don't care if users are specifically in China, but support mirrors by downloading with axel other than wget?

Copy link
Collaborator Author

@lhw362950217 lhw362950217 May 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did tried to use axel --search, it turned out that the axel relied filesearching.com can't be accessed in China.
I also want to give multiple urls to axels, but, it seems we can't enumerate the box's mirrors, really, vagrant do not have so many well-known official mirrors like other software.

Plus the fact we have to consider how to install axel itself in kinds of OS, I decided to make it work first, just use the wget.

Especially for China, I add a param inchina. Actually, if this param is not present, the script just run vagrant up and delegate the work to standard vagrant provision process.

./install.bash inchina

Other thought:
I want to make the install more intelligent, so I tried to figure out if we are in China automatically. I found this tool. I will try it in a more standard environment (in the vm, we don't have to consider the os) but not in this install script. It will in my next PR.

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script might run on macOS, Windows, and Linux, right? It needs the way to install axel.

  • macOS:
    1. install Homebrew
    2. install axel, VirtualBox, and Vagrant using Homebrew
  • Windows:
    1. install Chocolatey
    2. install axel, VirtualBox, and Vagrant using Chocolatey
  • Debian-like Linux:
    1. update apt-get
    2. install axel, VirtualBox, and Vagrant using apt-get

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like described above, now, I'm focused on macOS and Linux, especially for Chinese developers. Currently, make the provision progress fast takes a higher priority. Maybe I can fix this up in future PRs.

vagrant box add ubuntu/bionic64 downloads/ubuntu-bionic64.box
fi
fi

echo "Start and provision the playgound now..."
vagrant up