update readme

This commit is contained in:
Aarni Halinen
2021-04-14 17:48:45 +03:00
parent 39ba51f11a
commit 8481e963a3
3 changed files with 36 additions and 155 deletions
-75
View File
@@ -1,75 +0,0 @@
# Linux/Mac installation instructions
## Install dependencies
### Dependency list
* Python >3.5
* PostgreSQL >9.5
* pip3
* virtualenv
* npm
Install with apt:
```bash
sudo apt install python3
sudo apt install python3-pip
sudo apt install postgresql
sudo pip3 install virtualenv
sudo apt install npm
```
More info about PostgreSQL at:
[https://www.postgresql.org/](https://www.postgresql.org)
These packages might be needed on certain platforms:
* python3-dev
* libffi-dev
* python3-cffi
* libssl-dev
## Create a virtual environment for python
Create a virtualenv in the parent directory.
```bash
virtualenv -p python3 ../virtualenv.sikweb
```
## Activate virtualenv
Assuming we are at the root of this repository and virtualenv is one level above.
```bash
. ../virtualenv.sikweb/bin/activate
```
## Run install wizard
Run the install wizard with
```bash
bash setup.sh
```
and follow the instructions.
## Done
## In case of error on macOS Mojave 10.14
If you get an error saying
```bash
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
```
run
```bash
xcode-select --install
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
```
+36 -25
View File
@@ -26,18 +26,39 @@ Set up your SSH key authentication in GitLab Profile Settings. Then clone the re
git clone git@gitlab.com:sahkoinsinoorikilta/vtmk/web2.0-backend.git
cd web2.0-backend
git checkout develop
cp scripts/git/pre-push .git/hooks/pre-push # install a script to test code before committing
```
## Windows install instructions
## Development
See [Windows install instructions](./windows_install.md)
### Poetry
## Linux/Mac install instructions
For depedencies and virtual environment, we use [poetry](https://python-poetry.org/). The easiest integration with VSCode is to have poetry install virtual environment in project folder, configured with
See [Linux/Mac install instructions](./linux_install.md)
```bash
poetry config virtualenvs.in-project true
```
## Initializing data
#### CMDs
Install dependencies
```bash
poetry install
```
Activate virtual environment in shell
```bash
poetry shell
```
### npm scripts
We use Node.js for few development tasks, like linting. Easiest way to install Node is [nvm](https://github.com/nvm-sh/nvm).
TODO: List scripts
### Initializing data
Run the following `manage.py` commands. Do not run these in production without thinking!
@@ -47,9 +68,7 @@ python manage.py initialize # creates user groups
python manage.py createdummydata # creates dummy members to the member register
```
## Running
### Use runserver command
### Running
```bash
python manage.py runserver 0.0.0.0:8000
@@ -57,23 +76,11 @@ python manage.py runserver 0.0.0.0:8000
Using address `0.0.0.0` will bind to all IP addresses. Using `localhost` will only bind to your machine.
### Visit the page
#### Visit the page
Visit [https://localhost:8000](https://localhost:8000) in your browser!
## Running in production
Run the project in production with gunicorn. Refer to [this page](https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04) for instructions.
Install production dependencies.
```bash
pip install -r requirements.production.txt
```
## Development workflow
Do not use `rebase` when pulling or merging changes. Rebasing transforms the commit history and makes it appear more linear. This is a plus e.g. when working with a few people, but in this project traditional merging is recommended for clarity.
### Development workflow
When you start working on a feature, create a feature branch for your changes. These feature branches should be prefixed with `feature`.
@@ -110,13 +117,17 @@ Use an editor with linting capabilities to write pretty code that passes linting
Run unit tests with
```bash
python manage.py test -v 2
python manage.py test
```
Due to the mostly static nature of the project, most elements are difficult to properly unit test. If you write code with actual logic, make sure to write at least one unit or integration test that tests your code's core functionality.
Tests are located in `tests.py` under every subproject.
### GitLab CI
## Production
Project is run in production with Docker. See `Dockerfile` for details.
## GitLab CI
All pushed changes go through the GitLab Continuous Integration, which consists of automated unit testing and linting. Make sure your changes pass both before merging to `develop` or `master`.
-55
View File
@@ -1,55 +0,0 @@
# Windows installation instructions
## Install dependencies
### Install python3
Visit [The python website](https://www.python.org/downloads/windows/) to install the latest version of python3.
Make sure to add the python binary directory to PATH. For instructions how to do this, refer to [this Stackoverflow answer](https://superuser.com/questions/143119/how-to-add-python-to-the-windows-path).
### Install virtualenv with pip
Run the following command to install `virtualenv`.
```cmd
python -m pip install virtualenv
```
Setup a virtual python environment.
```cmd
python -m virtualenv ../virtualenv.sikweb
```
## Activate virtualenv and install requirements
Activate `virtualenv` (note that this has to be active at all times).
```cmd
source ../virtualenv.sikweb/Scripts/activate
```
Run the following command to install python packages.
```cmd
pip install -r requirements.txt
```
## Run migrations
Run
```cmd
python manage.py migrate
```
## Install npm for linting javascript
Follow the instructions on [the npm website](https://www.npmjs.com/package/npm).
## Set up database
By default Django uses SQLite, which doesn't need any configuration. If you need PostgreSQL instead, refer to [their website](https://www.postgresql.org/download/windows/).
## Done