Skip to content

Commit

Permalink
Merge pull request #120 from sharmaamitt16/starterkit-optimization
Browse files Browse the repository at this point in the history
Checkin Mailhog in all staarterkits and changed the dependency of chown service.
  • Loading branch information
AshishThakur authored Jul 22, 2020
2 parents 39fb388 + 2c94443 commit 2b98506
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 61 deletions.
14 changes: 12 additions & 2 deletions starterkits/drupal8-php-fpm-apache/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ are documented in the table below.
| Project name | .env | PROJECT_NAME | drupal8 |

---
**NOTE**

## NOTE:
Due to an issue as of now PHP_VERSION has to be updated in Tiltfile as well.
---

Expand Down Expand Up @@ -81,6 +80,17 @@ recommended alias:
alias ddrush="docker-compose run --rm drupal drush"
```
---
## NOTE:
```
Problem:
On Linux OS, during composer install cli service throws
a permission denied error while installing dependencies.
Solution:
Run the cli service with root user and run chown service after to change the ownership.
This will prevent the error throws during the composer install.
```
---

## Profiling
All the starterkits in vega are shipped with blackfire for code profiling. This is also available on
Expand Down
6 changes: 3 additions & 3 deletions starterkits/drupal8-php-fpm-apache/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ services:
command:
- "chown -R continua:continua /app"
user: root
depends_on:
- cli
volumes: *app-volumes

cli:
image: "srijanlabs/php-cli:${PHP_VERSION}-10"
container_name: ${PROJECT_NAME}_cli
command: ["composer", "install", "--no-dev", "--prefer-dist", "--no-progress", "--no-suggest", "--no-interaction", "--optimize-autoloader"]
user: continua
user: user
working_dir: /app
depends_on:
- chown
volumes: *cli-volumes
networks: *app-networks
env_file: *app-envsfile
Expand Down
24 changes: 24 additions & 0 deletions starterkits/drupal8-php-fpm-nginx/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
| PHP version | .env | PHP_VERSION | 7.3 |
| Project name | .env | PROJECT_NAME | drupal8 |

---
## NOTE:
Due to an issue as of now PHP_VERSION has to be updated in Tiltfile as well.
---

### Configuring Runtime:

##### These values can be configure using [.env](.env) file
Expand Down Expand Up @@ -68,6 +73,18 @@ recommended alias:
alias ddrush="docker-compose run --rm php drush"
```
---
## NOTE:
```
Problem:
On Linux OS, during composer install cli service throws
a permission denied error while installing dependencies.
Solution:
Run the cli service with root user and run chown service after to change the ownership.
This will prevent the error throws during the composer install.
```
---

### Profiling:
- Get your blackfire server id and token from https://blackfire.io/my/settings/credentials
- Configure the blackfire server id and token in .env file.
Expand All @@ -87,3 +104,10 @@ alias ddrush="docker-compose run --rm php drush"

Please follow the document to setup xdebug:
[Setup Xdebug](/starterkits/XDEBUG-SETUP.md)

## Mailhog

This starterkit ships with mailhog which can be accessed at localhost:8025. This can be a handy feature
to test email functionality on local systems without worrying about sending mails accidently to real users.
Mailhog is only available on dev images which are used for local development and not available on production
images.
8 changes: 6 additions & 2 deletions starterkits/drupal8-php-fpm-nginx/Tiltfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- mode: Python -*-

