Skip to content

Commit

Permalink
init project
Browse files Browse the repository at this point in the history
  • Loading branch information
RomulusED69 committed Aug 18, 2021
1 parent f85b1b4 commit fddced8
Show file tree
Hide file tree
Showing 65 changed files with 3,738 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# manala-recipes
# manala-recipes
Manala recipes for EDRom.
50 changes: 50 additions & 0 deletions edrom.app-docker/.manala.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
manala:
description: EDRom - Generic application using Docker
template: .manala.yaml.tmpl
sync:
- .manala/
- docker-compose.yaml.tmpl
- php.ini.tmpl

system:
# @option {"label": "App name (in kebab-case)"}
# @schema {"type": "string"}
app_name: ~
# @schema {"type": ["string"], "pattern": "^[a-zA-Z]+/[a-zA-Z]+$"}
timezone: Etc/UTC
php:
# @schema {
# "items": {"type": "object",
# "additionalProperties": false,
# "properties": {
# "config": {"type": ["object", "string", "array"]}
# }
# }
# }
configs: []
mariadb:
# @option {"label": "MariaDB version"}
# @schema {"enum": [null, 10.5, 10.4, 10.3, 10.2, 10.1, "10.0"]}
version: ~
# @schema {"type": ["string", "null"]}
init: ~
mysql:
# @option {"label": "MySQL version"}
# @schema {"enum": [null, 5.7, 8, "8.0"]}
version: ~
# @schema {"type": ["string", "null"]}
init: ~
postgresql:
# @option {"label": "PostgreSQL version"}
# @schema {"enum": [null, 13, 12, 11, 10, 9.6]}
version: ~
redis:
# @option {"label": "Redis version"}
# @schema {"enum": [null, "*"]}
version: ~
# @schema {"type": ["object", "array"]}
config: { }
mongo:
# @option {"label": "MongoDB version"}
# @schema {"enum": [null, "3.6", "4"]}
version: ~
64 changes: 64 additions & 0 deletions edrom.app-docker/.manala.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{- with .Vars.system -}}

####################################################################
# !!! REMINDER !!! #
# Don't forget to run `manala up` each time you update this file ! #
####################################################################

manala:
recipe: edrom.app-docker
repository: https://github.com/RomulusED69/manala-recipes.git

##########
# System #
##########

system:
app_name: {{ .app_name | toYaml }}
timezone: Etc/UTC

php:
configs:
# XDebug
- config: |
; Comment/uncomment the following lines to disable/enable XDebug
;zend_extension=xdebug.so
;xdebug.remote_enable=1
;xdebug.remote_autostart=1

# App
- config: |
;App specific configuration

{{- if .mariadb.version }}
mariadb:
version: {{ .mariadb.version | toYaml }}
init: |
CREATE DATABASE IF NOT EXISTS `app_test`;
GRANT ALL ON `app_test`.* TO 'app'@'%';
{{- end }}

{{- if .mysql.version }}
mysql:
version: {{ .mysql.version | toYaml }}
init: |
CREATE DATABASE IF NOT EXISTS `app_test`;
GRANT ALL ON `app_test`.* TO 'app'@'%';
{{- end }}

{{- if .postgresql.version }}
postgresql:
version: {{ .postgresql.version | toYaml }}
{{- end }}

{{- if .redis.version }}
redis:
version: {{ .redis.version | toYaml }}
{{- end }}

{{- if .mongo.version }}
mongo:
version: {{ .mongo.version | toYaml }}
{{- end }}

