Fakultas Ilmu Komputer UI

README.md 5.68 KB
Newer Older
Daya Adianto's avatar
Daya Adianto committed
1
2
3
4
5
6
7
8
9
# Kanal Akses Pendaftaran KP Elektronik _(kape)_

> Internship matchmaking platform for students and companies.

## Table of Contents

- [Install](#install)
- [Running Development Mode (Classic)](#running-development-mode-classic)
- [Running Development Mode (Containerised)](#running-development-mode-containerised)
Daya Adianto's avatar
Daya Adianto committed
10
- [References](#references)
Daya Adianto's avatar
Daya Adianto committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
- [License](#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](https://nodejs.org/en/download/releases/) and `npm` package
  manager.
  > Note: We recommend `nvm` (Node Version Manager) for installing Node.js. You
  > can find `nvm` for your OS at the following links:
  > - [nvm for macOS or GNU/Linux-based OS](https://github.com/creationix/nvm)
  > - [nvm for Windows](https://github.com/coreybutler/nvm-windows)
  >
  > Once `nvm` has been installed, install Node.js and activate it by executing
  > `nvm install 4.9.1` followed by `nvm activate 4.9.1`.
- [Python 2.7.16](https://www.python.org/downloads/release/) 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`](https://virtualenv.pypa.io/en/stable/) package to create the
  > virtual environment for this project.
- [PostgreSQL 9.6](https://www.postgresql.org/download/) 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):

```bash
# 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:

```bash
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
Daya Adianto's avatar
Daya Adianto committed
68
ownership of the new database to `kape` user. Once you have finished setting up
Daya Adianto's avatar
Daya Adianto committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
the database, perform database migration and seeding:

```bash
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`](kape/settings.py).

Finally, verify that the test suites pass:

```bash
# 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:

```bash
npm run build-production
npm run karma
```

## Running Development Mode (Classic)

To run the API (backend) server:

```bash
python manage.py runserver
```

To serve the frontend:

```bash
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:

```bash
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:
> 1. Rebuild the application (the frontend + backend), then start it along with
>    the database (`postgres`) and Web server (`nginx`).
> 1. Perform database migration
> 1. 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:

```bash
# 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.
152

Daya Adianto's avatar
Daya Adianto committed
153
154
155
156
157
## References

- [The original README file](README.old.md).
- [The original (_upstream_) GitLab project repository](https://gitlab.com/PPL2017csui/PPLA1).

158
159
## License

160
Copyright (c) 2017 PPLA1 Team & Faculty of Computer Science Universitas
161
Indonesia. This project is licensed under [ISC](LICENSE) license.