|
|
# Install & Setup
|
|
|
## Installation
|
|
|
1. `git clone` this repository: `git clone https://gitlab.sokoll.com/moritz/blog.git`
|
|
|
2. build the images: `sudo make docker-build-main` and `sudo make docker-build-api`
|
|
|
3. launch the application: `sudo docker-compose up -d`
|
|
|
4. stop the application: `sudo docker-compose down`
|
|
|
## Setup
|
|
|
in the `api` folder add a file called: `dbconfig.json`
|
|
|
this file configures the database connection between api and db
|
|
|
syntax in it looks like this:
|
|
|
```json
|
|
|
{
|
|
|
"user": "username",
|
|
|
"pwd": "password"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### Database
|
|
|
the database server needs 3 things:
|
|
|
1. a database called `pyblog`
|
|
|
2. a table called `pyblog_contents` in `pyblog`
|
|
|
3. a table called `pyblog_users` in `pyblog`
|
|
|
to set them up go into the container first: `sudo docker exec -ti blog_blogdb_1` if this doesnt work figure out how the container is called on your system
|
|
|
then go into the database with `mariadb -uroot -p(yourpassword of the docer-compose.yml file)`
|
|
|
then add the user: `CREATE USER 'username''@'%' identified by 'password';`
|
|
|
create the database: `CREATE DATABASE pyblog;`
|
|
|
create the tables:
|
|
|
```sql
|
|
|
CREATE IF NOT EXISTS TABLE pyblog_contents (
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
author VARCHAR(30) NOT NULL,
|
|
|
content VARCHAR(1000) NOT NULL,
|
|
|
PRIMARY KEY ( id )
|
|
|
);
|
|
|
```
|
|
|
and:
|
|
|
```sql
|
|
|
CREATE IF NOT EXISTS TABLE pyblog_users (
|
|
|
uuid INT NOT NULL AUTO_INCREMENT,
|
|
|
name VARCHAR(30) NOT NULL,
|
|
|
bio VARCHAR(100) NOT NULL,
|
|
|
PRIMARY KEY ( uuid )
|
|
|
);
|
|
|
``` |