Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-set shm size based on host available ram #342

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ DB_DATA_DIR=../.cache
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWD=1234567890
SHM_SIZE=64m
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ LOCAL_GID := $(shell id -g)
CUID ?= $(LOCAL_UID)
CGID ?= $(LOCAL_GID)

# Define shm size based on total ram on host ([Total ram on host, in kilobytes] / 4)
SHM_SIZE = $(shell expr $(shell cat /proc/meminfo | head -1 | awk '{print $$2}') \* 256)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs testing on Macos

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# Define network name.
COMPOSE_NET_NAME := $(COMPOSE_PROJECT_NAME)_front

Expand Down Expand Up @@ -50,6 +53,7 @@ allfast: | fast provision back front si localize hooksymlink info

## Update .env to build DB in ram (makes data NOT persistant)
fast:
$(shell sed -i "s|^SHM_SIZE=64m|SHM_SIZE=$(SHM_SIZE)|g" .env)
$(shell sed -i "s|^#DB_URL=sqlite:///dev/shm/d8.sqlite|DB_URL=sqlite:///dev/shm/d8.sqlite|g" .env)
$(shell sed -i "s|^DB_URL=sqlite:./../.cache/d8.sqlite|#DB_URL=sqlite:./../.cache/d8.sqlite|g" .env)

Expand Down
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,30 @@

#### Used variables

| Variable name | Description | Default value |
| --------------- | ----------------------- | ------------- |
| COMPOSE_FILE | Path to a Compose file(s) | `./docker/docker-compose.yml:./docker/docker-compose.override.yml` |
| COMPOSE_PROJECT_NAME | Your project name | - |
| PROFILE_NAME | Profile used for site install | sdd |
| MODULES | Additional modules to enable after site install | project_default_content |
| THEME_NAME | Name of theme directory in /web/themes | `NA` |
| SITE_NAME | Site name | Example |
| SITE_MAIL | Site e-mail address | [email protected] |
| ADMIN_NAME | Admin username | admin |
| ADMIN_PW | Admin password | admin |
| ADMIN_MAIL | Admin e-mail address | [email protected] |
| PROJECT_INSTALL | Way to install site - from straight or existing config | - |
| IMAGE_PHP | Php image to use | `skilldlabs/php:72-fpm` |
| IMAGE_NGINX | Image to use for nginx container | `skilldlabs/nginx:1.14.1` |
| IMAGE_APACHE | Image to use for apache container | `skilldlabs/skilld-docker-apache` |
| IMAGE_FRONT | Image to use for front tasks | `skilldlabs/frontend:zen` |
| IMAGE_DRIVER | Image to use for automated testing webdriver | `zenika/alpine-chrome` |
| ADD_PHP_EXT | Additional php extension to install | - |
| MAIN_DOMAIN_NAME | Domain name used for traefik | `docker.localhost` |
| DB_URL | Url to connect to database | `sqlite:///dev/shm/d8.sqlite` |
| DB_DATA_DIR | Full path to database storage | `/dev/shm` |
| CLEAR_FRONT_PACKAGES | Set it to `no` to keep `/node_nodules` directory in theme after `make front` task to save build time. | yes |
| Variable name | Description | Default value |
| --------------- | ----------------------- | ------------- |
| COMPOSE_FILE | Path to a Compose file(s) | `./docker/docker-compose.yml:./docker/docker-compose.override.yml` |
| COMPOSE_PROJECT_NAME | Your project name | - |
| PROFILE_NAME | Profile used for site install | sdd |
| MODULES | Additional modules to enable after site install | project_default_content |
| THEME_NAME | Name of theme directory in /web/themes | `NA` |
| SITE_NAME | Site name | Example |
| SITE_MAIL | Site e-mail address | [email protected] |
| ADMIN_NAME | Admin username | admin |
| ADMIN_PW | Admin password | admin |
| ADMIN_MAIL | Admin e-mail address | [email protected] |
| PROJECT_INSTALL | Way to install site - from straight or existing config | - |
| IMAGE_PHP | Php image to use | `skilldlabs/php:72-fpm` |
| IMAGE_NGINX | Image to use for nginx container | `skilldlabs/nginx:1.14.1` |
| IMAGE_APACHE | Image to use for apache container | `skilldlabs/skilld-docker-apache` |
| IMAGE_FRONT | Image to use for front tasks | `skilldlabs/frontend:zen` |
| IMAGE_DRIVER | Image to use for automated testing webdriver | `zenika/alpine-chrome` |
| ADD_PHP_EXT | Additional php extension to install | - |
| MAIN_DOMAIN_NAME | Domain name used for traefik | `docker.localhost` |
| DB_URL | Url to connect to database | `sqlite:///dev/shm/d8.sqlite` |
| DB_DATA_DIR | Full path to database storage | `/dev/shm` |
| CLEAR_FRONT_PACKAGES | Set it to `no` to keep `/node_nodules` directory in theme after `make front` task to save build time. | yes |
| SHM_SIZE | Defines php container shm_size, used when building in "fast" mode. | `total host ram / 4` when fast is used, otherwise defaults to 64m |

#### Persistent Mysql

Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.override.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ services:
# NEW_RELIC_APPNAME: "${COMPOSE_PROJECT_NAME}"
volumes:
- "./90-mail.ini:/etc/php7/conf.d/90-mail.ini:z"
shm_size: "${SHM_SIZE}"
andypost marked this conversation as resolved.
Show resolved Hide resolved
# depends_on:
# - mysql
# - postgresql
Expand Down