Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke commands by Makefile #122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<p align="center">

<h2 align="center">ZEZERE</h2>

<p align="center">
Official Codebase
<br>
<a href="https://github.com/fedora-iot/zezere/issues">Report Bug</a>
·
<a href="https://github.com/fedora-iot/zezere/issues">Request Feature</a>
</p>
</p>
<br>
<p align="center">
<a href="https://github.com/fedora-iot/zezere/graphs/contributors">
<img alt="Contributors" src="https://img.shields.io/github/contributors/fedora-iot/zezere.svg?style=for-the-badge" style="max-width:100%;">
</a>
<a href="https://github.com/fedora-iot/zezere/network/members">
<img alt="Forks" src="https://img.shields.io/github/forks/fedora-iot/zezere.svg?style=for-the-badge" style="max-width:100%;">
</a>
<a href="https://github.com/fedora-iot/zezere/stargazers">
<img alt="Stargazers" src="https://img.shields.io/github/stars/fedora-iot/zezere.svg?style=for-the-badge" style="max-width:100%;">
</a>
<a href="https://github.com/fedora-iot/zezere/issues">
<img alt="Issues" src="https://img.shields.io/github/issues/fedora-iot/zezere.svg?style=for-the-badge" style="max-width:100%;">
</a>
</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for not using markdown specifically? 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using regular HTML tags comes in handy while specifying the dimensions of an image. Rest, nothing specific.


## 📝 General Overview

This file contains the developer guidelines to set up **Fedora Zezere** for Debian-based Linux distributions.

## ⚙️ Set-Up and Usage
### For Linux (Debian) users:

- To clone the zezere repository of the project:
```
git clone https://github.com/fedora-iot/zezere.git .
```

- To set-up the virtual environment of the project:
```
make virtualenv
```

- To install the base-dependencies and wsgi configurations of the project:
```
make dev
```
- To install other requirements of the project:
```
make install
```
- To configure default zezere-manage tool of the project:
```
make zezere
```
- To modify the configurations of `zezere.conf` file, manually set:
```
secret_key = <key generated in .env file>
allowed_host = *
auth_method = local
```

- To apply the database migrations and collect staticfiles of the project:
```
make migrate
```
- To create the superuser of the project:
```
make superuser
```

- To run the project on the localhost:
```
make run
```
***Note:*** _As of now, `zezere.conf` file modifications are supposed to be done manually, however, the work is in progress to invoke them by `make` commands_

43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
PYTHON_EXE?=python3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you're using Makefile for this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Facing issues while setting up a project is quite inevitable. To simplify the process, make commands might be invoked after specifying the tasks to be executed.
The sole purpose was to set the desired python version in the makefile. In my opinion, they make the Makefile cleaner and can be overridden by the user as per the future requirements.

MANAGE=venv/bin/python manage.py
ACTIVATE?=. venv/bin/activate;
GET_SECRET_KEY=`base64 /dev/urandom | head -c50`
ENV_FILE=.env

PORT = 8080

virtualenv:
@echo "-> Making Virtual Environment"
@${PYTHON_EXE} -m venv venv

genkey: virtualenv
@echo "-> Generating Secret key"
@if test -f ${ENV_FILE}; then echo ".env file exists already"; true; else \
mkdir -p $(shell dirname ${ENV_FILE}) && touch ${ENV_FILE}; \
echo secret_key=\"${GET_SECRET_KEY}\" > ${ENV_FILE}; \
cat etc/env.txt >> ${ENV_FILE}; fi

dev: genkey
@echo "-> Installing Dependencies"
@${ACTIVATE} pip install -r etc/dev.txt
@${ACTIVATE}mod_wsgi-express start-server


install: genkey
@echo "-> Installing Dependencies"
@${ACTIVATE} pip install .

zezere:
@${ACTIVATE} cp zezere/default.conf ./zezere.conf

migrate:
@echo "-> Creating database file"
@${MANAGE} migrate --noinput
@echo "-> Collecting static file"
@${MANAGE} collectstatic

superuser:
@${ACTIVATE} zezere-manage createsuperuser --username admin --email [email protected]

run:
./app.sh
4 changes: 4 additions & 0 deletions etc/dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
django>=2.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why create a separate requirements file and not use the project-level one?
This will likely get out of sync.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use the project-level requirements file for sure. No doubt that right now it does not serve any major purpose but as the size of the source code grows with the passage of time, specifying separate dependencies for production and development seems more reasonable. Moreover, in the case of working with unit testing frameworks, installing that in production would be unavailing.

djangorestframework
mod_wsgi-standalone
psycopg2-binary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are these for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going by the common convention to put testing or development requirements in a separate file. The basic idea behind this was to install all developmental dependencies by invoking make commands in that respective directory.

Empty file added etc/env.txt
Empty file.