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

fix(docu): change link of deployment description #924

Merged
merged 15 commits into from
May 31, 2024
Merged
80 changes: 76 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Dreammall.earth

[![nodejs][badge-nodejs-img]][badge-nodejs-href]
[![npm][badge-npm-img]][badge-npm-href]
[![remark-cli][badge-remark-cli-img]][badge-remark-cli-href]
Expand All @@ -15,11 +16,11 @@ Dreammall.earth websites & services

## Deploy

Deploy instructions can be found in [deployment/](deplyoment/README.md)
Deploy instructions can be found in [deployment/](deployment/README.md)

## Commands

The following commands are available:
### The following commands are available

| Command | Description |
| -------------------------- | ---------------------------------------------- |
Expand All @@ -36,9 +37,80 @@ The following commands are available:
| **Maintenance** | |
| `npm run update` | Check for updates |

## Bare-metal

### Install Authentik

```bash
cd $rootFolder/authentik
./database.unpack.sh
docker compose up
```

### Start Database

```bash
cd $rootFolder
docker compose up database
```

### Start Backend

```bash
cd $rootFolder/backend
cp .env.dist .env
ln -s src/auth/public.pem public.pem
nvm use 21
npm install
# Initializierung Datenbank
npm run db:reset
# Migration Datenbank
# npm run db:migrate
npm run dev
```

### Start Presenter

```bash
cd $rootFolder/presenter
cp .env.dist .env
nvm use 21
npm install
# Run dev mode
# npm run dev
# Run prod mode (faster)
npm run prod
```

### Start Frontend

```bash
cd $rootFolder/frontend
cp .env.dist .env
nvm use 21
npm install
# Run dev mode
# npm run dev
# Run prod mode (faster)
npm run prod
```

### Start Admin

```bash
cd $rootFolder/admin
cp .env.dist .env
nvm use 21
npm install
# Run dev mode
# npm run dev
# Run prod mode (faster)
npm run prod
```

## Docker

The following endpoints are provided if `docker compose` is used:
### The following endpoints are provided for `docker compose`

| Endpoint | Description |
| -------------------------------------------------------------------- | -------------------------- |
Expand Down Expand Up @@ -66,7 +138,7 @@ Then run `npm run release` to propagate the new version and generate the changel

You can get a list of packages to update by running `npm run update`.

Appending `-u ` will also update the packages in the `package.json`. You have to run `npm install` again after.
Appending `-u` will also update the packages in the `package.json`. You have to run `npm install` again after.

```bash
npm run update -- -u
Expand Down
14 changes: 10 additions & 4 deletions admin/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# boilerplate-frontend

[![nodejs][badge-nodejs-img]][badge-nodejs-href]
[![npm][badge-npm-img]][badge-npm-href]
[![docker][badge-docker-img]][badge-docker-href]
Expand Down Expand Up @@ -32,7 +33,7 @@ This projects utilizes `storybook` and `chromatic` to develop, document & test f

## Commands

The following commands are available:
### The following commands are available

| Command | Description |
| --------------------------- | ------------------------------------------------ |
Expand Down Expand Up @@ -68,12 +69,14 @@ The following commands are available:

### Docker

Docker can be run in development mode utilizing `docker-compose.overwrite.yml`:
### Docker development mode

```bash
docker compose up
```

Docker can be run in production mode:
### Docker can be run in production mode

```bash
docker compose -f docker-compose.yml up
```
Expand All @@ -83,11 +86,14 @@ docker compose -f docker-compose.yml up
In order to use the chromatic workflow you need to provide a `CHROMATIC_PROJECT_TOKEN` in the repository secrets.

If you want to run chromatic from the command line you either have to provide this variable as well

```bash
export CHROMATIC_PROJECT_TOKEN=...
npm run chromatic
```

or you have to append it via parameter:

```bash
npm run chromatic -- --project-token=...
```
Expand All @@ -96,7 +102,7 @@ npm run chromatic -- --project-token=...

You can get a list of packes to update by running `npm run update`.

Appending `-u ` will also update the packages in the `package.json`. You have to run `npm install` again after.
Appending `-u` will also update the packages in the `package.json`. You have to run `npm install` again after.

```bash
npm run update -- -u
Expand Down
8 changes: 7 additions & 1 deletion authentik/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ This is an Authentik setup for development in order to make local testing for pr

This package comes with an preconfigured authentic - which has its data mainly residing in a postgress database. The contents of this database is available in packed form.

To extract the database use:
### Extract the database

```bash
./database.unpack.sh
```

(Note: make sure the database is not running before executing this command)

