Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
837fe1a
Added support for newer app versions
rudolfb Apr 2, 2016
24abdc1
Clean up
rudolfb Apr 2, 2016
d3556f9
View the version numbers of the installed software
rudolfb Apr 2, 2016
d710d2a
Ports of the host back to default
rudolfb Apr 2, 2016
742863b
Cosmetic
rudolfb Apr 11, 2016
a7091c5
Remove the ubuntu installation log from git
rudolfb Apr 11, 2016
1e28150
No erlang dist version available specifically for xenial
rudolfb Apr 11, 2016
eb6a476
Updated the scripts to support Ubuntu 16.04
rudolfb Apr 11, 2016
b6ef24d
Phoenix was not being installed correctly
rudolfb Apr 11, 2016
9a8304b
Removed duplicate Phoenix install
rudolfb Apr 11, 2016
110d927
Added test for Phoenix install
rudolfb Apr 11, 2016
503c3cb
Getting the folder sharing is a hassle for testing
rudolfb Apr 11, 2016
5060bd1
Can't test Phoenix in priveleged mode
rudolfb Apr 11, 2016
7948a87
Better code to test if mix installed and which version
rudolfb Apr 11, 2016
c3896bd
Clean up the display of the version display
rudolfb Apr 11, 2016
c18907e
Moved installation of hex and rebar into the Elixir script
rudolfb Apr 12, 2016
32016b3
Added template files for additional installation steps
rudolfb Apr 12, 2016
3d9f0b0
Corrected file names in echo scripts
rudolfb Apr 12, 2016
0242fca
mix needs to be executed in the context of the user
rudolfb Apr 12, 2016
4d2c3ef
Improved the test for phoenix installation
rudolfb Apr 12, 2016
857f506
Added a vbox name and linked_clone
rudolfb Apr 12, 2016
22ab3a5
hosts was not being updated due to permissions issue
rudolfb Apr 12, 2016
15f40f8
Xenial repo for postgres now available
rudolfb Apr 14, 2016
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vagrant
ubuntu*.log
68 changes: 62 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,68 @@

Based off project: https://github.com/jackdb/pg-app-dev-vm

* Ubuntu 14.04 LTS
* Elixir 1.0.5
* Phoenix 1.0.0
* PosgreSQL 9.4.4
* NodeJS 0.12.7
* Git 1.9.1
* Ubuntu 15.10
* Elixir 1.2.4 (latest version)
* Phoenix 1.1.4 (latest version)
* PosgreSQL 9.5 (latest version 9.5.x)
* NodeJS 5.x (latest version 5.x)
* Git 2.8.0 (latest version)

This box is published in Atlas as 'lazygray/phoenix-postgres' and can be used simply by
adding `config.vm.box = 'lazygray/phoenix-postgres'` to your `Vagrantfile`.

## For Vagrant users on Windows
On Windows platforms with Vagrant version 1.8.0 and 1.8.1 there are issues
getting rsync to work.

Perhaps a newer version of Vagrant might resolve this issue on Windows.
- https://github.com/mitchellh/vagrant/issues/6702
- https://github.com/mitchellh/vagrant/issues/3230

If on Windows, and you are not able to get rsync to work, the following code
in the `Vagrantfile` can be commented out
```
config.vm.synced_folder(
'.',
'/vagrant',
type: 'rsync',
rsync__exclude: [
'.git/',
'.vagrant/',
'log/*',
'tmp/'
]
)
```

and replaced with the code below.

Use the following on Windows to 'resolve' the rsync issue above.
```
config.vm.synced_folder "..", "/vagrant_data"
```

Your file structure on windows will then be as follows:

```
project
|
└─── vagrant-phoenix-postgres-master
│ .gitignore
│ README.mde
│ Vagrantfile
|
├─── .vagrant
| | ...
├─── config
|
├─── vagrant
| build_dependency_setup.sh
| elixir_setup.sh
| git_setup.sh
| phoenix_setup.sh
| postgresql_setup.sh
```

