Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7d52b02f
Unverified
Commit
7d52b02f
authored
Mar 02, 2020
by
Erik Wilson
Committed by
GitHub
Mar 02, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1473 from erikwilson/dev-build-update
Add ubuntu to vagrant provision
parents
65bfae55
74b5a4d5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
36 deletions
+64
-36
Vagrantfile
Vagrantfile
+8
-14
vagrant
scripts/provision/generic/alpine310/vagrant
+2
-5
vagrant
scripts/provision/generic/centos7/vagrant
+1
-3
vagrant
scripts/provision/generic/ubuntu1804/vagrant
+26
-0
vagrant
scripts/provision/vagrant
+27
-14
No files found.
Vagrantfile
View file @
7d52b02f
OS
=
(
ENV
[
'OS'
]
||
"alpine310"
)
BOX_REPO
=
(
ENV
[
'BOX_REPO'
]
||
"generic"
)
BOX
=
(
ENV
[
'BOX'
]
||
"
#{
BOX_REPO
}
/
#{
OS
}
"
)
HOME
=
File
.
dirname
(
__FILE__
)
PROJECT
=
File
.
basename
(
HOME
)
NUM_NODES
=
(
ENV
[
'NUM_NODES'
]
||
0
).
to_i
...
...
@@ -16,7 +15,11 @@ MOUNT_TYPE = ENV['MOUNT_TYPE'] || "nfs"
# %admin ALL = (root) NOPASSWD: /sbin/nfsd restart
# --- May need to add terminal to System Preferences -> Security & Privacy -> Privacy -> Full Disk Access
def
provision
(
vm
)
def
provision
(
vm
,
node_num
)
node_os
=
(
ENV
[
"OS_
#{
node_num
}
"
]
||
OS
)
vm
.
box
=
(
ENV
[
"BOX_
#{
node_num
}
"
]
||
ENV
[
"BOX"
]
||
"
#{
BOX_REPO
}
/
#{
node_os
}
"
)
vm
.
hostname
=
"
#{
PROJECT
}
-
#{
node_num
}
-
#{
node_os
}
"
vm
.
network
"private_network"
,
ip:
"
#{
NETWORK_PREFIX
}
.
#{
100
+
node_num
}
"
vm
.
provision
"shell"
,
path:
VAGRANT_PROVISION
,
env:
{
'HOME'
=>
HOME
,
'GOPATH'
=>
ENV
[
'GOPATH'
],
'BOX'
=>
vm
.
box
}
...
...
@@ -29,26 +32,17 @@ Vagrant.configure("2") do |config|
v
.
memory
=
NODE_MEMORY
v
.
customize
[
"modifyvm"
,
:id
,
"--audio"
,
"none"
]
end
config
.
vm
.
box
=
BOX
config
.
vm
.
hostname
=
PROJECT
config
.
vm
.
synced_folder
"."
,
HOME
,
type:
MOUNT_TYPE
if
Vagrant
.
has_plugin?
(
"vagrant-timezone"
)
config
.
timezone
.
value
=
:host
end
config
.
vm
.
synced_folder
"."
,
HOME
,
type:
MOUNT_TYPE
if
NUM_NODES
==
0
config
.
vm
.
network
"private_network"
,
ip:
"
#{
NETWORK_PREFIX
}
.100"
provision
(
config
.
vm
)
provision
(
config
.
vm
,
0
)
else
(
1
..
NUM_NODES
).
each
do
|
i
|
config
.
vm
.
define
".
#{
i
}
"
do
|
node
|
node_os
=
(
ENV
[
"OS_
#{
i
}
"
]
||
OS
)
node
.
vm
.
box
=
(
ENV
[
"BOX_
#{
i
}
"
]
||
"
#{
BOX_REPO
}
/
#{
node_os
}
"
)
node
.
vm
.
network
"private_network"
,
ip:
"
#{
NETWORK_PREFIX
}
.
#{
100
+
i
}
"
node
.
vm
.
hostname
=
"
#{
PROJECT
}
-
#{
i
}
"
provision
(
node
.
vm
)
provision
(
node
.
vm
,
i
)
end
end
end
...
...
scripts/provision/generic/alpine310/vagrant
View file @
7d52b02f
...
...
@@ -2,8 +2,8 @@
set
-ve
apk add
-q
-f
curl libc6-compat tzdata
echo
"Installing go
$goversion
"
curl
-sL
https://storage.googleapis.com/golang/go
${
goversion
}
.linux-
${
ARCH
}
.tar.gz |
tar
-xzf
-
-C
/usr/local
download_go
download_dqlite
# ---
cat
<<
EOF
>/etc/profile.d/build.sh
export SELINUX=true
...
...
@@ -12,9 +12,6 @@ export STATIC_BUILD=true
EOF
.
/etc/profile.d/build.sh
# ---
echo
"Downloading DQLITE from
$DQLITE_URL
"
curl
-sfL
$DQLITE_URL
-o
/usr/src/dqlite.tgz
# ---
.
/tmp/docker-run
# ---
go get
-u
github.com/go-delve/delve/cmd/dlv
...
...
scripts/provision/generic/centos7/vagrant
View file @
7d52b02f
#!/bin/bash
set
-ve
echo
"Installing go
$goversion
"
curl
-sL
https://storage.googleapis.com/golang/go
${
goversion
}
.linux-
${
ARCH
}
.tar.gz |
tar
-xzf
-
-C
/usr/local
download_go
# ---
cat
<<
EOF
>/etc/profile.d/build.sh
export SELINUX=true
...
...
scripts/provision/generic/ubuntu1804/vagrant
0 → 100755
View file @
7d52b02f
#!/bin/bash
set
-ve
download_go
# ---
cat
<<
EOF
>/etc/profile.d/build.sh
export SELINUX=true
# export DQLITE=true
# export STATIC_BUILD=true
EOF
.
/etc/profile.d/build.sh
# ---
apt-get
install
-y
\
build-essential
\
pkg-config
\
libseccomp-dev
\
libsqlite3-dev
\
libselinux1-dev
\
zlib1g-dev
\
# ---
sed
-E
's|apk( -U)?( --no-cache)?( --repository [^ ]*)? add|apt-get install -y|g'
-i
/tmp/docker-run
.
/tmp/docker-run
# ---
go get
-u
github.com/go-delve/delve/cmd/dlv
# ---
scripts/provision/vagrant
View file @
7d52b02f
#!/bin/bash
set
-ve
ARCH
=
amd64
PROVISION
=
"scripts/provision/
$BOX
/vagrant"
OS
=
$(
basename
$BOX
)
if
[
!
-f
/etc/vagrant_box_build_time
]
;
then
echo
"This script should only be called during vagrant provisioning"
...
...
@@ -28,15 +26,10 @@ if [ -z "${GOPATH}" ]; then
else
echo
"Using parent GOPATH=
$GOPATH
"
fi
goversion
=
$(
grep
"^FROM "
Dockerfile.dapper |
sed
-e
's/^FROM golang:\(.*\)-.*/\1/'
)
if
[
-z
"
$goversion
"
]
;
then
echo
"Cannot find version of go to fetch"
exit
1
fi
# --- Setup basic env
cat
<<
EOF
>/etc/profile.d/env.sh
export ARCH=amd64
export GO111MODULE=off
export GOPATH="
$GOPATH
"
export PATH=/usr/local/bin:
$PATH
:/usr/local/go/bin:
$GOPATH
/bin
...
...
@@ -44,10 +37,6 @@ export HOME="$HOME" && cd
EOF
.
/etc/profile.d/env.sh
# --- Setup for dqlite download
DQLITE_URL
=
"https://github.com/
$(
grep
dqlite-build Dockerfile.dapper |
sed
-e
's/^.*--from=\([^ ]*\).*$/\1/'
-e
's|:|/releases/download/|'
)
/dqlite-
$ARCH
.tgz"
mkdir
-p
/usr/src/
# --- Clean go cache
rm
-rf
.cache/go-build
||
true
...
...
@@ -55,13 +44,13 @@ rm -rf .cache/go-build || true
sed
-i
's|:/bin/ash$|:/bin/bash|g'
/etc/passwd
cat
<<
EOF
>/etc/profile.d/color.sh
alias ls='ls --color=auto'
export PS1='\033[31m[ \033[90m\D{%F %T}\033[31m ]
\033[35m{\033[90m
$OS
\033[35m}
\n\[\033[36m\]\u\[\033[m\]🐮\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\
$
'
export PS1='\033[31m[ \033[90m\D{%F %T}\033[31m ]\n\[\033[36m\]\u\[\033[m\]🐮\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\
$
'
EOF
# --- Setup install script from docker run commands
mkdir
-p
${
GOPATH
}
/bin
mkdir
-p
/go
ln
-s
$GOPATH
/bin /go/bin
ln
-s
f
$GOPATH
/bin /go/bin
sed
':a;N;$!ba;s/\\\n/ /g'
<Dockerfile.dapper |
grep
'^RUN '
|
sed
-e
's/^RUN //'
>
/tmp/docker-run
export
BINDIR
=
/go/bin
export
GOPATH
=
/go
...
...
@@ -79,6 +68,30 @@ cat <<\EOF >/etc/motd
EOF
# --- Utility function to download go
download_go
()
{
goversion
=
$(
grep
"^FROM "
Dockerfile.dapper |
sed
-e
's/^FROM golang:\(.*\)-.*/\1/'
)
if
[
-z
"
$goversion
"
]
;
then
echo
"Cannot find version of go to fetch"
return
1
fi
echo
"Installing go
$goversion
"
curl
-sL
https://storage.googleapis.com/golang/go
${
goversion
}
.linux-
${
ARCH
}
.tar.gz |
tar
-xzf
-
-C
/usr/local
}
# --- Utility function to download dqlite
download_dqlite
()
{
dqliteURL
=
"https://github.com/
$(
grep
dqlite-build Dockerfile.dapper |
sed
-e
's/^.*--from=\([^ ]*\).*$/\1/'
-e
's|:|/releases/download/|'
)
/dqlite-
$ARCH
.tgz"
if
[
-z
"
$dqliteURL
"
]
;
then
echo
"Cannot find dqlite URL to fetch"
return
1
fi
mkdir
-p
/usr/src/
echo
"Downloading DQLITE from
$dqliteURL
"
curl
-sfL
$dqliteURL
-o
/usr/src/dqlite.tgz
}
# --- Run vagrant provision script if available
if
[
!
-f
"
${
PROVISION
}
"
]
;
then
echo
'WARNING: Unable to execute provision script "${PROVISION}"'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment