Skip to content

Latest commit

 

History

History
52 lines (29 loc) · 3.04 KB

Serve-local-instance.md

File metadata and controls

52 lines (29 loc) · 3.04 KB

Run a local instance of the Legislation Explorer in a virtual machine

By following this guide, you will be able to access the latest version of the Legislation Explorer on your local machine at http://localhost:8001/, without worrying about dependency and stack management, thanks to Vagrant and Ansible.

For information, this guide was written with Ansible 2.11.2 running on Python 3.9.4, Vagrant 2.2.16 and VirtualBox 6.1.22.

1. Install a virtual machine provider

In order to isolate the Legislation Explorer environment from your environment, we will set it up in a virtual machine.

If you don’t already have a provider installed (VirtualBox, Docker, VMWare, Hyper-V…), install VirtualBox.

On a Mac with an Apple Silicon processor

VirtualBox is not compatible with Apple Silicon (M1…) processors. You will thus need to use the Docker provider.

To that end, install Docker Desktop through a manual install or with brew install homebrew/cask/docker.

2. Set up Vagrant

Vagrant enables programmatic setup of virtual machines.

Install Vagrant.

3. Install Ansible

To install Ansible, follow the documentation for your operating system.

To check that Ansible is properly installed, run ansible --version. You should get something like:

ansible [core 2.11.2]
   …

4. Install and start the Legislation Explorer

  1. Clone (or download) the legislation-explorer repository: https://github.com/openfisca/legislation-explorer.git.
  2. Navigate to the freshly downloaded folder: cd legislation-explorer.
  3. Type the following command: vagrant up. If you’re on an Apple Silicon machine or want to use Docker instead of VirtualBox, type vagrant up --provider=docker.

Once the command is done, you should have a virtual machine running the Legislation Explorer.

Thanks to Vagrant port forwarding, the port 80 inside the virtual machine is forwarded to another port on your development machine. You can thus access the Legislation Explorer on your local machine on the 8001 port: just open http://localhost:8001/ in your browser.

You can override that port with the PORT environment variable: PORT=8081 vagrant up.

You can override the API URL with the API_URL environment variable: API_URL=https://api.demo.openfisca.org/latest vagrant up.

On such a local virtual machine, the application is by default served over HTTP instead of HTTPS, as SSL certificates cannot be automatically provisioned by Let’s Encrypt.

The base_path variable won't have any effect when using this local virtual machine setup. When using Vagrant, by default the app is accessed directly, with no reverse proxy.