forked from andk/pause
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Vagrant scripts to build a PAUSE dev box
instructions can be found in the README.md added herein. note that this will build a box and all seems good, having ssh'd into the box and started up the server it is accessible at https://192.168.56.1 also note the factoring out of the dependencies in the Makefile.PL into a cpanfile so it's easier (?) to install them when building the box - there is almost certainly a way to do this with the existing build system but i couldn't see/find it also install self signed certs for SSL offloading so we can run the pause server behind nginx and proxy to it so we have a more representative setup to that of the production environment
- Loading branch information
Showing
12 changed files
with
279 additions
and
91 deletions.
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ pm_to_blib | |
mailer.testfile | ||
privatelib | ||
cover_db | ||
.vagrant |
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
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
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,32 @@ | ||
# PAUSE | ||
|
||
### The [Perl programming] Authors Upload Server | ||
|
||
[http://pause.perl.org/](http://pause.perl.org/) | ||
|
||
To build a development box you will need VirtualBox and Vagrant. | ||
|
||
git clone this repo then build the box that also install all necessary dependencies: | ||
|
||
VAGRANT_VAGRANTFILE=box-builder/Vagrantfile vagrant up | ||
VAGRANT_VAGRANTFILE=box-builder/Vagrantfile vagrant halt | ||
vagrant up --provision | ||
|
||
This make take around 30 minutes or so. Once the above is done you can: | ||
|
||
vagrant ssh | ||
cd pause | ||
perl Makefile.PL | ||
make test | ||
|
||
And if tests pass: | ||
|
||
plackup -I ../pause-private/lib | ||
|
||
Or for the mojolicious based server: | ||
|
||
plackup -I ../pause-private/lib --path / app_2017.psgi | ||
|
||
You should then be able to access PAUSE on `https://192.168.56.1` | ||
|
||
For more information about setup, development, and deployment see `doc/README` |
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,31 @@ | ||
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox' | ||
|
||
Vagrant.configure("2") do |config| | ||
|
||
config.vm.box = "debian/stretch64" | ||
|
||
# Use PAUSE_DEVELOPER_* env vars to set vm hardware resources. | ||
vbox_custom = %w[cpus memory].map do |hw| | ||
key = "PAUSE_DEVELOPER_#{hw.upcase}" | ||
ENV[key] ? ["--#{hw}", ENV[key]] : [] | ||
end.flatten | ||
|
||
config.vm.post_up_message = $msg | ||
|
||
config.vm.provider :virtualbox do |vb| | ||
vb.name = "pause-stretch" | ||
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | ||
if not vbox_custom.empty? | ||
vb.customize [ "modifyvm", :id, *vbox_custom ] | ||
end | ||
end | ||
|
||
config.vm.network "forwarded_port", guest: 80, host: 80 # apache http | ||
config.vm.network "forwarded_port", guest: 443, host: 443 # apache https | ||
config.vm.network "forwarded_port", guest: 5000, host: 5000 # PAUSE (non-TLS) | ||
|
||
config.vm.synced_folder '.', '/vagrant', disabled: true | ||
config.vm.synced_folder ".", "/home/vagrant/pause" | ||
|
||
config.vm.provision :shell, :path => 'provision/all.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,43 @@ | ||
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox' | ||
|
||
# To build a fresh box, from the top dir of this repository: | ||
# | ||
# * vagrant destroy | ||
# * VAGRANT_VAGRANTFILE=box-builder/Vagrantfile vagrant up | ||
# * VAGRANT_VAGRANTFILE=box-builder/Vagrantfile vagrant halt | ||
# * vagrant up --provision | ||
# | ||
# To use more resources: | ||
# PAUSE_DEVELOPER_CPUS=4 PAUSE_DEVELOPER_MEMORY=16384 VAGRANT_VAGRANTFILE=box-builder/Vagrantfile vagrant up | ||
|
||
Vagrant.configure("2") do |config| | ||
config.vm.box = "debian/stretch64" | ||
config.vm.hostname = "pause-dev" | ||
|
||
$msg = <<MSG | ||
Run the following commands to finish building your box: | ||
------------------------------------------------------ | ||
VAGRANT_VAGRANTFILE=box-builder/Vagrantfile vagrant halt | ||
vagrant up --provision | ||
------------------------------------------------------ | ||
MSG | ||
|
||
config.vm.post_up_message = $msg | ||
|
||
# Use PAUSE_DEVELOPER_* env vars to set vm hardware resources. | ||
vbox_custom = %w[cpus memory].map do |hw| | ||
key = "PAUSE_DEVELOPER_#{hw.upcase}" | ||
ENV[key] ? ["--#{hw}", ENV[key]] : [] | ||
end.flatten | ||
|
||
config.vm.provider :virtualbox do |vb| | ||
vb.name = "pause-stretch" | ||
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | ||
if not vbox_custom.empty? | ||
vb.customize [ "modifyvm", :id, *vbox_custom ] | ||
end | ||
end | ||
|
||
config.vm.synced_folder '.', '/vagrant', disabled: true | ||
config.vm.provision :shell, :path => 'box-builder/provision.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,34 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -e -o pipefail | ||
|
||
echo "vagrant provision: $0" | ||
|
||
# https://serverfault.com/a/500778/119512 | ||
export LANGUAGE=en_US.UTF-8 | ||
export LANG=en_US.UTF-8 | ||
export LC_ALL=en_US.UTF-8 | ||
locale-gen en_US.UTF-8 | ||
dpkg-reconfigure --frontend=noninteractive locales | ||
|
||
apt-get update | ||
|
||
# some nice to haves for working on the box | ||
apt-get -q --assume-yes install vim | ||
apt-get -q --assume-yes install sudo | ||
apt-get -q --assume-yes install openssh-server | ||
apt-get -q --assume-yes install git | ||
apt-get -q --assume-yes install aptitude | ||
apt-get -q --assume-yes install curl | ||
|
||
# some must haves for running the app/installing CPAN deps | ||
apt-get -q --assume-yes install default-libmysqlclient-dev | ||
apt-get -q --assume-yes install libxml2-dev | ||
apt-get -q --assume-yes install libexpat-dev | ||
apt-get -q --assume-yes install libssl-dev | ||
|
||
# some must have for other required services | ||
apt-get -q --assume-yes install mysql-server | ||
apt-get -q --assume-yes install nginx | ||
apt-get -q --assume-yes install unzip |
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
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,88 @@ | ||
#!/bin/bash | ||
|
||
# Execute all the scripts in a directory. | ||
function exec_dir () { | ||
local dir="$1" | ||
[[ "${dir:0:1}" == "/" ]] || dir="/vagrant/provision/$dir" | ||
for exe in "$dir"/*; do | ||
test -x "$exe" && echo "# $exe" && "$exe" | ||
done | ||
} | ||
|
||
# Execute any before vm initialization scripts. | ||
exec_dir before | ||
|
||
# Execute any after vm clean-up scripts. | ||
exec_dir after | ||
|
||
# install CPAN dependencies, note we are using the system perl here... | ||
cd /home/vagrant/pause | ||
PERL_MM_USE_DEFAULT=1 cpan App::cpanminus | ||
cpanm --installdeps . | ||
|
||
# database setup (note this is DEV setup hence simple passwords) | ||
mysqladmin -u root password "mysql" | ||
|
||
mysqladmin -uroot -pmysql create mod | ||
mysql -uroot -pmysql mod < doc/mod.schema.txt | ||
mysql -uroot -pmysql mod -e 'insert into users (userid) values ("LEEJO")' | ||
|
||
mysqladmin -uroot -pmysql create authen_pause | ||
mysql -uroot -pmysql authen_pause < doc/authen_pause.schema.txt | ||
|
||
LEEJO_PAUSE_PASSWD=$(perl -le 'print crypt "tiger","ef"') | ||
mysql -uroot -pmysql authen_pause -e "insert into usertable (user,password) values ('LEEJO', '$LEEJO_PAUSE_PASSWD')" | ||
|
||
# in mysql5.7 root login for localhost changed from password style to | ||
# sudo login style so we have to drop and recreate the root user to | ||
# restore password style login from non-sudo | ||
mysql -u root -pmysql -e " \ | ||
DROP USER 'root'@'localhost'; \ | ||
CREATE USER 'root'@'%' IDENTIFIED BY 'mysql'; \ | ||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION; \ | ||
FLUSH PRIVILEGES; | ||
"; | ||
|
||
# access to the databases | ||
mkdir -p ../pause-private/lib | ||
|
||
cat >> ../pause-private/lib/PrivatePAUSE.pm <<"EndOfFile" | ||
use strict; | ||
package PAUSE; | ||
$ENV{EMAIL_SENDER_TRANSPORT} = 'DevNull'; | ||
our $Config; | ||
$Config->{AUTHEN_DATA_SOURCE_USER} = "root"; | ||
$Config->{AUTHEN_DATA_SOURCE_PW} = "mysql"; | ||
$Config->{MOD_DATA_SOURCE_USER} = "root"; | ||
$Config->{MOD_DATA_SOURCE_PW} = "mysql"; | ||
$Config->{MAIL_MAILER} = ["testfile"]; | ||
$Config->{RUNDATA} = "/tmp/pause_1999"; | ||
$Config->{TESTHOST_SCHEMA} = "https"; | ||
1; | ||
EndOfFile | ||
|
||
mkdir -p /tmp/pause_1999; | ||
|
||
# config for nginx | ||
mkdir -p /usr/local/nginx/conf | ||
|
||
openssl req \ | ||
-new \ | ||
-newkey rsa:4096 \ | ||
-days 365 \ | ||
-nodes \ | ||
-x509 \ | ||
-subj "/C=CH/ST=Vaud/L=Villars/O=PAUSE/CN=pause.perl.org" \ | ||
-keyout /usr/local/nginx/conf/server.key \ | ||
-out /usr/local/nginx/conf/server.crt | ||
|
||
cp /home/vagrant/pause/doc/nginx-pause-config.sample /etc/nginx/sites-enabled/nginx-pause-config | ||
nginx -s reload | ||
|
||
# Don't let vagrant think the provision failed. | ||
exit 0 |
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,4 @@ | ||
#!/bin/sh | ||
|
||
# Fix the `stdin: is not a tty` message. | ||
sed -i 's/^mesg n$/tty -s \&\& mesg n/g' /root/.profile |
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,20 @@ | ||
#!/bin/bash | ||
|
||
hostname=pause-dev | ||
|
||
# If we can't write files, give up now. | ||
if ! touch /tmp/disk-writable; then | ||
echo 'Failed to write to disk. Please try "vagrant reload"'; | ||
exit 1; | ||
fi | ||
|
||
# Set hostname in this session. | ||
hostname "$hostname" | ||
# Remember after reboot. | ||
grep -qFx "$hostname" /etc/hostname || echo "$hostname" > /etc/hostname | ||
|
||
# Ensure there is an entry for each host name. | ||
for host in $hostname localhost puppet; do | ||
grep -qE "^127.0.[01].1[[:space:]]+.*$host" /etc/hosts || \ | ||
echo "127.0.0.1 $host" >> /etc/hosts | ||
done |
Oops, something went wrong.