{{- end }}
2 changes: 2 additions & 0 deletions edrom.app-docker/.manala/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.cache/
/.docker/
2 changes: 2 additions & 0 deletions edrom.app-docker/.manala/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.cache/
/.docker/
10 changes: 10 additions & 0 deletions edrom.app-docker/.manala/DOT_NOT_MANUALLY_EDIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
###############################################################
# !!! DO NOT DIRECTLY EDIT FILES IN THIS DIRECTORY !!! #
# #
# The files in this directory must not updated directly. #
# By doing this, you will lost ALL your modifications when #
# updating your .manala.yaml and running "manala up". #
# #
# If you really need to update those files, contribute to the #
# recipe or create one that will fill your requirements! #
###############################################################
121 changes: 121 additions & 0 deletions edrom.app-docker/.manala/Makefile.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{{- $has_postgresql := .Vars.system.postgresql.version -}}
{{- $has_mariadb := .Vars.system.mariadb.version -}}
{{- $has_mysql := .Vars.system.mysql.version -}}
{{- $has_redis := .Vars.system.redis.version -}}
{{- $has_mongo := .Vars.system.mongo.version -}}

# Relative root dir ("."|".."|"../.."|…)
_ROOT_DIR := $(patsubst ./%,%,$(patsubst %/.manala/Makefile,%,./$(filter %.manala/Makefile,$(MAKEFILE_LIST))))
# Is current dir root ? (""|"1")
_ROOT := $(if $(filter .,$(_ROOT_DIR)),1)
# Relative current dir ("."|"foo"|"foo/bar"|…)
_DIR := $(patsubst ./%,%,.$(patsubst $(realpath $(CURDIR)/$(_ROOT_DIR))%,%,$(CURDIR)))

include $(_ROOT_DIR)/.manala/make/text.mk
include $(_ROOT_DIR)/.manala/make/help.mk
include $(_ROOT_DIR)/.manala/make/os.mk
include $(_ROOT_DIR)/.manala/make/git.mk

.DEFAULT_GOAL := help

user := $(shell id -u)
group := $(shell id -g)

dc := USER_ID=$(user) GROUP_ID=$(group) docker-compose
symfony := symfony
php := $(symfony) php
composer := $(symfony) composer

HELP += $(call help_section, Environment)

HELP += $(call help,setup, Setup the development environment)
setup: setup-symfony
$(MAKE) up
$(setup)
@echo
@$(call message_success, The development environment has been successfully set up.)
@echo

HELP += $(call help,setup@integration, Setup the integration environment)
setup@integration: export APP_ENV=test
setup@integration: setup-symfony@integration
$(MAKE) _up
$(setup_integration)
@echo
@$(call message_success, The integration environment has been successfully set up.)
@echo

setup-symfony:
$(symfony) server:ca:install
$(symfony) proxy:start
$(MAKE) setup-domain

setup-symfony@integration:
$(symfony) server:ca:install

setup-domain:
$(symfony) proxy:domain:attach {{ .Vars.system.app_name }}

_up:
$(dc) up --detach
{{- if or ($has_postgresql) ($has_mariadb) ($has_mysql) }} database{{ end }}
{{- if $has_redis }} redis{{ end }}
{{- if $has_mongo }} mongo{{ end }}

{{ if or ($has_postgresql) ($has_mariadb) ($has_mysql) -}}
@$(call message_warning, Waiting for the database to be ready...)
@until docker inspect -f {{ "{{.State.Health.Status}}" }} `$(dc) ps -q database` | grep -q "healthy"; do \
$(call message_warning, Waiting...); \
sleep 1; \
done
@$(call message_success, The database is ready!)
{{- end }}

HELP += $(call help,up, Start the development environment)
up:
$(MAKE) _up
$(symfony) proxy:start
@echo
@$(call message_success, You can now run the Symfony server)
@echo

HELP += $(call help,halt, Stop the development environment)
halt:
$(dc) stop

HELP += $(call help,destroy, Destroy the development environment)
destroy: halt
$(dc) down --volumes
@echo
@$(call message_error, ALL CONTAINERS HAVE BEEN DESTROYED)
@echo

HELP += $(call help_section, Development tools)

