Skip to content

Local Studio Container

This guide will walk you through launching a Docker-container local development studio and using it to test changes made within a local Git repository.

Launch studio container

  1. Install Chef Habitat:

    curl -s https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash
    
  2. Set up Chef Habitat, accepting defaults for all prompts:

    hab setup
    
  3. Clone slate-cbl repository and any submodules:

    git clone --recursive git@github.com:SlateFoundation/scienceleadership-skeleton.git
    
  4. Change into cloned directory:

    cd ./slate-cbl
    
  5. Launch studio:

    Use the included scripts-to-rules-them-all workflow script to configure and launch a studio session:

    script/studio
    

    Review the notes printed to your terminal at the end of the studio startup process for a list of all available studio commands.

Bootstrap and develop backend

  1. Start services:

    Use the studio command start-all to launch the http server (nginx), the application runtime (php-fpm), and a local mysql server:

    start-all
    

    At this point, you should be able to open localhost:5520 and see the error message Page not found.

  2. Build site:

    To build the entire site and load it, use the studio command update-site:

    update-site
    

    At this point, localhost:5520 should display the current build of the site

  3. Load fixture data into site database (optional):

    load-fixtures
    

    The standard fixture data includes the following users:

    Username Password AccountLevel About
    system system Developer Full system access
    admin admin Administrator Manage site and staff
    teacher teacher Staff Staff access with teaching role in multiple courses sections
    teacher2 teacher2 Staff Staff access with teaching role in multiple course sections
    student student User Student user with student role in multiple course sections
    student2 student2 User Student user with student role in multiple course sections
    student3 student3 User Student user with no roles in any course sections
  4. Make and apply changes:

    After editing code in the working tree, you must rebuild and update the site:

    update-site
    

    A command to automatically rebuild and update the site as changes are made to the working tree is also available, but currently not that efficient or reliable:

    watch-site
    

Enable user registration

To enable user registration on a site that comes with it disabled:

# write class configuring enabling registration
mkdir -p php-config/Emergence/People
echo '<?php Emergence\People\RegistrationRequestHandler::$enableRegistration = true;' > php-config/Emergence/People/RegistrationRequestHandler.config.php

# rebuild environment
update-site

After visiting /register and creating a new user account, you can use the studio command promote-user to upgrade the user account you just registered to the highest access level:

promote-user <myuser>

Connect to local database

The studio container hosts a local MySQL instance that can be connected to at:

  • Host: localhost (or LAN/WAN IP of machine hosting Docker engine)
  • Port: 5526
  • Username: admin
  • Password: admin