Web Onboarding - Training - Setting Up Development Workstation

Workstation Setup and Development Container

Summary

This repository houses various utilities and configuration files that benefit increased productivity.


-Workstation Setup: The setup script downloads and installs the necessary programs for developing web applications.
-Development Container: Ansible playbook that takes user specified parameters and creates a container based on the uwm.edu/saits-webapp Docker image.



TL;DR
  • To setup your workstation open terminal:
cd
git clone git@git.sa.uwm.edu:lyonp/utilities.git
cd utilities/workstation-setup
./setup.sh

  • To setup a new development container:
cd
cd utilities/development-container
ansible-playbook -i inventory master.yml


Workstation Setup

This will download and install Docker, HomeBrew, Oracle InstantClient, and other tools necessary for development. The setup script is broken into two parts. The first part will download and install Docker and the necessary tools to install HomeBrew and Ansible. Once the required tools have been installed you will be prompted again for your account password for the sudo command.

cd workstation-setup
./setup.sh

In the event that something breaks or the Docker image needs to be rebuilt, you can use Ansible to rerun the playbook by specifying tags to execute parts of the playbook.
  • Configuration - Tasks relating to workstation configuration (e.g., Command Line Tools, HomeBrew, etc.)
  • Container Development - Tasks relating to Docker container development.
  • Docker Container - Task to rebuild the Docker image.
  • Local Development - Tasks relating to local development.
  • Oracle InstantClient - All Oracle InstantClient tasks.
  • Reapir - Reruns the HomeBrew and Oracle tasks.


Re-run Configuration Tasks

ansible-playbook setup.yml -e "username=$(id -u -nr) group=\"$(id -g -nr)\" homedir=$HOME" -t "Configuration"


Tasks for Configuration Tag
  • Generate SSH Keys
  • Install Home Brew
  • Install Taps
  • Install Brews
  • Get Homebrew Prefix
  • Install NPM Modules


Re-run Container Development Tasks

ansible-playbook setup.yml -e "username=$(id -u -nr) group=\"$(id -g -nr)\" homedir=$HOME" -t "Container Development"


Tasks for Container Development Tag
  • Install Home Brew
  • Install Taps
  • Install Brews
  • Get Homebrew Prefix
  • Install NPM Modules
  • Build Webapp Image


Re-run Docker Container Tasks

ansible-playbook setup.yml -e "username=$(id -u -nr) group=\"$(id -g -nr)\" homedir=$HOME" -t "Docker Container"


Tasks for Docker Container Tag
  • Build Webapp Image



Re-run Local Development Tasks

ansible-playbook setup.yml -e "username=$(id -u -nr) group=$(id -g -nr) homedir=$HOME" -t "Local Development"



Tasks for Local Development Tag
  • Generate SSH Keys
  • Install Home Brew
  • Install Taps
  • Create Oracle Directory
  • Extract Oracle InstantClient Files
  • Create Oracle Links
  • Change Permissions of Oracle InstantClient
  • Install Brews
  • Get Homebrew Prefix
  • Install NPM Modules



Re-run Oracle InstantClient Tasks

ansible-playbook setup.yml -e "username=$(id -u -nr) group=$(id -g -nr) homedir=$HOME" -t "Oracle InstantClient"



Tasks for Oracle InstantClient Tag
  • Create Oracle Directory
  • Extract Oracle InstantClient Files
  • Create Oracle Links
  • Change Permissions of Oracle InstantClient



Repair

If things become completely broken it might be easier and save a lot of time and pain to re-run everything again:

ansible-playbook setup.yml -e "username=$(id -u -nr) group=$(id -g -nr) homedir=$HOME" -t "Repair"


Tasks for Repair Tag
  • Install Home Brew
  • Install Taps
  • Create Oracle Directory
  • Extract Oracle InstantClient Files
  • Create Oracle Links
  • Change Permissions of Oracle InstantClient
  • Install Brews
  • Get Homebrew Prefix
  • Install NPM Modules



Development Container

The Ansible play book for creating a development container is found in development-container. Running the playbook without specifying any variables will cause Ansible to prompt you for the following:
  • Name of Project - This is used as the container's name
  • Project Path - Where the files for the project will reside. This directory is exported to the container.
  • Git Repository (optional) - A URL or path can be provided to have Ansible clone the directory. If you have provided a path to a directory that contains a repository then leave this blank to skip cloning.
  • Git Branch (optional) - Specifying a branch will select which branch to checkout. By default the master branch will be the active branch.
  • Database Name - Defaults to webapp.
  • Database User Name - Defaults to webapp.
  • Database Password - Defaults to webapp.
  • Database Seeder - Defaults to DefaultsSeeder

ansible-playbook -i inventory master.yml


To run the play without having to enter anything:

cd development-container
ansible-playbook -i inventory master.yml -e "project_name=WebApplication project_directory=$HOME/Code/MyApplication git_repository=git@git.sa.uwm.edu:web/webapp.git git_branch=develop project_db=webapp project_db_user=webapp project_db_pass=webapp project_db_seeder=DefaultsSeeder container_image=uwm.edu/saits-webapp"


IMPORTANT: When entering the project directory, you must specify the full path because Ansible will not expand the tilde (~) to the value found in $HOME.



Additional Information

To make life simpler, ports 80, 443, 3306, 8443, and 9000 are forwarded from the local machine to the container. Therefore only one container can be running at a time and no other programs using those ports.

If the workstation_setup playbook was run, three helper functions are available to you.
  • artisan is an alias of php artisan which only works in the same directory as the artisan file.

  • dash [container name] runs the command docker exec -it [container name] /bin/bash If no container is specified then it will use the name of the container that was created last.

  • conrestart stops and starts the last container. This is useful when configuring any service that requires to be restarted.




Keywords:Saits, sa its, Student Affairs IT Services, learning, training, workstation, development, web, set up, Docker, Container,   Doc ID:80936
Owner:Sammie O.Group:UW-Milwaukee Student Affairs IT
Created:2018-03-15 13:02 CDTUpdated:2018-03-21 13:31 CDT
Sites:UW-Milwaukee Student Affairs IT
Feedback:  0   0