The fixes in the issues above seem to relate the use of rsync in relation to
CygWin. I tried using cwRsync (https://www.itefix.net/cwrsync) on Windows, but was not able to get that rsync to work.
49 changes: 36 additions & 13 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,57 @@ SCRIPT
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = '2'

MEMORY_SIZE_MB = 1024
NUMBER_OF_CPUS = 2
VM_NAME = "vagrant-phoenix-postgres"
VM_LINKED = true

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

config.vm.provider "virtualbox" do |v|
v.memory = MEMORY_SIZE_MB
v.cpus = NUMBER_OF_CPUS
v.name = VM_NAME
v.linked_clone = VM_LINKED
end

config.vm.provision 'shell', inline: $script

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = 'ubuntu/trusty64'

config.vm.synced_folder(
'.',
'/vagrant',
type: 'rsync',
rsync__exclude: [
'.git/',
'.vagrant/',
'log/*',
'tmp/'
]
)
config.vm.box = 'ubuntu/xenial64'

config.vm.provision :shell, path: 'config/vagrant/build_dependency_setup.sh'
config.vm.provision :shell, path: 'config/vagrant/git_setup.sh'
config.vm.provision :shell, path: 'config/vagrant/nodejs_setup.sh'
config.vm.provision :shell, path: 'config/vagrant/postgresql_setup.sh'
config.vm.provision :shell, path: 'config/vagrant/elixir_setup.sh'
config.vm.provision :shell, path: 'config/vagrant/phoenix_setup.sh', privileged: false
config.vm.provision :shell, path: 'config/vagrant/post_install_priveleged.sh'
config.vm.provision :shell, path: 'config/vagrant/post_install_user.sh', privileged: false
config.vm.provision :shell, path: 'config/vagrant/check_versions.sh', privileged: false

# On Windows there are problems using rsync, which is why I commented out this
# original code. Here the github references for Vagrant 1.8.1 .
# Perhaps a newer version of Vagrant might resolve this issue on Windows.
# https://github.com/mitchellh/vagrant/issues/6702
# https://github.com/mitchellh/vagrant/issues/3230
# config.vm.synced_folder(
# '.',
# '/vagrant',
# type: 'rsync',
# rsync__exclude: [
# '.git/',
# '.vagrant/',
# 'log/*',
# 'tmp/'
# ]
# )

# Use the following on Windows to 'resolve' the rsync issue above.
# config.vm.synced_folder ".", "/vagrant"

# PostgreSQL Server port forwarding
config.vm.network :forwarded_port, host: 4000, guest: 4000
Expand Down
28 changes: 26 additions & 2 deletions config/vagrant/build_dependency_setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
#!/usr/bin/env bash

echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
echo "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
echo "======================================================================"
echo "=== Begin Vagrant Provisioning using 'config/vagrant/build_dependency_setup.sh'"

# https://bugs.launchpad.net/ubuntu/+bug/1561250
if [ $(cat /etc/hosts | grep -co 'ubuntu-xenial') = 0 ]; then
echo "sudo sh -c ""echo '127.0.1.1 ubuntu-xenial' >> /etc/hosts"""
sudo sh -c "echo '127.0.1.1 ubuntu-xenial' >> /etc/hosts"
else
echo "Found entry 'ubuntu-xenial' in the /etc/hosts"
fi

# Install build dependencies for a sane build environment
apt-get -y update
apt-get -y install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
sudo apt-get -y update
sudo apt-get -y install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev libgtk2.0-0 libgtk2.0-bin libgtk2.0-common

# Problem installing esl-erlang.
# Standard installation methods for libwxbase fail.
# http://packages.ubuntu.com/search?suite=default&section=all&arch=any&keywords=libwxbase&searchon=names
# Even after the explicit installation of libwxbase3.0-0v5 the dependencies are not resolved, so
# this forces us to manually install libwxbase3 and libwxgtk3.
wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wxwidgets3.0/libwxbase3.0-0_3.0.2-1_amd64.deb
yes Y | sudo dpkg -i libwxbase3.0-0_3.0.2-1*.deb
yes Y | sudo apt-get -f install

wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wxwidgets3.0/libwxgtk3.0-0_3.0.2-1_amd64.deb
yes Y | sudo dpkg -i libwxgtk3.0-0_3.0.2-1*.deb
yes Y | sudo apt-get -f install

echo "=== End Vagrant Provisioning using 'config/vagrant/build_dependency_setup.sh'"
52 changes: 52 additions & 0 deletions config/vagrant/check_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
echo "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
echo "======================================================================"
echo "=== Begin Vagrant Provisioning using 'config/vagrant/check_version.sh'"

echo " "
echo " "
echo "--- git"
echo "--------------------"
echo "git --version"
git --version
echo " "
echo " "
echo "--- node"
echo "--------------------"
echo "node --version"
node --version
echo " "
echo " "
echo "--- postgres"
echo "--------------------"
echo "psql --version"
psql --version
echo " "
echo " "
echo "--- erlang"
echo "--------------------"
echo "cat /usr/lib/erlang/releases/RELEASES"
cat /usr/lib/erlang/releases/RELEASES
echo " "
echo " "
echo "--- elixir"
echo "--------------------"
echo "elixir --version"
elixir --version
echo " "
echo " "
echo "--- phoenix"
echo "--------------------"
echo "mix help phoenix.new"
if [ $(strings ~/.mix/archives/phoenix_new.ez | grep -co '{vsn,') = 0 ]; then
echo "Error: unable to find installed phoenix"
else
mix help phoenix.new | sed -e 3b -e '$!d'
strings ~/.mix/archives/phoenix_new.ez | grep '{vsn,'
fi
echo " "
echo " "

echo "=== End Vagrant Provisioning using 'config/vagrant/check_version.sh'"
26 changes: 18 additions & 8 deletions config/vagrant/elixir_setup.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
#!/usr/bin/env bash

echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
echo "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
echo "======================================================================"
echo "=== Begin Vagrant Provisioning using 'config/vagrant/elixir_setup.sh'"

PHOENIX_VERSION=0.17.0

# Install Git if not available
# Install elixir if not available
# Note: the URL of erlang will
if [ -z `which elixir` ]; then
echo "===== Installing Elixir"
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
apt-get -y update
apt-get -y install elixir
yes Y | mix local.hex
yes Y | mix archive.install "https://github.com/phoenixframework/phoenix/releases/download/v0.17.0/phoenix_new-$PHOENIX_VERSION.ez"
# https://www.erlang-solutions.com/resources/download.html
# We have to use the more complex alternative erlang install as the
# standard install does not detect the Ubuntu codename correctly.
# Even if you have Ubuntu wily installed, the codename squeezy is
# prompted, and used for the insall, and the installation of erlang fails.
wget http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
# There is as of now no erlang download for xenial, so we have to hard code wily.
sudo add-apt-repository "deb http://packages.erlang-solutions.com/ubuntu wily contrib"
# sudo add-apt-repository "deb http://packages.erlang-solutions.com/ubuntu $(lsb_release -s -c) contrib"
sudo apt-get update
yes Y | sudo apt-get install esl-erlang
sudo apt-get install elixir
fi

echo "=== End Vagrant Provisioning using 'config/vagrant/elixir_setup.sh'"
7 changes: 5 additions & 2 deletions config/vagrant/git_setup.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/usr/bin/env bash

echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
echo "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
echo "======================================================================"
echo "=== Begin Vagrant Provisioning using 'config/vagrant/git_setup.sh'"

# Install Git if not available
if [ -z `which git` ]; then
echo "===== Installing Git"
apt-get -y update
apt-get -y install git-core
sudo apt-get -y update
sudo apt-get -y install git-core
fi

echo "=== End Vagrant Provisioning using 'config/vagrant/git_setup.sh'"
5 changes: 4 additions & 1 deletion config/vagrant/nodejs_setup.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/usr/bin/env bash

echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
echo "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
echo "======================================================================"
echo "=== Begin Vagrant Provisioning using 'config/vagrant/nodejs_setup.sh'"

if [ -z `which nodejs` ]; then
# Instructions from:
# https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
fi

Expand Down
14 changes: 7 additions & 7 deletions config/vagrant/phoenix_setup.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env bash

echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
echo "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
echo "======================================================================"
echo "=== Begin Vagrant Provisioning using 'config/vagrant/phoenix_setup.sh'"

PHOENIX_VERSION=1.0.0

# Install Git if not available
# if [ -z `which elixir` ]; then
# Install the latest version of Phoenix
echo "===== Installing Phoenix"
yes Y | mix local.hex
yes Y | mix archive.install "https://github.com/phoenixframework/phoenix/releases/download/v$PHOENIX_VERSION/phoenix_new-$PHOENIX_VERSION.ez"
# fi
mix local.hex --force
mix local.rebar --force
mix archive.install "https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez" --force

echo "=== End Vagrant Provisioning using 'config/vagrant/phoenix_setup.sh'"
13 changes: 13 additions & 0 deletions config/vagrant/post_install_priveleged.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
echo "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
echo "======================================================================"
echo "=== Begin Vagrant Provisioning using 'config/vagrant/post_install_priveleged.sh'"

# Here I can place post install commands to install stuff which I need for
# my project. This file is specifically for code that must be
# executed as the super-user.

sudo npm install -g elm

echo "=== End Vagrant Provisioning using 'config/vagrant/post_install_priveleged.sh'"
11 changes: 11 additions & 0 deletions config/vagrant/post_install_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
echo "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
echo "======================================================================"
echo "=== Begin Vagrant Provisioning using 'config/vagrant/post_install_user.sh'"

# Here I can place post install commands to install stuff which I need for
# my project.


echo "=== End Vagrant Provisioning using 'config/vagrant/post_install_user.sh'"
17 changes: 10 additions & 7 deletions config/vagrant/postgresql_setup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/sh -e

echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
echo "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
echo "======================================================================"
echo "=== Begin Vagrant Provisioning using 'config/vagrant/postgresql_setup.sh'"

# Edit the following to change the name of the database user that will be created:
Expand All @@ -10,7 +13,7 @@ APP_DB_PASS=$APP_DB_USER
# APP_DB_NAME=${APP_DB_USER}_unused

# Edit the following to change the version of PostgreSQL that is installed
PG_VERSION=9.4
PG_VERSION=9.5

###########################################################
# Changes below this line are probably not necessary
Expand Down Expand Up @@ -55,18 +58,18 @@ PG_REPO_APT_SOURCE=/etc/apt/sources.list.d/pgdg.list
if [ ! -f "$PG_REPO_APT_SOURCE" ]
then
# Add PG apt repo:
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > "$PG_REPO_APT_SOURCE"
echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" > "$PG_REPO_APT_SOURCE"

# Add PGDG repo key:
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
fi

# Update package list and upgrade all packages
apt-get update
apt-get -y upgrade
sudo apt-get update
sudo apt-get -y upgrade

apt-get -y install "postgresql-$PG_VERSION" "postgresql-contrib-$PG_VERSION"
apt-get -y install libpq-dev # For building ruby 'pg' gem
sudo apt-get -y install "postgresql-$PG_VERSION" "postgresql-contrib-$PG_VERSION"
sudo apt-get -y install libpq-dev # For building ruby 'pg' gem

PG_CONF="/etc/postgresql/$PG_VERSION/main/postgresql.conf"
PG_HBA="/etc/postgresql/$PG_VERSION/main/pg_hba.conf"
Expand Down