README.md 3.29 KB
Newer Older
Jacob Priddy's avatar
Jacob Priddy committed
1 2
# Doorcode

3 4
The new doorcode system repository.

Jacob Priddy's avatar
Jacob Priddy committed
5 6 7 8 9
## Running Code Coverage
Code coverage is best generated with phpdbg as it is very fast. Inside the docker
container in the `backend` directory, run the command `phpdbg -qrr vendor/bin/phpunit --coverage-html cov`.
Visit the backend/cov/index.html file in a browser to see the report.

10 11 12 13 14 15 16

## Web Development Installation Instructions
#### Requirements
Installing the requirements is operating system dependent and is left as an exercise for the reader.
 - docker
 - docker-compose
 
17
#### Frontend and Backend Common Instructions
18 19 20
1. First, copy the [docker-compose.yml.example](docker-compose.yml.example) to [docker-compose.yml](docker-compose.yml).
Change any needed ports to not conflict with any currently running services.
If you know you won't have any conflicts, you can use all the defaults in the .example file.
21 22
If you did make changes to the [docker-compose.yml](docker-compose.yml) file, make sure those changes
are also reflected in the .env file that is created in step 3.
23

24 25
1. Generate secrets by running the shell scripts located in the `secrets` folder. `./gen-certs.sh && ./gen-webserver.sh`

26
1. Spin up the docker containers with the docker compose command `docker-compose up -d`. It will take a while the
27 28 29
first time around as the containers need to be built. Anytime they are launched after they have been built will be
very quick.

30 31 32 33 34 35
1. You must then launch the install script to setup the front and back end. This can be done with the command
`docker-compose exec api ./install-dev.sh`. This will install PHP and JS dependencies and perform any other
necessary operations.

### API Specific Development Installation
The backend api should now be installed and running on [http://localhost:8080/api/](http://localhost:8080/api/)
36 37 38 39
(The trailing slash is important because otherwise nginx running in the docker container won't redirect the port 
correctly because the docker contianer port and the host port it's mapped to are different. So you will end up at 
`http://localhost/api`)

40 41
### Frontend Specific Development Installation
It is currently just static files, so assuming the docker containers are running, just visit
42 43 44 45
[http://localhost:8080](http://localhost:8080)

## Docker usage
### Current Structure
46
The current structure can be seen in the [docker-compose.yml](docker-compose.yml). The containers are as follows:
47 48
 - webserver: This container holds the nginx server that serves up the webserver files to your local machine. It is
 bound to your local port 8080. It maps the backend to /api/ and the frontend to /
49
 - db: This container holds a PostgreSQL database for backend usage to store data.
50
 - dbadmin: This is a phpPGgAdmin interface for the PostgreSQL database. It is running on port 8081
51
 [http://localhost:8081](http://localhost:8081)
52 53
 - api: This container holds a php-fpm server that processes all backend php files.
 
54 55 56 57 58 59 60
### Common/Useful Commands
 - Bring up containers with `docker-compose up -d`
 - Restart containers with `docker-compose restart [container]`
 - Kill a container with `docker-compose down [container]`
 - You can rebuild a single container with `docker-compose build --no-cache [container1] [container2...]`
 - You can completely rebuild everything if you mess something up with the command
`docker-compose down -v --rmi all --remove-orphans && docker-compose up -d`