HovedprosjektWebApp/.docker/README.md

47 lines
2.7 KiB
Markdown
Raw Normal View History

2020-04-02 15:38:38 +02:00
# Application download & Docker setup
## Requirements
- Docker
- Docker Compose CLI
- Git
- A text editor, like `nano`
## Project repository setup
1. Download the project repository via Git: `git clone https://git.alex.lol/FLOT/HovedprosjektWebApp.git /srv/FLOTWebApp`
2. Navigate to the repository directory: `cd /srv/FLOTWebApp`
3. Copy `.env.example` to `.env`. Leave the `.env` file as is for now.
4. Copy `docker-compose.example.yml` to `docker-compose.yml`.
5. Edit `docker-compose.yml` (with your text editor) and modify configuration/volumes to match your needs.
6. Edit `.env` and modify your database credentials to match the ones you set in `docker-compose.yml`
2020-04-02 15:38:38 +02:00
- `DB_HOST` (db) and `DB_PORT` (5432) can generally be left as is
7. Navigate to the `.docker` directory in the repository.
8. Copy `examples/hovedprosjekt.example.conf` to `nginx/hovedprosjekt.conf`.
9. Edit `nginx/hovedprosjekt.conf` and modify domain/TLS configuration to your needs.
- Make sure that the SSL certificate and key uses the path as the volume mapping in `docker-compose.yml`.
10. Go up one directory (`cd ..`) and run `docker-compose build app`
11. If built successfully, run `docker-compose up -d` to run all containers in "detached" mode.
2020-04-02 15:38:38 +02:00
## Application setup - First-time setup only
These steps should be run after you have run `docker-compose up -d`, as the containers need to be running.
1. Go to the project repository: `cd /srv/FLOTWebApp`
2. Make sure that the project repository has correct permissions for the user specified in `docker-compose.yml`
- `sudo chown -R 1000:1000 .` will set it to the user/group with ID "1000". You can see users and their IDs if you `cat /etc/passwd`.
3. Install Composer dependencies using: `docker-compose exec app composer install`
2020-04-02 15:38:38 +02:00
- Dependency installation might take a while, so be patient.
4. Run `docker-compose exec app php artisan key:generate` to generate an app key that's saved in `.env`
5. Finally, create the database tables with: `docker-compose exec app php artisan migrate`
6. [Optional] Add sample users and posts to the database tables: `docker-compose exec app php artisan db:seed`
2020-04-02 15:38:38 +02:00
## Logs [Optional]
You do not need to look at the logs, but if things aren't working, the logs might point you in the right direction:
> `docker-compose logs -f` will show the logs and display new entries while open.
### Special thanks
Special thanks to the DigitalOcean tutorial "[How To Containerize a Laravel Application for Development with Docker Compose on Ubuntu 18.04](https://www.digitalocean.com/community/tutorials/how-to-containerize-a-laravel-application-for-development-with-docker-compose-on-ubuntu-18-04)", which was used as the initial template.