Skip to content

hackathon-mentors/hackathon-mentors-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

hackathonmentors-web

Website for Hackathon Mentors

Requirements

  • UNIX environment (Windows users look into WSL2)
  • Python 3.8.2 or higher
  • docker (WSL2 reference)
  • docker-compose

Setup

  1. Clone into this repository:
$ git clone https://github.com/hackathon-mentors/hackathon-mentors-web.git
  1. In the repository's root directory, create a directory named secrets and make a django_secret file to create your own Django secret key.
$ cd hackathon-mentors-web 
$ mkdir secrets && cd secrets
$ cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 50 | head -n 1 > django_secret

(Note: for macOS, the last command may not run and shell would complain about tr: Illegal byte sequence error. Use the following instead:

$ cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 50 | head -n 1 > django_secret

Use the following template to create db.env in secrets folder, using your preferred text editor:

POSTGRES_DB=hackathonmentors
POSTGRES_USER=hackathonmentors_user
POSTGRES_PASSWORD=hackathonmentors_pass
  1. Run docker-compose build and docker-compose up -d to start building & spinning up the api and db images.
  • Since we are running docker-compose v3, the db may come up before the api server.
  • Check logs docker-compose logs -f api and see if it has connection errors.
  • If so, simply do docker-compose restart api
  • Note: If you encounter issue with the connection between the api and db images, you would need to docker-compose down and docker-compose up -d
  1. docker exec -ti api /bin/bash to go into the django (web) image:
  • python hackathonmentors/manage.py migrate to set up initial database
  • python hackathonmentors/manage.py createsuperuser to create an admin user for your localhost.
  • python hackathonmentors/manage.py loaddata hackathonmentors/hackathon/fixtures/0001_initial.json to load up sample hackathon data (from HackathonScraper!) NOTE: The fixture will be bind the sample hackathon objects' creator as the first user (i.e. id=1) you created from running the createsuperuser command from above.
  • Run UPDATE django_site SET domain='127.0.0.1', name='127.0.0.1' WHERE id='1'; in the SQL database to expose the site locally.
  1. Visit https://localhost:8000/ ✨

Deployment

Production deployment is separate from using docker-compose:

$ docker build . -t web  # to build a docker image
$ docker tag web hm-web:<version>  # (check version at https://github.com/hackathon-mentors/hackathon-mentors-web/blob/master/k8s/hm.yaml)
$ docker push hm-web:<version>  # to push up to docker hub

NOTE: more deployment info to be added once we go prod