Skip to content

Commit

Permalink
Clean up readme and vagrant setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Benestar committed Jul 29, 2017
1 parent b08b354 commit 6188470
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
23 changes: 15 additions & 8 deletions README.md
Expand Up @@ -10,7 +10,7 @@ assign managers for each depot and group them into several organizations.


The development of the Verleihtool happens via [Vagrant](https://www.vagrantup.com/) The development of the Verleihtool happens via [Vagrant](https://www.vagrantup.com/)
and preferably with the [VirtualBox](https://www.virtualbox.org/) provider. and preferably with the [VirtualBox](https://www.virtualbox.org/) provider.
After installing these components, doing `vagrant up` from the project's After installing these components, invoking `vagrant up` from the project's
directory will create the virtual machine and run the provisioner on it. directory will create the virtual machine and run the provisioner on it.
When the process is finished, one can login to the machine using `vagrant ssh`. When the process is finished, one can login to the machine using `vagrant ssh`.
In case the provision script gets updated afterwards, the command In case the provision script gets updated afterwards, the command
Expand All @@ -19,12 +19,13 @@ In case the provision script gets updated afterwards, the command
### Starting the tool ### Starting the tool


To install the dependencies, run `pip install -r requirements.txt` and To install the dependencies, run `pip install -r requirements.txt` and
`npm install` from the `/vagrant` directory in the virtual machine. Afterwards, `npm install` from the `/vagrant` directory in the virtual machine.
apply all migrations using the command `python manage.py migrate`. To generate On a Windows host, the parameter `--no-bin-links` is most likely required.
the JavaScript and CSS files, enter `npm run dev` or alternatively Afterwards, apply all migrations using the command `python manage.py migrate`.
To generate the JavaScript and CSS files, enter `npm run dev` or alternatively
`npm run watch-poll` if the script should automatically detect changes to the `npm run watch-poll` if the script should automatically detect changes to the
source files. Finally, the server can be started using the provided script in source files. Finally, the server can be started using the provided script in
the home directory of the vagrant user called `startServer.sh`. The tool can the home directory of the vagrant user called `server.sh`. The tool can
then be reached at [http://127.0.0.1:1337/](http://127.0.0.1:1337/). then be reached at [http://127.0.0.1:1337/](http://127.0.0.1:1337/).


To create a superuser, execute the command `python manage.py createsuperuser` To create a superuser, execute the command `python manage.py createsuperuser`
Expand All @@ -37,12 +38,18 @@ The Verleihtool comes with a full test suite that can be run using the command
new test database every time. To run the lint script, execute `flake8` from new test database every time. To run the lint script, execute `flake8` from
the `/vagrant` directory. the `/vagrant` directory.


Alternatively, when using vagrant a `test.sh` script is provided to automate
the steps described above.

## Deployment ## Deployment


The Verleihtool requires Python 3 to be installed on the server as well as a The Verleihtool requires Python 3.6 to be installed on the server as well as a
database software that is [supported by Django](https://docs.djangoproject.com/en/1.10/ref/databases/). database backend that is [supported by Django](https://docs.djangoproject.com/en/1.10/ref/databases/).
The web server must be configured to access static files from the `static` The web server must be configured to access static files from the `static`
directory of this project. Before each deployment, the resource files have to be directory of this project. for more information, please consult the
[Django manual for deployments](https://docs.djangoproject.com/en/1.10/howto/deployment/).

Before each deployment, the resource files have to be
generated either on the production server or on another device using the generated either on the production server or on another device using the
`npm run production` command. This will place the minified JavaScript and CSS `npm run production` command. This will place the minified JavaScript and CSS
files in the `static` directory. files in the `static` directory.
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Expand Up @@ -6,7 +6,7 @@ Vagrant.configure("2") do |config|
config.vm.provision :shell, path: "bootstrap.sh", privileged: false config.vm.provision :shell, path: "bootstrap.sh", privileged: false


# Configure port forwarding # Configure port forwarding
config.vm.network :forwarded_port, guest: 8000, host: 1337, host_ip: "127.0.0.1" config.vm.network :forwarded_port, guest: 8000, host: 1337, host_ip: "127.0.0.1", auto_correct: true


# Virtualbox configuration # Virtualbox configuration
config.vm.provider "virtualbox" do |v| config.vm.provider "virtualbox" do |v|
Expand Down
41 changes: 20 additions & 21 deletions bootstrap.sh
Expand Up @@ -3,7 +3,8 @@
echo "Bootstrapping Django Vagrant machine..." echo "Bootstrapping Django Vagrant machine..."
sudo apt-get update sudo apt-get update
sudo apt-get install -y vim git make build-essential libssl-dev zlib1g-dev libbz2-dev \ sudo apt-get install -y vim git make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils


# Install NodeJS # Install NodeJS


Expand Down Expand Up @@ -43,32 +44,30 @@ which pip
python -V python -V
pip -V pip -V


echo "Installing Django" # Link vagrant directory to home
pip install django


python -m django --version echo "Create symbolic link to the repository"

ln -sfn /vagrant /home/vagrant/verleihtool
echo "Installing html2text"
pip install html2text
html2text --version

echo "Installing Flake8"
pip install flake8

flake8 --version


# Create helper scripts # Create helper scripts


cat > /home/vagrant/startServer.sh <<- EOF echo "Create helper scripts"
cat > /home/vagrant/server.sh <<- EOF
echo "Server listening at http://127.0.0.1:1337/"
python /vagrant/manage.py runserver [::]:8000 python /vagrant/manage.py runserver [::]:8000
EOF EOF


cat > /home/vagrant/lint.sh <<- EOF cat > /home/vagrant/test.sh <<- EOF
pylint --load-plugins pylint_django \ set -e
/vagrant/verleihtool \ cd /vagrant
/vagrant/depot \
/vagrant/rental echo "-- Running linter flake8"
flake8
echo "Linter succeeded"
echo
echo "-- Running tests"
python manage.py test
EOF EOF


chmod u+x /home/vagrant/startServer.sh chmod u+x /home/vagrant/server.sh /home/vagrant/test.sh
chmod u+x /home/vagrant/lint.sh
6 changes: 3 additions & 3 deletions requirements.txt
@@ -1,3 +1,3 @@
Django>=1.10.6 Django==1.10.6
flake8>=3.3.0 flake8==3.3.0
html2text>=2016.9.19 html2text==2016.9.19

0 comments on commit 6188470

Please sign in to comment.