diff --git a/README.md b/README.md index 2d691a1..20560f1 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ ## Set Up Procedure > **Note:** -> In this structure, we always need to add few flags for our commands to work. -> --env-file flag then the path to the environment config we want to load. -> -f flag then the path to the docker compose yaml file. -> which in our case it is -> - `--env-file docker/environments/local.env` +> In this structure, we always need to add few flags for our commands to work. +> - --env-file flag then the path to the environment config we want to load. +> - -f flag then the path to the docker compose yaml file. +> which in our case it is: +> - `--env-file docker/environments/config.env` > - `-f docker/docker-compose.yml` > > _See: `docker/docker-compose.yml` for the list of service containers_ @@ -31,36 +31,40 @@ ### Step 0: Environment File Config Note: _This will soon be updated and improved to support multi-environment set up and load the correct file automatically -So for now, its just_ `local.env`. To set up your configs and credentials for this file. -_see:_ `docker/environment/local.env`. Take note that some values in this file will be use later on by laravel `.env` file. +So for now, its just_ `local.env`. +- _see:_ `docker/environments/local.env` to set up your configs and credentials for this file + - Take note that some values in this file will be use later on by laravel `.env` and our `config.env` file. + +The generic `.env` file `config.env` should be always be use in the command and use the variable `SYS_ENV` to set the specific environment file configuration. +- _see:_ `docker/environments/config.env` ### Step 1: Service containers - Building and Starting ``` // Building the services/containers -> docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml build +> docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml build // Starting the services/containers // - optionally add the -d (detach) flag to run in the background -> docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml up -d +> docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml up -d // Or do a one-liner command for the build and start process -> docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml up -d --build +> docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml up -d --build ``` ### Step 2 - A: Packages and Dependencies > **_Note:_** for a specific service, use the container name > **_Format:_** docker-compose --env-file <_EnvFile_> -f <_DockerComposeYamlFile_> up <_ContainerName_> -> **_E.g.:_** `docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml up php` +> **_E.g.:_** `docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml up php` > ``` // Running composer install -> docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml run --rm composer install +> docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml run --rm composer install // Running artisan migrate -> docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml run --rm artisan migrate +> docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml run --rm artisan migrate // Running npm -> docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml run --rm npm install +> docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml run --rm npm install ``` ### Step 2 - B: Importing existing database data diff --git a/docker/README.md b/docker/README.md index 91eec21..8063f9c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -12,7 +12,7 @@ > --env-file flag then the path to the environment config we want to load. > -f flag then the path to the docker compose yaml file. > which in our case it is -> - `--env-file docker/environments/local.env` +> - `--env-file docker/environments/config.env` > - `-f docker/docker-compose.yml` > > _See: `docker/docker-compose.yml` for the list of service containers_ @@ -47,27 +47,27 @@ docker system prune -a ### Building the service containers ``` // Build the services/containers -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml build +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml build ``` ### Starting the service ``` -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml up +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml up // add the -d (detach) option to run in the background -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml up -d +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml up -d // Can also do a one-liner build and start -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml up -d --build +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml up -d --build // use the container name for a specific service // docker-compose up <_ContainerName_> -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml up php +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml up php ``` ### Stopping the service ``` -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml down -v +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml down -v // -v, --volumes Remove named volumes declared in the `volumes` // section of the Compose file and anonymous volumes @@ -75,15 +75,15 @@ docker-compose --env-file docker/environments/local.env -f docker/docker-compose // to stop a specific service, use the stop command followed by th container name // docker-compose stop <_ContainerName_> -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml stop mysql +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml stop mysql ``` ### Restarting the service ``` -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml restart +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml restart // use the container name for a specific service -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml restart php +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml restart php ``` ### Running commands inside a service container @@ -98,13 +98,13 @@ docker-compose --env-file docker/environments/local.env -f docker/docker-compose // Note: we still need to use -f flag and the path to our docker compose yamel file // Running composer -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml run --rm composer dump-autoload +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml run --rm composer dump-autoload // Running npm -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml run --rm npm install +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml run --rm npm install // Running artisan command -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml run --rm artisan migrate +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml run --rm artisan migrate ``` ### Running arbitrary commands inside a service container (OLD/DEPRECATED) @@ -115,10 +115,10 @@ docker-compose --env-file docker/environments/local.env -f docker/docker-compose // Use docker-compose exec to run command inside the container. // - e.g.: To run php artisan migrate commad // - format: docker-compose exec <_ContainerName_> php <_PathToArtisan_> migrate -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml exec php php /var/www/html/artisan migrate +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml exec php php /var/www/html/artisan migrate // Check if index.php exists -docker-compose --env-file docker/environments/local.env -f docker/docker-compose.yml exec nginx ls /var/www/html/public +docker-compose --env-file docker/environments/config.env -f docker/docker-compose.yml exec nginx ls /var/www/html/public ``` ### Importing existing database data