A gateway/firewall task to be able to talk someone about the real job
Fibinger Ádám
2021-10-22 3f95d8278fc20cdc53936ee8eac2361a12440312
commit | author | age
e3c536 1 # SecretServer
2 This is a submission for the Shoprenter's backend developer job.
3
4 Live version: https://secretserver.unr.hu/
5
6 ## Minimum requirements 
7
8 ### Everywhere
9 - PHP 7.2.5 (tested with 7.4)
10 - composer
11
12 ##### Locally
13 - [Symfony binary](https://symfony.com/download)
14 #### On a webserver
15 - A properly configured php 7+ and some VHost-config skills on your webserver of choice (It is on an Nginx + php-fpm on the live version)
16
17 ### How to fire up the project
18  Included a default .env file with a preconfigured Sqlite database and unless you have a production ready stuff, you should use this default.
19  
20 If you want to use anything else, please consult the [Symfony Documentation](https://symfony.com/doc/current/configuration.html#configuring-environment-variables-in-env-files) about the correct configuration.
21
22 ### Install
23 Checkout the repository and change dir (same for local and deployed):
24
25 ```
26 git clone https://shr:yRmglFOqNMbwpnuhP5iy@git.unr.hu/r/shoprenter-secretserver.git secretserver.website.tld
27 cd secretserver.website.tld
3f95d8 28 composer install --no-dev
e3c536 29 ```
30
3f95d8 31 This is will create an Sqlite DB (or anything else if you changed the config) with the correct schema (you can check the .env file about the details) in the project dir (`var/data.db`):
e3c536 32
33 ```
34 php bin/console doctrine:database:create
35 php bin/console doctrine:migrations:migrate
36 ```
37
38 ##### SELinux
39 In theory if you have good sysadmins, you have SELinux. 
40 Tell them to add `httpd_sys_rw_content_t` type to the project var/* directory and you are good to go.
41
42 ##### Im am alone in the dark and my desire to `setenforce 0` is high
43 _Never turn off_ SELinux if you have it, its easy: let the almighty SERuler know we have some stuff that should be R/W by the webserver (you have to be in the project directory):
44
45 ```
46 semanage fcontext -a -t httpd_sys_rw_content_t "`pwd`/var(/.*)?"
47 ```
48 At this point you have a proper type context enabled on the var files (if your OS has correctly configured context), but SELinux cannot see it yet, you have to "activate" it:
49 ```
50 restorecon -R -v "`pwd`/var/"
51 ```
52 You should see the context you modified on the files, the app is able to function now. This is a permanent change, it sticks (reloads) even after a restart.
53
54 ### Run
55 The .env by default is in debug mode, so if something goes sideways, you should be able to see it.
56
57 #### Locally
58 Fire up this baby:
3f95d8 59 ```
60 symfony server:start
61 ```
e3c536 62
63 ### Deploy
3f95d8 64 Only God knows what you are using (Apache, Nginx, Windows Server), you can configure as a normal symfony project: https://symfony.com/doc/current/setup/web_server_configuration.html
65
66 ## Testing
67
68 ### Installing dev libraries
69 If you followed point-by-point your version of the project does not contains dev libraries, you have to install it: 
70 ```
71 composer install
72 ```
73 And get the tests running:
74 ```
75 php bin/phpunit
76 ```
77 Probably you will get some errors, most likely the recent removal of monolog from default Symfony install.
78 My only option would be to mask up, but I prefer not to: https://github.com/liip/LiipTestFixturesBundle/issues/135
79
80 ### Questions
81 Are welcome @ (vfiber@gmail.com)[mailto:vfiber@gmail.com] / (adam.fibinger@gmail.com)[mailto:adam.fibinger@gmail.com]