This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
add vagrantfile and build script to create a VM using docker #185
Draft
paskino
wants to merge
6
commits into
master
Choose a base branch
from
docker_VM
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
136a658
add vagrantfile and build script to create a VM using docker
paskino c2ed7c3
allow pass superbuild tag
paskino 3fb6046
add pass of SB_TAG
paskino ed950c9
added readme
paskino ad2c941
fix syntax
paskino b09c705
add comment
paskino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#======================================================================== | ||
# Author: Edoardo Pasca, Ben Thomas | ||
# Copyright 2018 University College London | ||
# Copyright 2018-2019 Science Technology Facilities Council | ||
# | ||
# This file is part of the CCP PETMR Synergistic Image Reconstruction Framework (SIRF) virtual machine. | ||
# | ||
# 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.txt | ||
# | ||
# 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. | ||
# | ||
#========================================================================= | ||
|
||
Vagrant.configure("2") do |config| | ||
config.vm.box = "bento/ubuntu-18.04" | ||
config.vm.synced_folder '.', '/vagrant', disabled: true | ||
config.vm.define "docker" | ||
|
||
# Disable automatic box update checking. If you disable this, then | ||
# boxes will only be checked for updates when the user runs | ||
# `vagrant box outdated`. This is not recommended. | ||
# config.vm.box_check_update = false | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine. In the example below, | ||
# accessing "localhost:8080" will access port 80 on the guest machine. | ||
|
||
# Forward port for jupyter notebooks | ||
config.vm.network "forwarded_port", guest: 8888, host: 8889 | ||
config.vm.network "forwarded_port", guest: 9001, host: 9003, protocol: "tcp" | ||
config.vm.network "forwarded_port", guest: 9002, host: 9004, protocol: "tcp" | ||
|
||
# Create a private network, which allows host-only access to the machine | ||
# using a specific IP. | ||
# config.vm.network "private_network", ip: "192.168.33.10" | ||
|
||
# Create a public network, which generally matched to bridged network. | ||
# Bridged networks make the machine appear as another physical device on | ||
# your network. | ||
# config.vm.network "public_network" | ||
|
||
# Share an additional folder to the guest VM. The first argument is | ||
# the path on the host to the actual folder. The second argument is | ||
# the path on the guest to mount the folder. And the optional third | ||
# argument is a set of non-required options. | ||
# config.vm.synced_folder "../data", "/vagrant_data" | ||
|
||
# Provider-specific configuration so you can fine-tune various | ||
# backing providers for Vagrant. These expose provider-specific options. | ||
# Next lines are for VirtualBox: | ||
# | ||
|
||
config.vm.provider "virtualbox" do |vb| | ||
# Display the VirtualBox GUI when booting the machine | ||
vb.gui = true | ||
|
||
# Customize the amount of memory on the VM: | ||
vb.cpus = "2" | ||
vb.memory = "4096" | ||
|
||
vb.customize "pre-boot", [ | ||
"storageattach", :id, | ||
"--storagectl", "IDE Controller", | ||
"--port", "1", | ||
"--device", "0", | ||
"--type", "dvddrive", | ||
"--medium", "emptydrive" | ||
] | ||
|
||
vb.name = "SIRF 3.0.0 Docker" | ||
vb.customize ["modifyvm", :id, | ||
"--clipboard", "bidirectional", | ||
"--vram", "32"] | ||
|
||
end | ||
|
||
# | ||
# View the documentation for the provider you are using for more | ||
# information on available options. | ||
|
||
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies | ||
# such as FTP and Heroku are also available. See the documentation at | ||
# https://docs.vagrantup.com/v2/push/atlas.html for more information. | ||
# config.push.define "atlas" do |push| | ||
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" | ||
# end | ||
|
||
# Enable provisioning with a shell script. Additional provisioners such as | ||
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the | ||
# documentation for more information about their specific syntax and use. | ||
|
||
config.vm.provision "shell", path: "../scripts/bootstrap_ubuntu_docker.sh" | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
SIRFUSERNAME=sirfuser | ||
SIRFPASS=virtual | ||
|
||
# check if user exists. if not create it. Useful for vagrant provision | ||
id -u $SIRFUSERNAME | ||
if [ $? -eq "1" ] ; then | ||
adduser $SIRFUSERNAME | ||
adduser $SIRFUSERNAME sudo | ||
{ echo $SIRFPASS; echo $SIRFPASS; } | passwd $SIRFUSERNAME | ||
fi | ||
|
||
# fail hard on any step | ||
set -ex | ||
# update the apt-get database | ||
export DEBIAN_FRONTEND=noninteractive | ||
apt-get update && apt-get upgrade -y -o Dpkg::Options::=--force-confnew | ||
# upgrade the list of packages | ||
|
||
|
||
#install upgrades | ||
apt-get update && apt-get install -y --no-install-recommends wget git xorg xterm gdm3 menu policykit-1-gnome synaptic gnome-session gnome-panel metacity | ||
apt-get update && apt-get install -y at-spi2-core gnome-terminal gnome-control-center nautilus dmz-cursor-theme network-manager network-manager-gnome | ||
apt=get install -y --no-install-recommends docker-compose docker | ||
|
||
# start gnome display manager | ||
service gdm start | ||
|
||
# set the current locale, otherwise the gnome-terminal doesn't start | ||
sudo locale-gen en_GB.UTF-8 | ||
sudo locale-gen en_US.UTF-8 | ||
sudo locale-gen de_DE.UTF-8 | ||
sudo locale-gen fr_FR.UTF-8 | ||
sudo locale-gen es_ES.UTF-8 | ||
sudo locale-gen it_IT.UTF-8 | ||
sudo locale-gen pt_PT.UTF-8 | ||
sudo locale-gen pt_BR.UTF-8 | ||
sudo locale-gen ja_JP.UTF-8 | ||
sudo locale-gen zh_CN.UTF-8 | ||
sudo update-locale LANG=en_GB.UTF-8 | ||
sudo localectl set-x11-keymap uk | ||
sudo localectl status | ||
|
||
|
||
# To hide vagrant from login screen: | ||
# 1. Log-in as vagrant | ||
# 2. In /var/lib/AccountsService/users/vagrant change 'SystemAccount=true' | ||
sudo echo '[User]' > vagrant | ||
sudo echo 'SystemAccount=true' >> vagrant | ||
sudo cp -v vagrant /var/lib/AccountsService/users/vagrant | ||
|
||
# To remove the Ubuntu user from VM: | ||
#sudo deluser --remove-home ubuntu | ||
# Could add custom logos here: /etc/gdm3/greeter.dconf-defaults | ||
|
||
userHOME=/home/$SIRFUSERNAME | ||
|
||
if [ ! -d $userHOME/devel ]; then | ||
mkdir $userHOME/devel | ||
fi | ||
cd $userHOME/devel | ||
|
||
if [ ! -d $userHOME/devel/SyneRBI_VM ]; then | ||
git clone https://github.com/SyneRBI/SyneRBI_VM.git | ||
cd SyneRBI_VM | ||
else | ||
cd SyneRBI_VM | ||
git pull | ||
fi | ||
|
||
if [ ! -d $userHOME/devel/SIRF-SuperBuild ]; then | ||
git clone https://github.com/SyneRBI/SIRF-SuperBuild.git | ||
cd SIRF-SuperBuild | ||
else | ||
cd SIRF-SuperBuild | ||
git pull | ||
fi | ||
|
||
|
||
|
||
#bash $userHOME/devel/SyneRBI_VM/scripts/INSTALL_prerequisites_with_apt-get.sh | ||
#bash $userHOME/devel/SyneRBI_VM/scripts/INSTALL_CMake.sh /usr/local | ||
#bash $userHOME/devel/SyneRBI_VM/scripts/INSTALL_python_packages.sh | ||
|
||
# port 8888 is forwarded to 8888 so the user can use the host browser | ||
# Therefore no browser is installed on the VM | ||
|
||
chown -R $SIRFUSERNAME:users $userHOME | ||
# sudo -u $SIRFUSERNAME -H bash $userHOME/devel/SyneRBI_VM/scripts/UPDATE.sh -t origin/master | ||
|
||
|
||
# add sirfuser to the group docker | ||
sudo groupadd docker | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. possibly this is not needed because the group is added when installing docker |
||
sudo usermod -aG docker ${SIRFUSERNAME} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guest
should be 9999 as jupyter on the docker instance responds to port 8888, which is forwarded to 9999.Host: 8889 -> VirtualBox 9999 -> docker 8888