docker_compose('docker-compose.yml')
php_version = str(local('source .env && echo $PHP_VERSION')).strip()
# php_version = str(local('source .env && echo $PHP_VERSION')).strip(). @TODO: This does not
# work on some systems, hence for workaround php_version is hardcoded.
# Change this in case you want to use someother version of php(supported: 7.2, 7.3 & .7.4).
# Please ensure to change PHP_VERSION in .env file as well.
php_version = "7.3"
docker_build('srijanlabs/php-fpm-nginx:' + php_version + '-10-local', '.',
build_arg={'PHP_VERSION': php_version},
build_args={'PHP_VERSION': php_version},
dockerfile='Dockerfile.dev',
live_update = [
sync('.', '/app'),
Expand Down
34 changes: 19 additions & 15 deletions starterkits/drupal8-php-fpm-nginx/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#========================================= Drupal 8 StarterKit =============================================#
# Drupal 8 + Nginx StarterKit with nginx.
version: '3.5'
#____________________________________________ Named Volumes ________________________________________________#

volumes:
app:
driver: local
Expand All @@ -13,11 +13,11 @@ volumes:
# core: # drupal core
# vendor: # php modules
files: # files
#______________________________________________ Networks ___________________________________________________#

networks:
default:
name: vega-${PROJECT_NAME}
#___________________________________________ YAML extensions _______________________________________________#

x-app-volumes: &app-volumes
- files:${DOC_ROOT}/sites/default/files:delegated
# - ./:/app:cached
Expand All @@ -34,9 +34,7 @@ x-app-envsfile: &app-envsfile .env
x-app-networks: &app-networks
- default

#_______________________________________________ Services __________________________________________________#
services:
#----------------------------- permission setter ------------------------------------#
# Change mounted named volumes user from root(default) to continua.
chown:
image: "srijanlabs/php-cli:${PHP_VERSION}-10"
Expand All @@ -45,22 +43,22 @@ services:
command:
- "chown -R continua:continua /app"
user: root
depends_on:
- cli
volumes: *app-volumes
#---------------------------------- php cli -----------------------------------------#

cli:
image: "srijanlabs/php-cli:${PHP_VERSION}-10"
container_name: ${PROJECT_NAME}_cli
command: ["composer", "install", "--no-dev", "--prefer-dist", "--no-progress", "--no-suggest", "--no-interaction", "--optimize-autoloader"]
user: continua
user: root
working_dir: /app
depends_on:
- chown
volumes: *cli-volumes
networks: *app-networks
env_file: *app-envsfile
environment:
- COMPOSER_MEMORY_LIMIT=-1 # Prevent composer from running out of memory
#---------------------------------- php-fpm -----------------------------------------#

php:
image: srijanlabs/php-fpm-nginx:${PHP_VERSION}-10-local
build:
Expand All @@ -76,7 +74,7 @@ services:
volumes: *app-volumes
networks: *app-networks
env_file: *app-envsfile
#---------------------------------- nginx ------------------------------------------#

nginx:
image: srijanlabs/php-fpm-nginx:${PHP_VERSION}-10-local
container_name: ${PROJECT_NAME}_nginx
Expand All @@ -88,7 +86,7 @@ services:
volumes: *app-volumes
networks: *app-networks
env_file: *app-envsfile
#------------------------------- database (mysql) -----------------------------------#

mysql:
image: mysql:5.7
container_name: ${PROJECT_NAME}_mysql
Expand All @@ -102,7 +100,13 @@ services:
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
networks: *app-networks
#------------------------------- blackfire -----------------------------------#

mailhog:
image: mailhog/mailhog
ports:
- "1025:1025"
- "8025:8025"

# blackfire:
# image: blackfire/blackfire
# container_name: ${PROJECT_NAME}_blackfire
Expand All @@ -113,4 +117,4 @@ services:
# BLACKFIRE_SERVER_ID: ${BLACKFIRE_SERVER_ID}
# BLACKFIRE_SERVER_TOKEN: ${BLACKFIRE_SERVER_TOKEN}
# networks: *app-networks
#===========================================================================================================#

29 changes: 27 additions & 2 deletions starterkits/drupal9-php-fpm-apache/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
| PHP version | .env | PHP_VERSION | 7.3 |
| Project name | .env | PROJECT_NAME | drupal9 |

---
## NOTE:
Due to an issue as of now PHP_VERSION has to be updated in Tiltfile as well.
---

### Configuring Runtime:

##### These values can be configure using [.env](.env) file
Expand Down Expand Up @@ -61,13 +66,26 @@ alias dcomposer="docker-compose run --rm cli composer"
---
### Running drush commands:
```bash
docker-compose run --rm php drush cr
docker-compose run --rm drupal drush cr
```
recommended alias:
```bash
alias ddrush="docker-compose run --rm php drush"
alias ddrush="docker-compose run --rm drupal drush"
```
---

## NOTE:
```
Problem:
On Linux OS, during composer install cli service throws
a permission denied error while installing dependencies.
Solution:
Run the cli service with root user and run chown service after to change the ownership.
This will prevent the error throws during the composer install.
```
---

### Profiling:
- Get your blackfire server id and token from https://blackfire.io/my/settings/credentials
- Configure the blackfire server id and token in .env file.
Expand All @@ -88,3 +106,10 @@ alias ddrush="docker-compose run --rm php drush"

Please follow the document to setup xdebug:
[Setup Xdebug](/starterkits/XDEBUG-SETUP.md)

## Mailhog

This starterkit ships with mailhog which can be accessed at localhost:8025. This can be a handy feature
to test email functionality on local systems without worrying about sending mails accidently to real users.
Mailhog is only available on dev images which are used for local development and not available on production
images.
8 changes: 6 additions & 2 deletions starterkits/drupal9-php-fpm-apache/Tiltfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# -*- mode: Python -*-

docker_compose('docker-compose.yml')
php_version = str(local('source .env && echo $PHP_VERSION')).strip()
# php_version = str(local('source .env && echo $PHP_VERSION')).strip(). @TODO: This does not
# work on some systems, hence for workaround php_version is hardcoded.
# Change this in case you want to use someother version of php(supported: 7.2, 7.3 & .7.4).
# Please ensure to change PHP_VERSION in .env file as well.
php_version = "7.3"
docker_build('srijanlabs/php-fpm-apache:' + php_version + '-10-local', '.',
build_arg={'PHP_VERSION': php_version},
build_args={'PHP_VERSION': php_version},
dockerfile='Dockerfile.dev',
live_update = [
sync('.', '/app'),
Expand Down
31 changes: 17 additions & 14 deletions starterkits/drupal9-php-fpm-apache/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#========================================= Drupal 9 StarterKit =============================================#
# Drupal 9 StarterKit with Nginx.
version: '3.5'
#____________________________________________ Named Volumes ________________________________________________#

volumes:
app:
driver: local
Expand All @@ -13,11 +13,11 @@ volumes:
# core: # drupal core
# vendor: # php modules
files: # files
#______________________________________________ Networks ___________________________________________________#

networks:
default:
name: vega-${PROJECT_NAME}
#___________________________________________ YAML extensions _______________________________________________#

x-app-volumes: &app-volumes
- files:${DOC_ROOT}/sites/default/files:delegated
# - ./:/app:cached
Expand All @@ -34,9 +34,7 @@ x-app-envsfile: &app-envsfile .env
x-app-networks: &app-networks
- default

#_______________________________________________ Services __________________________________________________#
services:
#----------------------------- permission setter ------------------------------------#
# Change mounted named volumes user from root(default) to continua.
chown:
image: "srijanlabs/php-cli:${PHP_VERSION}-10"
Expand All @@ -45,22 +43,22 @@ services:
command:
- "chown -R continua:continua /app"
user: root
depends_on:
- cli
volumes: *app-volumes
#---------------------------------- php cli -----------------------------------------#

cli:
image: "srijanlabs/php-cli:${PHP_VERSION}-10"
container_name: ${PROJECT_NAME}_cli
command: ["composer", "install", "--no-dev", "--prefer-dist", "--no-progress", "--no-suggest", "--no-interaction", "--optimize-autoloader"]
user: continua
user: root
working_dir: /app
depends_on:
- chown
volumes: *cli-volumes
networks: *app-networks
env_file: *app-envsfile
environment:
- COMPOSER_MEMORY_LIMIT=-1 # Prevent composer from running out of memory
#---------------------------------- drupal ------------------------------------------#

drupal:
image: srijanlabs/php-fpm-apache:${PHP_VERSION}-10-local
build:
Expand All @@ -76,7 +74,7 @@ services:
volumes: *app-volumes
networks: *app-networks
env_file: *app-envsfile
#------------------------------- database (mysql) -----------------------------------#

mysql:
image: mysql:5.7
container_name: ${PROJECT_NAME}_mysql
Expand All @@ -90,7 +88,13 @@ services:
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
networks: *app-networks
#------------------------------- blackfire -----------------------------------#

mailhog:
image: mailhog/mailhog
ports:
- "1025:1025"
- "8025:8025"

# blackfire:
# image: blackfire/blackfire
# container_name: ${PROJECT_NAME}_blackfire
Expand All @@ -101,4 +105,3 @@ services:
# BLACKFIRE_SERVER_ID: ${BLACKFIRE_SERVER_ID}
# BLACKFIRE_SERVER_TOKEN: ${BLACKFIRE_SERVER_TOKEN}
# networks: *app-networks
#===========================================================================================================#
Loading

0 comments on commit 2b98506

Please sign in to comment.