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

Tricotage #84

Open
wants to merge 2 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
51 changes: 51 additions & 0 deletions .manala.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
####################################################################
# !!! REMINDER !!! #
# Don't forget to run `manala up` each time you update this file ! #
####################################################################

manala:
recipe: elao.app.docker

###########
# Project #
###########

project:
name: elao-tricot
ports_prefix: 126

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

system:
version: 11
nginx:
configs:
- template: nginx/gzip.j2
# App
- file: app.conf
config: |
server {
server_name ~.;
root /srv/app/public;
access_log /srv/log/nginx.access.log;
error_log /srv/log/nginx.error.log;
include conf.d/gzip;
}
nodejs:
version: 8
php:
version: 8.1
docker:
services:
app:
ports:
- 12600:8000

# ssh:
# client:
# config: |
# Host *.elao.run
# User app
# ForwardAgent yes
1 change: 1 addition & 0 deletions .manala/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.cache/
1 change: 1 addition & 0 deletions .manala/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.cache/
5 changes: 5 additions & 0 deletions .manala/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env groovy

stage('¯\\_(ツ)_/¯') {
echo 'Because testing is doubting...'
}
118 changes: 118 additions & 0 deletions .manala/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Relative root dir ("."|".."|"../.."|…)
_DIR := $(patsubst %/.,%,$(patsubst %.manala/..,%.,$(patsubst %Makefile,%..,$(lastword $(MAKEFILE_LIST)))))
# Is current dir root ? (""|"1")
_ROOT = $(if $(filter .,$(_DIR)),1)
# Relative current dir ("."|"foo"|"foo/bar"|…)
_CURRENT_DIR = $(patsubst ./%,%,.$(patsubst $(realpath $(CURDIR)/$(_DIR))%,%,$(CURDIR)))

###########
# Project #
###########

define project_host
elao-tricot.ela.ooo$(if $(1),:126$(shell printf "%02d" $(1)))
endef

-include $(_DIR)/.manala/make/text.mk
-include $(_DIR)/.manala/make/help.mk
-include $(_DIR)/.manala/make/os.mk
-include $(_DIR)/.manala/docker/make.mk
-include $(_DIR)/.manala/ansible/make.mk
-include $(_DIR)/.manala/make/try.mk
-include $(_DIR)/.manala/make/git.mk
-include $(_DIR)/.manala/make/semver.mk

###############
# Environment #
###############

HELP += $(call help_section, Environment)

# Docker commands only available *OUTSIDE* docker environment
ifndef DOCKER

# Setup commands only available *IN* root directory
ifdef _ROOT
HELP += $(call help,setup, Setup environment (DEBUG))
setup:
$(_docker_compose) up \
--build \
--detach \
--wait
$(setup)
$(MAKE) help
endif

HELP += $(call help,up, Start the environment)
up:
$(_docker_compose) start
$(MAKE) help.project

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

HELP += $(call help,reload, Restart the environment)
reload:
$(_docker_compose) restart
$(MAKE) help.project

HELP += $(call help,sh, Open shell to the environment)
sh:
$(_docker_compose_exec) \
sh -c "if [ -x \"$$(command -v zsh)\" ] ; then exec zsh --login ; else exec bash --login ; fi"

HELP += $(call help,destroy, Stop and delete environment)
destroy:
$(_docker_compose) down \
--rmi local \
--volumes \
--remove-orphans

HELP += $(call help,docker, Arbitrary docker compose commands)
ifeq (docker, $(firstword $(MAKECMDGOALS)))
ARGS := $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))
$(eval $(ARGS):;@true)
docker:
$(_docker_compose) $(ARGS)
endif

endif

HELP += $(call help,provision, Provision the environment (TAGS|DIFF|VERBOSE|LIMIT))
provision: SHELL := $(or $(DOCKER_SHELL),$(SHELL))
provision: _ANSIBLE_PLAYBOOK_INVENTORY = $(_DIR)/.manala/ansible/inventories
provision: _ANSIBLE_PLAYBOOK_BECOME = 1
provision:
$(call log, Install ansible galaxy collections)
$(_ansible_galaxy_collection_install) \
$(_DIR)/.manala/ansible/collections/requirements.yaml
$(call log, Run ansible playbook)
$(_ansible_playbook) \
$(_DIR)/.manala/ansible/system.yaml

HELP += $(call help,provision.apt, Provision the environment - Apt (DIFF|VERBOSE))
provision.apt: _ANSIBLE_PLAYBOOK_TAGS = apt
provision.apt: provision

HELP += $(call help,provision.nginx, Provision the environment - Nginx (DIFF|VERBOSE))
provision.nginx: _ANSIBLE_PLAYBOOK_TAGS = nginx
provision.nginx: provision

HELP += $(call help,provision.php, Provision the environment - Php (DIFF|VERBOSE))
provision.php: _ANSIBLE_PLAYBOOK_TAGS = php
provision.php: provision

HELP += $(call help,provision.certificates,Provision the environment - Certificates (DIFF|VERBOSE))
provision.certificates: _ANSIBLE_PLAYBOOK_TAGS = certificates
provision.certificates: _ANSIBLE_PLAYBOOK_EXTRA_VARS = certificates_prompt=true
provision.certificates: provision

########
# Help #
########

HELP_PROJECT = $(COLOR_COMMENT)┏(°.°)┛┗(°.°)┓$(COLOR_RESET) ♪♫ Let's party ♫♪ $(COLOR_COMMENT)┗(°.°)┛┏(°.°)┓$(COLOR_RESET)\n
HELP_PROJECT += $(call help,Http, http://$(call project_host, 80))
HELP_PROJECT += $(call help,Https, https://$(call project_host, 43))
HELP_PROJECT += $(call help,MailHog, http://$(call project_host, 25))
Loading