Website for Hackathon Mentors
- UNIX environment (Windows users look into WSL2)
- Python 3.8.2 or higher
- docker (WSL2 reference)
- docker-compose
- Clone into this repository:
$ git clone https://github.com/hackathon-mentors/hackathon-mentors-web.git- In the repository's root directory, create a directory named
secretsand make adjango_secretfile 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_secretUse 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- Run
docker-compose buildanddocker-compose up -dto start building & spinning up theapianddbimages.
- Since we are running docker-compose v3, the db may come up before the api server.
- Check logs
docker-compose logs -f apiand see if it has connection errors. - If so, simply do
docker-compose restart api - Note: If you encounter issue with the connection between the
apianddbimages, you would need todocker-compose downanddocker-compose up -d
docker exec -ti api /bin/bashto go into the django (web) image:
python hackathonmentors/manage.py migrateto set up initial databasepython hackathonmentors/manage.py createsuperuserto create an admin user for your localhost.python hackathonmentors/manage.py loaddata hackathonmentors/hackathon/fixtures/0001_initial.jsonto 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 thecreatesuperusercommand 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.
- Visit http://localhost:8000/ β¨
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 hubNOTE: more deployment info to be added once we go prod