{{- if $has_postgresql -}}
HELP += $(call help,run-phppgadmin, Start a PhpPgAdmin web interface)
run-phppgadmin:
$(dc) up --detach phppgadmin
@echo
@$(call message_success, You can now open http://`$(dc) port phppgadmin 8080` to access PhpPgAdmin)
@echo
{{- end }}

{{ if or ($has_mariadb) ($has_mysql) -}}
HELP += $(call help,run-phpmyadmin, Start a PhpMyAdmin web interface)
run-phpmyadmin:
$(dc) up --detach phpmyadmin
@echo
@$(call message_success, You can now open http://`$(dc) port phpmyadmin 80` to access PhpMyAdmin)
@echo
{{- end }}

{{ if $has_redis -}}
HELP += $(call help,run-phpredisadmin, Start a PhpRedisAdmin web interface)
run-phpredisadmin:
$(dc) up --detach phpredisadmin
@echo
@$(call message_success, You can now open http://`$(dc) port phpredisadmin 80` to access PhpRedisAdmin)
@echo{{- end }}

HELP += $(call help_section, Project)
7 changes: 7 additions & 0 deletions edrom.app-docker/.manala/init-db/01.sql.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- if .Vars.system.mariadb.init -}}
{{- .Vars.system.mariadb.init -}}
{{- end -}}

{{- if .Vars.system.mysql.init -}}
{{- .Vars.system.mysql.init -}}
{{- end -}}
30 changes: 30 additions & 0 deletions edrom.app-docker/.manala/make/git.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
########
# Diff #
########

# Returns the list of changed files for some given extensions and some given folders.
#
# @param $1 The file extensions of changed files
# @param $2 The relative folders to parse for changed files
#
# Examples:
#
# Example #1: list PHP and Javascript files changed in the src and test folders
#
# $(call git_diff, php js, src test)

define git_diff
$(shell \
for ext in $(if $(strip $(1)),$(strip $(1)),"") ; \
do \
for dir in $(if $(strip $(2)),$(strip $(2)),"") ; \
do \
git --no-pager diff --name-status "$$(git merge-base HEAD origin/master)" \
| grep "$${ext}\$$" \
| grep "\\s$${dir}" \
| grep -v '^D' \
| awk '{ print $$NF }' || true ; \
done ; \
done \
)
endef
42 changes: 42 additions & 0 deletions edrom.app-docker/.manala/make/help.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
########
# Help #
########

HELP = \
\nUsage: make [$(COLOR_INFO)target$(COLOR_RESET)] \
$(call help_section, Help) \
$(call help,help,This help)

define help_section
\n\n$(COLOR_COMMENT)$(strip $(1)):$(COLOR_RESET)
endef

define help
\n $(COLOR_INFO)$(1)$(COLOR_RESET) $(2)
endef

help:
@printf "$(HELP)$(HELP_SUFFIX)"
@awk ' \
/^[-a-zA-Z0-9_.@%\/]+:/ { \
hasMessage = match(lastLine, /^## (.*)/); \
if (hasMessage) { \
lines++; \
helpCommands[lines] = substr($$1, 0, index($$1, ":")); \
helpLenght = length(helpCommands[lines]); \
if (helpLenght > helpLenghtMax) { \
helpLenghtMax = helpLenght; \
} \
helpMessages[lines] = substr(lastLine, RSTART + 3, RLENGTH); \
} \
} \
{ lastLine = $$0 } \
END { \
for (i = 1; i <= lines; i++) { \
printf "\n $(COLOR_INFO)%-" helpLenghtMax "s$(COLOR_RESET) %s", helpCommands[i], helpMessages[i]; \
} \
} \
' $(MAKEFILE_LIST)
@printf "\n\n"

.PHONY: help
21 changes: 21 additions & 0 deletions edrom.app-docker/.manala/make/os.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
######
# Os #
######

# Os detection helpers.
#
# Examples:
#
# Example #1: conditions on linux
#
# echo $(if $(OS_LINUX),Running on Linux,*NOT* running on Linux)

ifeq ($(OS),Windows_NT)
OS = windows
else
OS = $(shell uname | tr '[:upper:]' '[:lower:]')
endif

OS_LINUX = $(if $(findstring $(OS),linux),1,)
OS_DARWIN = $(if $(findstring $(OS),darwin),1,)
OS_WINDOWS = $(if $(findstring $(OS),windows),1,)
Loading

0 comments on commit fddced8

Please sign in to comment.