Giter Site home page Giter Site logo

sfelix-martins / laradock-multiple-project Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 79 KB

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

License: MIT License

Python 100.00%
laradock laradock-multiple-project laradock-multiple-env multiple-environment multiple-projects laravel-environment laravel-docker docker-compose

laradock-multiple-project's Introduction

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

laradock-multiple-project's People

Contributors

sfelix-martins avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

gordan43dom

laradock-multiple-project's Issues

Create a help section

Create a way to check the command documentation and options.

A command should look like this:

./laradock --help

[1.x] Install script globally

I didn't have a good experience to up the env and access the workspace container with docker-compose exec --user=laradock workspace bash. I had to back to laradock root folder and execute the command.

I think that if install the script globally it can be execute from laradock root folder. E.g.:

cd ~/laradock
upenv my_site
docker-compose exec --user=laradock workspace bash

The Projects.yml file should be created in the laradock root folder.

WARNING A global installer will be required using brew, apt-get, etc.

An alternative is continue the same installation and usage flow and just add instructions to README.

[1.x] Create databases

Create databases like Laravel Homested.

On up command should create the databases, if not exists, from defined project.
An example from Projects.yml file:

site_1:
  env:
    - PHP_VERSION: 7.3
  services:
    - nginx
    - mysql
    - mailhog
  databases:
    - site_one
    - site_one_test

When up the project, check if the project definitions has databases, and create it if not exists.
If database already exists, no action will be required

[1.x] Create virtual host

Create virtual hosts mapping like Laravel Homested.

On up command should create the sites mapping according to Projects.yml definitions.
An example from Projects.yml file:

site_1:
  env:
    - PHP_VERSION: 7.3
  services:
    - nginx
    - mysql
    - mailhog
  site:
    - map: siteone.test
    - to: Desktop/projects/siteone/public

When up the project create the virtual host if no exists.

It should be able to handle with creation for different services:

  • Nginx
  • Apache
  • Caddy

Sometimes return error "ERROR: env_var_container_build.yml config file not found!" on up

Sometimes when run the command ./laradock up ${project} the following error message is returned:

ERROR: env_var_container_build.yml config file not found!

After run again, all works correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Try up a project: ./laradock up ${project}
  2. Sometimes you can see the error.

Expected behavior
The project should to up correctly.

Screenshots
Screen Shot 2019-11-24 at 11 00 21

Desktop (please complete the following information):

  • OS: MacOS Catalina
  • Version 10.15.1
  • Python Version 3.7.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.