PyCon / pycon2019

Website for PyCon 2019
BSD 3-Clause "New" or "Revised" License
158 stars 89 forks source link

Create turnkey setup script for developers #579

Closed brandon-rhodes closed 8 years ago

brandon-rhodes commented 9 years ago

After checking out the repository, @njl reported that there was no quick and easy way to get the PyCon Django site up and running locally on his machine.

In all of the projects I have worked on, it is important to have a quick provisioning script. Whether it uses a virtual machine managed by something like Vagrant, or uses a virtualenv style Python environment that runs natively on a developer's host, such a script lets a developer go from an initial checkout to a working site that they can debug in a single step.

A Vagrant image is tempting here because a Django site like this requires a MySQL database to be up and running, which is difficult to provide in a virtualenv, and almost inevitably will involve a number of manual admin setup steps to install on a developer's Linux, Mac, or Windows machine — but as I am not sure what the Django current best-practice is for turnkey solutions that get both the site and a database for it up and running, we defer to @chefscott the choice of approach here.

ghost commented 8 years ago

I just noticed there's already a 'Vagrantfile' in the repository. Once you have Virtualbox and Vagrant setup do the following:

  1. Clone the pycon repo and cd into the folder: git clone https://github.com/PyCon/pycon.git && cd pycon
  2. Bring up Vagrant: vagrant up
  3. When it's initialized, SSH in: vagrant ssh
  4. Create and activate a virtualenv: virtualenv env/pycon; . env/pycon/bin/activate
  5. Install requirements: pip install --trusted-host dist.pinaxproject.com -r requirements/dev.txt
  6. Copy 'local.py' and uncomment the line "from .dev import *" : cp pycon/settings/local.py-example pycon/settings/local.py
  7. Run the 'load_fixtures.sh' script and enter "Y": ./load_fixtures.sh
  8. Switch to the 'postgres' user and create the 'root' postgres user: sudo su - postgres
    • createuser -dlPs root
  9. Run psql and grant privileges: psql
    • GRANT ALL PRIVILEGES ON DATABASE pycon2016 TO root;
  10. Exit psql and logout from the 'postgres' user by pressing "ctrl-d" twice and then create the Django super user: ./manage.py createsuperuser
  11. Run the site and connect by navigating to http://localhost:8000 ./manage.py runserver 0.0.0.0:8000
brandon-rhodes commented 8 years ago

THANK YOU for putting together this list of steps, @chefscott! This is exactly what I needed to know in order to create a turnkey script.

But I am going to go ahead and re-open this issue because its goal was the creation of a script that would perform the above steps. The goal here is for developers to be able to run one command and then see the PyCon web site running locally. I will work on getting the above steps put together into a turnkey script, and I'll update this issue with my progress.

Thanks again for figuring out how we could get the site running!

brandon-rhodes commented 8 years ago

Oh — and, in case it helps with any future scripts you write: note that instead of using two commands to become another user as in sudo su - postgres, you can instead ask sudo directly to do something as a non-root user. Either of the following works, for example:

$ sudo -u postgres bash
$ sudo -u postgres psql -l