Alternatively you can not extract the database, which will start the service with an empty database. Use the [Docker Guide](https://goauthentik.io/docs/installation/docker-compose#preparation) from Authentik to get you going then.

## Start Docker

To start the authentik server and its services run:

```bash
docker compose up
```

(Note: make sure to run this command in the authentik folder, since there is another docker-compose setup in the main folder)

## User Credentials
Expand All @@ -37,8 +41,10 @@ To login you can use the superadmins credentials:
## Publish changes

If you want to publish changes to the database you can use the following command to pack the database:

```bash
./database.pack.sh
```

(Note: this assumes you are not root and sets the permissions of the database files via sudo)
(Note: make sure to shut down the database first before you run the script)
13 changes: 11 additions & 2 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,27 @@ This mechanic was taken from this [source](https://stackoverflow.com/questions/1

## Database setup

The project is set up for a `mysql` database. Use
### The project is set up for a `mysql` database

```bash
docker-compose up database
```
in the main folder to run the database inside docker. You need to copy the `.env.dist` file to `.env`. Run `npm run db:migrate` to generate the database. It might be required to delete the migration folder beforehand.

in the main folder to run the database inside docker.
You need to copy the `.env.dist` file to `.env`.

Run `npm run db:migrate` to generate the database.

It might be required to delete the migration folder beforehand.

## Token validation

If you use the authentik database from the zip file, link the `src/auth/public.pem` to the main folder:

```bash
ln -s src/auth/public.pem public.pem
```

Otherwise place the according certificate in the main folder with the name `public.pem`

## License
Expand Down
47 changes: 33 additions & 14 deletions deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,44 @@ This document describes how to prepare a host to deploy from a specific branch a
All instructions are for an `Alpine 3.18` and require adjustment if a different system is used.

## Update the system

```bash
apk update
apk upgrade
```

## Install Software
Install nginx:

### Install nginx

```bash
apk add nginx
rc-update add nginx boot
service nginx start
```

Install node & npm:
### Install node & npm

```bash
apk add nodejs npm
```

Install pm2:
### Install pm2

```bash
npm install pm2 -g
pm2 startup
rc-update add pm2 boot
```

Install git:
### Install git

```bash
apk add git
```

Install mariadb:
### Install mariadb

```bash
apk add mysql mysql-client
service mariadb setup
Expand All @@ -49,14 +56,16 @@ service mariadb start

## Install the project

Clone the repository:
### Clone the repository

```bash
cd /var/www/localhost/htdocs/
git clone https://github.com/dreammall-earth/dreammall.earth.git
cd dreammall.earth
```

Configure nginx:
### Configure nginx

```bash
# replace nginx config
cp -f deployment/nginx/default.conf /etc/nginx/http.d/default.conf
Expand All @@ -74,42 +83,50 @@ vi /etc/nginx/http.d/admin.conf
service nginx restart
```

Create Database User:
### Create Database User

```bash
mysql
```

### Create Database Tea

```sql
CREATE USER 'dreammall'@'localhost' IDENTIFIED BY 'SECRET';
GRANT ALL PRIVILEGES ON * . * TO 'dreammall'@'localhost';
FLUSH PRIVILEGES;
exit
```

Configure database connection:
### Configure database connection

```bash
cp backend/.env.dist backend/.env
# adjust the .env config as needed
vi backend/.env
# DATABASE_URL="mysql://dreammall:SECRET@localhost:3306/dreammall.earth"
```

Configure backend connection:
### Configure backend connection
Elweyn marked this conversation as resolved.
Show resolved Hide resolved

```bash
cp presenter/.env.dist presenter/.env
# adjust the .env config as needed
vi presenter/.env
# PUBLIC_ENV__ENDPOINTS__GRAPHQL_URI=http://localhost/api
```
Elweyn marked this conversation as resolved.
Show resolved Hide resolved

## Deploy the project

To deploy the project run
### To deploy the project run

```bash
deployment/deploy.sh
```

This will build all projects parts and start a pm2 instance to serve the corresponding services currently defined in the nginx config found in `deployment/nginx/default.conf`.

Those services are:
### Those services are

| Service | URL |
| ------------------- | ------------------------------------------ |
Expand All @@ -122,12 +139,14 @@ Those services are:

To enable autoupdate from a github branch do the following:

Install webhook:
### Install webhook

```bash
apk add webhook
```

Configure webhook:
### Configure webhook

```bash
cp deployment/webhooks/hooks.json.template deployment/webhooks/hooks.json
vi deployment/webhooks/hooks.json
Expand Down
3 changes: 2 additions & 1 deletion presenter/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Dreammall Presenter

[![nodejs][badge-nodejs-img]][badge-nodejs-href]
[![npm][badge-npm-img]][badge-npm-href]
[![docker][badge-docker-img]][badge-docker-href]
Expand Down Expand Up @@ -32,7 +33,7 @@ This projects utilizes `storybook` and `chromatic` to develop, document & test f

## Commands

The following commands are available:
### The following commands are available

| Command | Description |
| --------------------------- | ------------------------------------------------ |
Expand Down