Skip to content

CLI application to helps the use of multiple projects on Laradock.

License

Notifications You must be signed in to change notification settings

sfelix-martins/laradock-multiple-project

Repository files navigation

Laradock Multiple Project

CLI application to helps the use of multiple projects on Laradock.

Pre-requisites

Installation

Clone the project inside laradock project folder and access the cloned folder:

git clone https://github.com/sfelix-martins/laradock-multiple-project.git multiple-project
cd multiple-project

Install the project dependencies from requirements.txt:

python -m pip install --upgrade pip
pip install -r requirements.txt

Configuration

Copy the file Projects.yml.example to Projects.yml:

cp Projects.yml.example Projects.yml

Set your projects configs on Projects.yml file.

# Project name
laravel_project:
  # The containers that will be executed
  services:
    - nginx
    - mysql
    - mailhog
  # Environment vars that will override the `.env` vars from laradock
  env:
    - PHP_VERSION: 7.3
  # The server definitions to point domain to folder
  server:
    name: laravelproject.test
    root: Projects/laravel/laravelproject.test/public
    template: laravel

laravel_api:
  # The containers that will be executed
  services:
    - apache2
    - postgres
    - maildev
    - redis
  # Environment vars that will override the `.env` vars from laradock
  env:
    - PHP_VERSION: 7.3
  # The server definitions to point domain to folder
  server:
    name: laravel_api.test
    root: Projects/laravel/laravel_api.test/public

Services (Required)

The containers that will be executed. You must defined at least one service

Env (Optional)

Define the environment variables to each specific project. If no one variable was defined the default .env file from laradock will be used to up environment.

Server Definitions (Optional)

On server config section you must define the server name, root and template (Optional).

The name are the site domain.

The root are the folder that contains your site code.

The template are the example .conf.example file that will be used to create the server configs.

For the nginx services you can choose between laravel, symfony and default. The default template is laravel.

For apache2 and caddy exists just one template.

E.g.: If your folder structure look like this:

+ laradock
+ Projects
    + site-1
        + laravel-api # This folder contains a laravel API, for example

Your server definitions section for your project in Projects.yml file should look like:

server:
    name: laravelapi.test
    root: Projects/site-1/laravel-api/public

The caddy web server accepts too the https param. By the default the https value is False:

server:
    name: laravelapi.test
    root: Projects/site-1/laravel-api/public
    https: True

Don't forget put the domain in your hosts file:

127.0.0.1  laravelapi.test

IMPORTANT: To the server definitions works correctly, you must assert that:

  • Exists only one web server container in your services section. You must choose nginx, apache2 or caddy.
  • If your services section has no one web server container nothing will happens.

Usage

After configure your projects on Projects.yml file you can execute the script laradock passing the project name on first param:

./laradock up laravel_project

Wait the process finish and your laradock should be started with your chosen project definitions.

Call the exec command to access the workspace container:

./laradock exec laravel_project