Skip to content
This repository was archived by the owner on Sep 24, 2019. It is now read-only.

Development environment

Max van der Schee edited this page Dec 4, 2017 · 4 revisions

To make setting up a production server easier we use Docker to run a Laravel 5.4 project. This also makes it very easy for setting up a development environment. Even though Docker is quite complex, it is certainly worth the time you invest.

Setting up a development environment does mean that you do need knowledge about Docker, so be sure to look at the documentation here.

The take a look at the images written for this project:

Step 1

Download docker for your OS:

And follow the installation instructions.

Recommendation

For windows users upgrade to windows education to make use of Hyper-V.

Surfspot

Step 2

Find a great spot for your projects on your computer. Something like C:\gebruikers\<YOURNAME>\Documents\projects

Make a file called docker-compose.yml with in that directory and change the following example to reflect your situation.

Docker-compose example

version: '2'

services:

  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    restart: always
    ports:
      - "80:80"
    volumes:
      - "/etc/nginx/vhost.d"
      - "/usr/share/nginx/html"
      - "/var/run/docker.sock:/tmp/docker.sock:ro"

  database:
    image: mysql
    container_name: database
    environment:
      MYSQL_ROOT_PASSWORD: adminpassword
      MYSQL_DATABASE: statman
      MYSQL_USER: boy
      MYSQL_PASSWORD: boyz
    volumes:
      - \c\gebruikers\<YOURNAME>\Documents\projects\database:/var/lib/mysql

  statman:
    image: maxvanderschee/laravel:latest
    container_name: statman
    environment:
      VIRTUAL_HOST: statman.dev
      VIRTUAL_PROTO: http
    depends_on:
      - database
    volumes:
      - \c\gebruikers\<YOURNAME>\Documents\projects\statman:/var/www/app

networks:
  default:
    external:
      name: nginx-proxy

Now two things have to be done.

  • Clone the GitHub repository to your projects folder.
  • Change the Host file and add something like statman.dev 127.0.0.1 this needs to be the same as you declared as VIRTUAL_HOST

Step 3

Open a terminal (Mac) or power shell (Windows) and go to the projects folder.

Now type docker-compose up -d, this will start all containers defined in the compose file.

Wait until it you can type again in the terminal.

Type the following to enter the container docker exec -it <container_name> bash.

Now you are in the container and you can run your commands for Laravel like; php artisan install, php artisan migrate, etc.

To exit the container just type exit.

And if you are done with docker you can stop te containers with docker-compose stop.

Update Docker image

If you are already running the docker image and you just want to update the image use docker pull maxvanderschee/laravel.

Clone this wiki locally