Skip to content

Commit

Permalink
Merge pull request #31 from nspalo/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
nspalo authored Aug 11, 2022
2 parents 8e8c006 + caae912 commit 167192e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,52 @@

## 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_
### 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
Expand Down
30 changes: 15 additions & 15 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down Expand Up @@ -47,43 +47,43 @@ 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
// attached to containers.
// 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
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 167192e

Please sign in to comment.