Kanal Akses Pendaftaran KP Elektronik (kape)
Internship matchmaking platform for students and companies.
Table of Contents
- Install
- Running Development Mode (Classic)
- Running Development Mode (Containerised)
- References
- License
Install
This project uses Python 2 and Node.js v4 for building the backend and frontend, respectively. The backend uses Django Framework and PostgreSQL database, while the frontend is developed using React. You need to install the required dependencies prior to building and contributing to the project.
-
Node.js v4.9.1 and
npm
package manager.Note: We recommend
nvm
(Node Version Manager) for installing Node.js. You can findnvm
for your OS at the following links:Once
nvm
has been installed, install Node.js and activate it by executingnvm install 4.9.1
followed bynvm activate 4.9.1
. -
Python 2.7.16 and
pip
package manager.Note: We recommend using virtual environment to isolate project-specific Python packages from system-level packages. You can install and use
virtualenv
package to create the virtual environment for this project. -
PostgreSQL 9.6 and any database
client that can interface with PostgreSQL, e.g.
psql
, pgAdmin.Note: We recommend running the database as container or virtual machine to avoid cluttering your local development environment. Please consult the documentation for your container engine (e.g. Docker) or virtualization platform (e.g. VirtualBox or Hyper-V) on how to provision PostgreSQL database. If you had to use locally-installed database, make sure your own data will not interleave with the data generated by this project.
Verify that Node.js and Python 2 have been successfully installed. Make sure
the interpreter for both platforms can be invoked from the shell. For example,
in bash
shell (macOS or GNU/Linux-based OS):
# Assuming there is a Python virtual environment directory named `env` in
# current path
$ source env/bin/activate
$ python --version # or: python2 --version
Python 2.7.16
$ node --version
v4.9.1
Now install the packages required by Node.js and Python 2:
npm install
pip install -r requirements.txt
If you are cloning the project for the first time into your local development
environment, you need to create a new database user named kape
and create a
new database with the same name for this project. Do not forget to set the
ownership of the new database to kape
user. Once you have finished setting up
the database, perform database migration and seeding:
python manage.py migrate
python manage.py loaddata seeder.json
Note: Can't connect to the database? Adjust the database connection settings at
settings.py
.
Finally, verify that the test suites pass:
# Run the test suite for backend
python manage.py test
To run the test suite for frontend, you need to build the frontend first before running the test suite:
npm run build-production
npm run karma
Running Development Mode (Classic)
To run the API (backend) server:
python manage.py runserver
To serve the frontend:
npm run webpack
# If you don't want live update, run: npm run build
# If you want the uglified, zipped, production-ready version, run: npm run build-production
You can see the app running by going to localhost:8080
via your favourite
Web browser.
Running Development Mode (Containerised)
If you have installed Docker and Docker Compose, you can build the app into a container image and run it with container-based database and Web server:
docker-compose up --build --detach
docker-compose run --rm app python manage.py migrate
docker-compose run --rm app python manage.py loaddata seeder.json
Explanation:
- Rebuild the application (the frontend + backend), then start it along with the database (
postgres
) and Web server (nginx
).- Perform database migration
- Perform database seeding
Before you can see the app, you need to know the port in the host that mapped to the port in the Web server container:
# The following is just an example. The output may vary in your environment.
$ docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------
kape_app_1 gunicorn --bind 0.0.0.0:80 ... Up 8001/tcp
kape_db_1 docker-entrypoint.sh postgres Up 5432/tcp
kape_web_1 nginx -g daemon off; Up 0.0.0.0:32770->80/tcp
In the above example, port 32770 is mapped to port 80 in the Web server
container. Thus, you can see the app via Web browser by opening
http://localhost:32770
.
Note: Running the app and its dependencies as containers are convenient, but you will not be able to see any changes to the codebase in real-time. If you want to see changes in the codebase reflected in real-time, follow the classical approach for running the development mode.
References
License
Copyright (c) 2017 PPLA1 Team & Faculty of Computer Science Universitas Indonesia. This project is licensed under ISC license.