Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Latest commit

 

History

History
220 lines (152 loc) · 5.65 KB

README.md

File metadata and controls

220 lines (152 loc) · 5.65 KB

Documentation for baldeweg Desk

baldeweg Desk contains services like letter.

Repositories

Requirements

  • PHP 8.1
  • PHP Composer
  • NodeJS 14LTS
  • Yarn
  • MySQL
  • SSH Access

Install with Docker

Installation with Docker is the preferred way!

Clone the examples repo from git@github.com:abaldeweg/desk_docker.git.

Change into the new created directory, create a .env file and define/change the env vars - particularly the passwords.

//.env

COMPOSE_PROJECT_NAME=desk
PORT_CORE=9011
PORT_LETTER=9012

DATABASE_SERVER=db
DATABASE_PORT=3306
DATABASE_NAME=desk
DATABASE_USER=admin
DATABASE_PASSWORD=password
DATABASE_ROOT_PASSWORD=password

APP_ENV=prod
APP_SECRET=secret
JWT_PASSPHRASE=passphrase
CORS_ALLOW_ORIGIN='^https?://(localhost|DOMAIN)(:[0-9]+)?$'

VUE_APP_API='DOMAIN'

Run ./setup to start the container.

Update

Run ./setup to update the container.

Backup Database

docker exec ID sh -c 'exec mysqldump $MYSQL_DATABASE -uroot -p"$MYSQL_ROOT_PASSWORD"' > dump.sql

Restore Database

docker exec -i ID sh -c 'exec mysql $MYSQL_DATABASE -uroot -p"$MYSQL_ROOT_PASSWORD"' < dump.sql

Install Manually

This is only needed if you do not want to install it with Docker.

Setup Backend

Clone the repository.

git clone https://github.com/abaldeweg/desk_core.git

Change into the created directory.

Create the file .env.local and .env.test.local with the following content. Please fit it to your needs.

DATABASE_URL=mysql://DB_USER:DB_PASSWORD@localhost:3306/DB_NAME

Then install the composer dependencies and create the database.

In prod run the following command.

composer install
composer dump-env prod
bin/console doctrine:database:create --if-not-exists
bin/console doctrine:migrations:migrate -n

If you are in dev run the following commands.

composer install
bin/console doctrine:database:create --if-not-exists
bin/console doctrine:migrations:migrate -n
bin/console doctrine:fixtures:load -n

The fixtures will create an account admin with password password. This is only for development, you should not use the fixtures in production!

In production you can run bin/console user:new [USERNAME] [ROLE]. The first user should have the role ROLE_ADMIN for others use ROLE_USER or just omit the role.

Auth

To authenticate your users, you need to generate the SSL keys under config/jwt/.

bin/console lexik:jwt:generate-keypair

Apache Webserver

Point the web root to the public dir.

You also need this header for apache.

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

More info on that: https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Resources/doc/index.md#important-note-for-apache-users

Configure your webserver to redirect all requests to the index.php file.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{ENV:REDIRECT_STATUS} ^$
  RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteRule ^ - [L]
  RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>

Setup Frontend

Download the files from the repository.

git clone https://github.com/abaldeweg/desk_letter.git

Change into the created directory.

Create the file .env.local and overwrite env vars from .env, if needed.

Start the build process.

yarn build

The files in dest/ should be located in your web root.

Apache Webserver

Configure your webserver to redirect all requests to the index.html file.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

Update

Update Backend

Change into the corresponding directory. Check out the latest version from git. Then, just call the following commands, if you are updating the production environment.

git checkout tags/[VERSION]
composer install
composer dump-env prod
bin/console doctrine:migrations:migrate -n

Update Frontend

Change into the corresponding directory. Then, run the following commands.

git checkout tags/[VERSION]
yarn build

Env Vars

  • APP_ENV - Environment, like prod, dev or test
  • APP_SECRET - A secret key
  • DATABASE_SERVER - Domain to the db server
  • DATABASE_PORT - Port of the db server
  • DATABASE_URL - Schema with credentials e.g. mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=8.0
  • DATABASE_NAME - Name of the db
  • DATABASE_USER - Username for the db
  • DATABASE_PASSWORD - Password of the db
  • DATABASE_ROOT_PASSWORD - The root password of the MySQL Server
  • JWT_PASSPHRASE - Password for the JWT key files
  • CORS_ALLOW_ORIGIN - Defines from which domains requests are allowed (CORS on Browsers)
  • VUE_APP_API - URL to the backend
  • VUE_APP_BASE_URL - The Base URL, in case the app is installed in a subdir.
  • PORT_CORE - Port for core
  • PORT_LETTER - Port for letter
  • PROXY_DOMAIN - Service name of the php-fpm instance

Architecture

All Code needs to be checked. For that Linter, CI-Tools, Unit-Tests and E2E-Tests should be in place. Security Alerts for dependencies should be active and Best Practices for coding needs to be followed. As frameworks were chosen Symfony and VueJS because of their free licenses and wide spread. The resulting code should also be released under a free license.