HovedprosjektWebApp/.docker
2020-04-02 16:23:48 +02:00
..
examples [Docker] Fix issues with PostgreSQL and move docker-compose file to root 2020-04-02 16:09:19 +02:00
nginx [Docker] Fix issues with PostgreSQL and move docker-compose file to root 2020-04-02 16:09:19 +02:00
Dockerfile [Docker] Fix issues with PostgreSQL and move docker-compose file to root 2020-04-02 16:09:19 +02:00
README.md [Docker] Final fixes in Docker setup README 2020-04-02 16:23:48 +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
    • 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.

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
    • 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

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", which was used as the initial template.