Skip to content

Commit

Permalink
Merge pull request #73 from EmakinaFR/feature/compose
Browse files Browse the repository at this point in the history
  • Loading branch information
duboiss committed Nov 19, 2021
2 parents 9048790 + e107157 commit b9bf007
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
11 changes: 2 additions & 9 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@ BLACKFIRE_SERVER_TOKEN=
#BLACKFIRE_CLIENT_ID=
#BLACKFIRE_CLIENT_TOKEN=

##### Elasticsearch
http.host=0.0.0.0
transport.host=127.0.0.1
xpack.security.enabled=false
ES_JAVA_OPTS=-Xms256m -Xmx256m

##### MySQL
MYSQL_ALLOW_EMPTY_PASSWORD=1
MYSQL_ROOT_PASSWORD=
MYSQL_USER=
MYSQL_PASSWORD=
MYSQL_DATABASE=

##### Nginx

##### PHP / XDEBUG
PHP_IDE_CONFIG=serverName=proximis
XDEBUG_CONFIG=remote_host=host.docker.internal idekey=PHPSTORM remote_port=9001 remote_enable=1 remote_connect_back=0
XDEBUG_CONFIG="client_host=host.docker.internal idekey=PHPSTORM client_port=9001"
XDEBUG_MODE=debug
32 changes: 16 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This Makefile can be extended by another Makefile located in your project directory.

SHELL := /bin/bash
PHP_SERVICE := docker-compose exec -u www-data:www-data php sh -c
PHP_SERVICE := docker compose exec -u www-data:www-data php sh -c

# Define a static project name that will be prepended to each service name
export COMPOSE_PROJECT_NAME := $(shell echo proximis_$(subst .,,$(notdir $(PWD))) | tr '[:upper:]' '[:lower:]')
Expand All @@ -18,57 +18,57 @@ export PROJECT_LOCATION := $(shell echo ${MAKEFILE_DIRECTORY})

env-backup: ## Backup the "mysql" volume
docker run --rm \
--volumes-from $$(docker-compose ps -q mysql) \
--volumes-from $$(docker compose ps -q mysql) \
--volume $$(pwd):/backup \
busybox sh -c "tar cvf /backup/backup.tar /var/lib/mysql"

env-build: ## Build the environment
docker-compose build --pull
docker compose build --pull

env-cache: ## Flush cache in Redis
docker-compose exec redis sh -c "redis-cli FLUSHALL"
docker compose exec redis sh -c "redis-cli FLUSHALL"

env-logs: ## Follow logs generated by all containers
docker-compose logs -f --tail=0
docker compose logs -f --tail=0

env-logs-full: ## Follow logs generated by all containers from the containers creation
docker-compose logs -f
docker compose logs -f

env-mysql: ## Open a terminal in the "mysql" container
docker-compose exec mysql sh
docker compose exec mysql sh

env-nginx: ## Open a terminal in the "nginx" container
docker-compose exec -u nginx:nginx nginx sh -l
docker compose exec -u nginx:nginx nginx sh -l

env-php: ## Open a terminal in the "php" container
docker-compose exec -u www-data:www-data php bash -l -c "source ./project.sh use && /bin/bash"
docker compose exec -u www-data:www-data php bash -l -c "source ./project.sh use && /bin/bash"

env-phpl: ## Open a terminal in the "php" container and prompt source locale
@read -p "Enter locale: " locale; \
docker-compose exec -u www-data:www-data php bash -l -c "source ./project.sh use $$locale && /bin/bash"
docker compose exec -u www-data:www-data php bash -l -c "source ./project.sh use $$locale && /bin/bash"

source: ## Set source with given locale
@read -p "Enter locale: " locale; \
source ./project.sh use $$locale

env-ps: ## List all containers managed by the environment
docker-compose ps
docker compose ps

env-purge: ## Purge all services and associated volumes
docker-compose down -v
docker compose down -v
mutagen sync terminate --label-selector='name==${COMPOSE_PROJECT_NAME}'

env-restart: env-stop env-start ## Restart the environment

env-restore: ## Restore the "mysql" volume
docker run --rm \
--volumes-from $$(docker-compose ps -q mysql) \
--volumes-from $$(docker compose ps -q mysql) \
--volume $$(pwd):/backup \
busybox sh -c "tar xvf /backup/backup.tar var/lib/mysql/"
docker-compose restart mysql
docker compose restart mysql

env-start: ## Start the environment
@docker-compose up --detach --remove-orphans
@docker compose up --detach --remove-orphans

@if [[ ! "$$(mutagen sync list --label-selector='name==${COMPOSE_PROJECT_NAME}')" =~ "${COMPOSE_PROJECT_NAME}" ]]; then \
mutagen sync create \
Expand All @@ -91,7 +91,7 @@ env-stats: ## Print real-time statistics about containers ressources usage
docker stats $(docker ps --format={{.Names}})

env-stop: ## Stop the environment
@docker-compose stop
@docker compose stop
@mutagen sync pause --label-selector='name==${COMPOSE_PROJECT_NAME}'

.PHONY: env-backup env-build env-cache env-logs env-logs env-mysql env-nginx env-php env-ps env-purge env-restart env-restore env-start env-stats env-stop
Expand Down
15 changes: 10 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ services:
build:
context: ./elasticsearch
env_file: ${PROJECT_LOCATION}/docker/local/.env
environment:
- http.host=0.0.0.0
- transport.host=127.0.0.1
- xpack.security.enabled=false
- ES_JAVA_OPTS=-Xms256m -Xmx256m
ports:
- 9200:9200
- 9300:9300
- "9200:9200"
- "9300:9300"
ulimits:
memlock:
soft: -1
Expand All @@ -36,7 +41,7 @@ services:
image: mariadb:latest
env_file: ${PROJECT_LOCATION}/docker/local/.env
ports:
- 3306:3306
- "3306:3306"
volumes:
- mysql:/var/lib/mysql
tty: true
Expand All @@ -46,7 +51,7 @@ services:
context: ./nginx
env_file: ${PROJECT_LOCATION}/docker/local/.env
ports:
- 443:443
- "443:443"
volumes:
# Projects files
- code_sync:/var/www/html:nocopy
Expand Down Expand Up @@ -83,7 +88,7 @@ services:
context: ./redis
env_file: ${PROJECT_LOCATION}/docker/local/.env
ports:
- 6379:6379
- "6379:6379"
volumes:
- redis:/data
tty: true
Expand Down

0 comments on commit b9bf007

Please sign in to comment.