Skip to content

Workshop Part 1

ABG edited this page Nov 17, 2022 · 7 revisions

Workshop Part 1

Workshop attendees will be provided support for the initial set up of the development environment during Part I of the Workshop. This workshop is for people who have not been able to successfully complete the following environment setup:

  • a public GitHub account with two-factor authentication (2FA) setting on
  • Git installed on your computer
  • A text editor. VS Code is recommended, but feel free to use a text editor of your choice.
  • Docker and Docker-compose installed/downloaded from the internet
  • Basic knowledge of Python – see lessons here

Setting up the development environment

1.1 Dev setup (1): Join the repository team

  1. Make your own Hack for LA GitHub organization membership public by following this guide.
  2. Set up two-factor authentication on your account by following this guide.

1.2 Dev setup (2): Installing Git

Before cloning your forked repository to your local machine, you must have Git installed. You can find instructions for installing Git for your operating system here.

For Windows, you may want to install a Windows Subsystem for Linux (WSL) and then install Git from WSL.

Please note that if you have a Mac the page offers several options (see other option, if you need to conserve hard drive space) including:

  • an “easiest” option (this version is fine for use at hackforla): This option would take just over 4GB.
  • a “more up to date” option (not required but optional if you want it): This option prompts you to go to install an 8GB package manager called Homebrew.
  • Other option: If your computer is low on space, you can use this tutorial to install XCode Command Tools and a lighter version of Homebrew and then install Git using this command: $ brew install git which in total only uses 300MB.

1.3 Dev setup (3): Fork the repository

You can fork the hackforla/peopledepot repository by clicking Fork . A fork is a copy of the repository that will be placed on your GitHub account.

Note: It should create a URL that looks like the following -> https://github.com/<your_GitHub_user_name>/peopledepot.

For example -> https://github.com/octocat/peopledepot.

Be Aware: What you have created is a forked copy in a remote version on GitHub. It is not yet on your local machine yet.

1.4 Dev setup (4): Clone (Create) a copy on your computer

Before creating a copy to your local machine, you must have Git installed. You can find instructions for installing Git for your operating system here.

The following steps will clone (create) a local copy of the forked repository on your computer.

1.4.a Clone repo (1): Create hackforla folder

Create a new folder in your computer that will contain hackforla projects.

In your command line interface (Terminal, Git Bash, Powershell), move to where you want your new folder to be placed and create a new folder in your computer that will contain hackforla projects. After that, navigate into the folder(directory) you just created.

For example:

mkdir hackforla
cd hackforla

and run the following commands:

git clone https://github.com/<your_GitHub_user_name>/peopledepot.git

For example if your GitHub username was octocat:

git clone https://github.com/octocat/peopledepot.git

You should now have a new folder in your hackforla folder called peopledepot. Verify this by changing into the new directory:

cd peopledepot

1.4.b Clone repo (2): Verify origin remote url

Verify that your local cloned repository is pointing to the correct origin URL (that is, the forked repo on your own Github account):

git remote -v

You should see fetch and push URLs with links to your forked repository under your account (i.e. https://github.com/<your_GitHub_user_name>/peopledepot.git). You are all set to make working changes to the website on your local machine.

However, we still need a way to keep our local repo up to date with the deployed website. To do so, you must add an upstream remote to incorporate changes made while you are working on your local repo. Run the following to add an upstream remote URL & update your local repo with recent changes to the hackforla version:

git remote add upstream https://github.com/hackforla/peopledepot.git
git fetch upstream

After adding the upstream remote, you should now see it if you again run git remote -v :

origin  https://github.com/<your_GitHub_user_name>/peopledepot.git (fetch)
origin  https://github.com/<your_GitHub_user_name>/peopledepot.git (push)
upstream        https://github.com/hackforla/peopledepot.git (fetch)
upstream        https://github.com/hackforla/peopledepot.git (push)

1.5 Dev setup (5): Set up Docker

Install or make sure [docker][docker-install] and [docker-compose][docker-compose-install] are installed on your computer

    docker -v
    docker-compose -v

The recommended installation method for your operating system can be found here. Feel free to reach out in the Hack for LA Slack channel if you have trouble installing docker on your system

More on using Docker and the concepts of containerization:

1.6 Dev setup (6): Build and run the project locally with the script

IMPORTANT: Please make sure the Docker Desktop application is running on your computer before you run the bash commands below. Running docker container ls should list the peopledepot-web image, e.g.: docker_ls_screenshot

  1. Create an .env.dev file from .env.dev-sample

    cp .env.dev-sample .env.dev
  2. Build and run the project via the script

    ./scripts/buildrun.sh
  3. Create a super user for logging into the web admin interface

    docker-compose exec web python manage.py createsuperuser
  4. Browse to the web admin interface at http://localhost:8000/admin/ and confirm the admin site is running. Use the credentials you created in Step 2 (above) to log in.

1.6.a Stopping Docker

To stop the service-container, but not destroy it (often sufficient for day-to-day work):

docker-compose stop

To stop and destroy the service container:

docker-compose down

Add the -v flag to destroy the data volumes as well:

docker-compose down -v
Clone this wiki locally