Skip to content

Commit 67f1699

Browse files
authored
Merge pull request #25 from wangkuiyi/use_vbox_cache
Use vbox cache
2 parents 6eeaef6 + 2fc8128 commit 67f1699

File tree

4 files changed

+71
-62
lines changed

4 files changed

+71
-62
lines changed

Vagrantfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Vagrant.configure("2") do |config|
66
config.vm.provision "shell", path: "provision.bash"
77

88
# Enlarge disk size from default '10G' to '20G'
9-
# This need the vagrant-disksize plugin which is installed in install.bash
9+
# This need the vagrant-disksize plugin which is installed in play.sh.
1010
config.disksize.size = '20GB'
1111

1212
# Don't forward 22. Even if we do so, the exposed port only binds

dev.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,20 @@
1111
1. To suspend the VM, run `vagrant halt`. You can run `vagrant up` later to resume it.
1212
1. To completely destroy the VM and re-provision it, run `vagrant destroy` and `vagrant up`.
1313

14-
We have provided an install shell script for you to get an easy initialization. You can run it with:
14+
We provided a shell script to start a VM running the SQLFlow service.
15+
16+
```bash
17+
./play.sh
18+
```
19+
20+
If you have a slow Internet connection to Vagrant Cloud, you might want to
21+
download the Ubuntu VirtualBox image manually from some mirror sites into
22+
`~/.cache/sqlflow/` before running the above script.
23+
1524
```bash
16-
./install.sh [inchina]
25+
curl -Lo $HOME/.cache/sqlflow/ubuntu-bionic64.box \
26+
"https://mirrors.ustc.edu.cn/ubuntu-cloud-images/bionic/current/bionic-server-cloudimg-amd64-vagrant.box"
1727
```
18-
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.
1928

2029
### For Releaser
2130

install.bash

Lines changed: 0 additions & 58 deletions
This file was deleted.

play.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
# Copyright 2020 The SQLFlow Authors. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -e
17+
18+
cat <<EOF
19+
___ ___ _ ___ _
20+
/ __|/ _ \| | | __| |_____ __ __
21+
\__ \ (_) | |__| _|| / _ \ V V /
22+
|___/\__\_\____|_| |_\___/\_/\_/
23+
24+
EOF
25+
26+
if ! which vagrant >/dev/null; then
27+
cat <<EOF
28+
We need Vagrant to run the playground.
29+
30+
Linux users can refer to https://www.vagrantup.com/downloads.html for the
31+
installation guide.
32+
33+
macOS users can install Vagrant using Homebrew:
34+
brew cask install vagrant
35+
EOF
36+
exit 1
37+
fi
38+
39+
if [[ -n "$(vagrant global-status --prune | grep -o 'playground')" ]]; then
40+
echo "The playground VM is running."
41+
exit 0
42+
fi
43+
44+
if [[ -z "$(vagrant plugin list | grep -o 'vagrant-disksize')" ]]; then
45+
echo "Install Vagrant disk size plugin ..."
46+
vagrant plugin install vagrant-disksize
47+
fi
48+
49+
if [[ -z "$(vagrant box list | grep 'ubuntu/bionic64')" ]]; then
50+
CACHED_BOX="$HOME/.cache/sqlflow/ubuntu-bionic64.box"
51+
if [[ -f $CACHED_BOX ]]; then
52+
echo "Found and use cached box $CACHED_BOX"
53+
vagrant box add ubuntu/bionic64 $CACHED_BOX
54+
fi
55+
fi
56+
57+
echo "Start and provision the playgound VM ..."
58+
vagrant up

0 commit comments

Comments
 (0)