Compare commits

...

19 Commits

Author SHA1 Message Date
aynic.os d07a6aafaf Merge remote-tracking branch 'upstream/master' 2024-02-12 00:36:23 +00:00
Yann Autissier e90c606237 Merge branch 'master' of https://git.p2p.legal/qo-op/myos
Conflicts:
	make/apps/myos/setup.mk
	stack/host/acme.mk
2024-02-12 01:34:02 +01:00
aynic.os 2a3a929372 add stack duniter/v2s 2024-02-12 00:15:50 +00:00
Yann Autissier 1a731109ea update apps: bionicgpt 2023-11-26 20:19:44 +01:00
Yann Autissier 2699a04c84 first apps :) 2023-11-26 12:33:55 +01:00
Yann Autissier 5e3782c944 update .env when older than .env.dist 2023-11-26 00:53:32 +01:00
aynic.os 2fb3c83b6a improve docker-compose.yml file detection 2023-11-24 02:57:42 +00:00
aynic.os ac3b5c2381 fix build arch 2023-11-24 00:16:15 +00:00
aynic.os 4f21668399 fix build context 2023-11-21 19:27:07 +00:00
aynic.os 750e451bab rename STACK_* 2023-11-21 19:08:46 +00:00
aynic.os e15701b5a3 fix myos stack path 2023-11-21 18:53:15 +00:00
Yann Autissier 2ad02d500c add myos stack 2023-11-21 19:51:13 +01:00
Yann Autissier 6ff838624c add docker compose support for apps 2023-11-21 19:37:11 +01:00
Yann Autissier 1d2cc6a9a7 improve perfs 2023-11-21 19:36:45 +01:00
Yann Autissier ed4f2e3cc6 improve stack detection 2023-10-26 04:49:02 +02:00
Yann Autissier be9cb1ea30 ipfs network mode host 2023-03-22 13:43:30 +01:00
aynic.os 4cc840d392 update nginx-proxy 2023-02-20 17:03:31 +01:00
aynic.os 7c8da80cbb acme 2023-01-15 13:31:33 +01:00
aynic.os b0a2a9851b armv7 2023-01-13 20:23:36 +01:00
97 changed files with 1090 additions and 490 deletions

View File

@ -0,0 +1,4 @@
BIONICGPT_ENVOY_SERVICE_7700_TAGS ?= $(call tagprefix)
BIONICGPT_REPOSITORY_URL ?= https://github.com/purton-tech/bionicgpt
BIONICGPT_VERSION ?= v1.3.3
ENV_VARS += BIONICGPT_ENVOY_SERVICE_7700_TAGS

View File

@ -0,0 +1,47 @@
services:
app:
environment:
APP_DATABASE_URL: postgresql://${BIONICGPT_DB_APP_USER:-ft_application}:${BIONICGPT_DB_APP_PASSWORD:-testpassword}@db:5432/${BIONICGPT_DB_POSTGRES_DB:-finetuna}?sslmode=disable
barricade:
environment:
SECRET_KEY: ${BIONICGPT_BARRICADE_SECRET_KEY:-190a5bf4b3cbb6c0991967ab1c48ab30790af876720f1835cbbf3820f4f5d949}
DATABASE_URL: postgresql://${BIONICGPT_DB_POSTGRES_USER:-postgres}:${BIONICGPT_DB_POSTGRES_PASSWORD:-testpassword}@db:5432/${BIONICGPT_DB_POSTGRES_DB:-finetuna}?sslmode=disable
db:
environment:
POSTGRES_PASSWORD: ${BIONICGPT_DB_POSTGRES_PASSWORD:-testpassword}
POSTGRES_USER: ${BIONICGPT_DB_POSTGRES_USER:-postgres}
POSTGRES_DB: ${BIONICGPT_DB_POSTGRES_DB:-finetuna}
PGDATA: /var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${BIONICGPT_DB_POSTGRES_USER:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- pgdata:/var/lib/postgresql/data
pipeline-job:
environment:
APP_DATABASE_URL: postgresql://${BIONICGPT_DB_APP_USER:-ft_application}:${BIONICGPT_DB_APP_PASSWORD:-testpassword}@db:5432/${BIONICGPT_DB_POSTGRES_DB:-finetuna}?sslmode=disable
envoy:
labels:
- SERVICE_7700_CHECK_HTTP=${BIONICGPT_ENVOY_SERVICE_7700_CHECK_HTTP:-/auth/sign_in}
- SERVICE_7700_NAME=${COMPOSE_SERVICE_NAME:-bionicgpt}-envoy-7700
- SERVICE_7700_TAGS=${BIONICGPT_ENVOY_SERVICE_7700_TAGS:-urlprefix-localhost/bionicgpt/*}
llm-api:
networks:
default:
aliases:
- local-ai
migrations:
environment:
DATABASE_URL: postgresql://${BIONICGPT_DB_POSTGRES_USER:-postgres}:${BIONICGPT_DB_POSTGRES_PASSWORD:-testpassword}@db:5432/${BIONICGPT_DB_POSTGRES_DB:-finetuna}?sslmode=disable
volumes:
pgdata:

6
apps/signoz/signoz.mk Normal file
View File

@ -0,0 +1,6 @@
ENV_VARS += SIGNOZ_FRONTEND_SERVICE_3301_TAGS
SIGNOZ_DOCKER_DIR ?= deploy/docker/clickhouse-setup
SIGNOZ_FRONTEND_SERVICE_3301_TAGS ?= $(call urlprefix)
SIGNOZ_REPOSITORY_URL ?= https://github.com/SigNoz/signoz
SIGNOZ_VERSION ?= v0.34.3
STACK += alerting/apprise

6
apps/signoz/signoz.yml Normal file
View File

@ -0,0 +1,6 @@
services:
frontend:
labels:
- SERVICE_3301_CHECK_HTTP=${SIGNOZ_SERVICE_3301_CHECK_HTTP:-/}
- SERVICE_3301_NAME=${COMPOSE_SERVICE_NAME:-signoz}-frontend-3301
- SERVICE_3301_TAGS=${SIGNOZ_FRONTEND_SERVICE_3301_TAGS:-urlprefix-localhost/signoz/*}

View File

@ -9,9 +9,9 @@ ARG DOCKER_SYSTEM=Linux
RUN apk update \
&& apk add --no-cache ca-certificates \
&& OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')"; \
ARCH="$(echo ${DOCKER_MACHINE})"; \
wget -qO /usr/bin/docker-compose ${COMPOSE_REMOTE}/releases/download/v${COMPOSE_VERSION}/docker-compose-${OS}-${ARCH} \
&& OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')" \
&& ARCH="$(echo ${DOCKER_MACHINE} |awk '{print /armv7l/ ? "armv7" : $0}')" \
&& wget -qO /usr/bin/docker-compose ${COMPOSE_REMOTE}/releases/download/v${COMPOSE_VERSION}/docker-compose-${OS}-${ARCH} \
&& chmod +x /usr/bin/docker-compose
ENTRYPOINT ["/usr/bin/docker-compose"]

View File

@ -5,13 +5,13 @@ ARG DOCKER_BUILD_DIR
ARG DOCKER_MACHINE=x86_64
ARG DOCKER_SYSTEM=Linux
ARG FABIO_REMOTE=https://github.com/fabiolb/fabio
ARG FABIO_VERSION=1.6.0
ARG FABIO_VERSION=1.6.3
RUN apk update \
&& apk add --no-cache ca-certificates \
&& OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')"; \
ARCH="$(echo ${DOCKER_MACHINE} |awk '/x86_64/ {print "amd64"}; /aarch64/ {print "arm64"}')"; \
wget -qO /usr/bin/fabio ${FABIO_REMOTE}/releases/download/v${FABIO_VERSION}/fabio-${FABIO_VERSION}-${OS}_${ARCH} \
&& OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')" \
&& ARCH="$(echo ${DOCKER_MACHINE} |awk '{print /x86_64/ ? "amd64" : /arch64/ ? "arm64" : /armv(6|7)/ ? "arm" : $0}')" \
&& wget -qO /usr/bin/fabio ${FABIO_REMOTE}/releases/download/v${FABIO_VERSION}/fabio-${FABIO_VERSION}-${OS}_${ARCH} \
&& chmod +x /usr/bin/fabio
EXPOSE 9998 9999

19
docker/myos/.bash_profile Normal file
View File

@ -0,0 +1,19 @@
# shellcheck shell=bash source=/dev/null
# ~/.bash_profile: executed by the command interpreter for bash login shell.
# bash-completion
if ! shopt -oq posix && [ -z "${BASH_COMPLETION_VERSINFO-}" ]; then
if [ "${BASH_VERSINFO[0]}" -gt 4 ] \
|| { [ "${BASH_VERSINFO[0]}" -eq 4 ] && [ "${BASH_VERSINFO[1]}" -ge 1 ] ;}; then
shopt -q progcomp && for file in \
/{*/local,usr}/share/bash-completion/bash_completion \
/etc/bash_completion; do
[ -r "$file" ] && . "$file"
done
fi
if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ]; then
. "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion"
fi
fi
[ -f ~/.sh_profile ] && . ~/.sh_profile

39
docker/myos/.sh_profile Normal file
View File

@ -0,0 +1,39 @@
# shellcheck shell=sh source=/dev/null
# ~/.sh_profile: executed by the command interpreter for login shells.
# source ~/.*aliases and ~/.*functions files
for source in aliases functions; do
for file in "$HOME"/.*"$source"; do
[ -f "$file" ] || continue
# remove $HOME/. prefix from file
file="${file#${HOME}/.}"
# remove _$source suffix from $file
command="${file%_$source}"
# source file if command exists, ie ~/.bash_aliases
command -v "$command" >/dev/null 2>&1 && . "${HOME}/.$file"
# remove $source suffix from $file, ie ~/.aliases
command="${file%$source}"
# source file if command empty, ie ~/.aliases
[ -z "$command" ] && . "${HOME}/.$file"
done
done
# source ~/.*shrc
for file in "$HOME"/.*shrc; do
[ -f "$file" ] || continue
# remove $HOME/. prefix from file
file="${file#${HOME}/.}"
# source file if match current shell
[ "$(basename "${SHELL}")" = "${file%rc}" ] && . "${HOME}/.$file"
done
# set PATH to include user's bin
for path in /*/local/sbin /*/local/bin /*/local/*/bin "${HOME}"/.*/bin; do
[ -d "$path" ] || continue
case ":${PATH}:" in
*:"$path":*) ;;
*) export PATH="${path}:$PATH" ;;
esac
done
[ -f ~/.profile ] && . ~/.profile

5
docker/myos/.shrc Normal file
View File

@ -0,0 +1,5 @@
export EDITOR=vim
export GIT_PS1_SHOWUPSTREAM=auto
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_HIDE_IF_PWD_IGNORED=true
export PAGER=less

View File

@ -41,15 +41,21 @@ RUN git clone https://github.com/ingydotnet/git-subrepo \
&& cd .. \
&& rm -rf git-subrepo
ARG IPFS_VERSION=0.14.0
ARG COMPOSE_REMOTE=https://github.com/docker/compose
ARG COMPOSE_VERSION=2.5.0
ARG IPFS_VERSION=0.24.0
RUN { OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')"; \
ARCH="$(echo ${DOCKER_MACHINE})"; \
wget -qO - https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.${OS}.${ARCH}.tar.xz \
|tar --strip-components 1 -C /usr/local/bin -xJf - shellcheck-stable/shellcheck; } \
&& { ARCH="$(echo ${DOCKER_MACHINE} |awk '/x86_64/ {print "amd64"}; /aarch64/ {print "arm64"}')"; \
wget -qO - https://github.com/ipfs/kubo/releases/download/v${IPFS_VERSION}/kubo_v${IPFS_VERSION}_${OS}-${ARCH}.tar.gz \
|tar --strip-components 1 -C /usr/local/bin -xzf - kubo/ipfs; } \
RUN OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')" \
&& ARCH="$(echo ${DOCKER_MACHINE} |awk '{print /armv7l/ ? "armv7" : $0}')" \
&& wget -qO /usr/bin/docker-compose ${COMPOSE_REMOTE}/releases/download/v${COMPOSE_VERSION}/docker-compose-${OS}-${ARCH} \
&& chmod +x /usr/bin/docker-compose \
&& OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')" \
&& ARCH="$(echo ${DOCKER_MACHINE})" \
&& wget -qO - https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.${OS}.${ARCH}.tar.xz \
|tar --strip-components 1 -C /usr/local/bin -xJf - shellcheck-stable/shellcheck \
&& ARCH="$(echo ${DOCKER_MACHINE} |awk '{print /x86_64/ ? "amd64" : /arch64/ ? "arm64" : /armv(6|7)/ ? "arm" : $0}')" \
&& wget -qO - https://github.com/ipfs/kubo/releases/download/v${IPFS_VERSION}/kubo_v${IPFS_VERSION}_${OS}-${ARCH}.tar.gz \
|tar --strip-components 1 -C /usr/local/bin -xzf - kubo/ipfs \
&& mkdir -p /usr/local/lib/shellspec \
&& wget -qO - https://github.com/shellspec/shellspec/archive/refs/heads/master.tar.gz \
|tar --strip-components 1 -C /usr/local/lib/shellspec -xzf - \
@ -83,13 +89,12 @@ ENV GID=${UID}
ENV USER=${USER}
RUN apk add --no-cache \
# docker \
# docker-compose \
# mysql-client \
# postgresql-client \
sudo
# vim \
# zsh
docker \
mysql-client \
postgresql-client \
sudo \
vim \
zsh
# If we provide a numeric UID
RUN [ "$UID" -eq "$UID" ] 2>/dev/null \
@ -146,7 +151,7 @@ Host ssh-bastion\n\
fi
# Custom rc functions
COPY ansible/roles/hosts/files/etc/profile.d/rc*.sh /etc/profile.d/
COPY ${DOCKER_BUILD_DIR}/rc*.sh /etc/profile.d/
RUN mkdir -p $SOCKET_DIR && chown $USER $SOCKET_DIR

45
docker/myos/rc.sh Normal file
View File

@ -0,0 +1,45 @@
# shellcheck shell=sh
# file rc.sh: Call user defined functions
## author: Yann "aya" Autissier
## license: GPL
## version: 20220630
case $- in
# if this is an interactive shell
*i*)
# load user stuff from ~/.rc.d/* files
for file in "${HOME}"/.rc.d/*; do
# read files only
if [ -f "${file}" ]; then
func_name=$(basename "${file}")
func_args=$(cat "${file}")
# at this stage, func_name can start with numbers to allow ordering function calls with file names starting with numbers
# func_name must start with a letter, remove all other characters at the beginning of func_name until a letter is found
while [ "${func_name}" != "" ] && [ "${func_name#[a-z]}" = "${func_name}" ]; do
# remove first char of func_name
func_name="${func_name#?}"
done
# call user function with args passed from the content of the file
command -v "${func_name}" >/dev/null 2>&1 && "${func_name}" "${func_args}"
fi
done
# load user stuff from RC_* env vars
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}"; for line in $(printenv 2>/dev/null |awk '$0 ~ /^RC_[0-9A-Z_]*=/' |sort); do
func_name=$(printf '%s\n' "${line%%=*}" |awk '{print tolower(substr($0,4))}')
eval func_args=\$"${line%%=*}"
[ "${func_args}" = "false" ] && continue
[ "${func_args}" = "true" ] && unset func_args
# at this stage, func_name can start with numbers to allow ordering function calls with file names starting with numbers
# func_name must start with a letter, remove all other characters at the beginning of func_name until a letter is found
while [ "${func_name}" != "" ] && [ "${func_name#[a-z]}" = "${func_name}" ]; do
# remove first char of func_name
func_name="${func_name#?}"
done
# call user function with args passed from the value of the env var
command -v "${func_name}" >/dev/null 2>&1 && "${func_name}" "${func_args}"
done
unset IFS
;;
esac
# vim:ts=2:sw=2:sts=2:et

286
docker/myos/rc_functions.sh Normal file
View File

@ -0,0 +1,286 @@
# shellcheck shell=sh
# file rc_functions.sh: Define shell functions
## author: Yann "aya" Autissier
## license: GPL
## version: 20221229
# function force: Run a command sine die
force() {
if [ $# -gt 0 ]; then
while true; do
"$@"
sleep 1
done
fi
}
# function force8: Run a command sine die if not already running
force8() {
if [ $# -gt 0 ]; then
while true; do
# awk expression to match $@
[ "$(ps wwx -o args 2>/dev/null |awk -v field="${PS_X_FIELD:-1}" '
BEGIN { nargs=split("'"$*"'",args); }
# first field matched
$field == args[1] {
matched=1;
# match following fields
for (i=1;i<=NF-field;i++) {
if ($(i+field) == args[i+1]) { matched++; }
};
# all fields matched
if (matched == nargs) { found++; }
}
END { print found+0; }'
)" = 0 ] && "$@"
sleep 1
done
fi
}
# function lang_set; Export default LANG
lang_set() {
export $(awk -F'=' '$1 == "LANG"' /etc/default/locale 2>/dev/null) >/dev/null
}
# function load_average; Print the current load average
load_average() {
uptime 2>/dev/null |awk '{printf "%.1f\n", $(NF-2)}'
}
# function process_count: Print number of "processes"/"running processes"/"D-state"
process_count() {
ps ax -o stat 2>/dev/null |awk '
$1 ~ /R/ {process_running++};
$1 ~ /D/ {process_dstate++};
END { print NR-1"/"process_running+0"/"process_dstate+0; }'
}
# function prompt_set: Export custom PROMPT_COMMAND
prompt_set() {
case "${TERM}" in
screen*)
ESCAPE_CODE_DCS="\033k"
ESCAPE_CODE_ST="\033\\"
;;
linux*|xterm*|rxvt*)
ESCAPE_CODE_DCS="\033]0;"
ESCAPE_CODE_ST="\007"
;;
*)
;;
esac
# in a screen
if [ -n "${STY}" ]; then
export PROMPT_COMMAND='printf\
"${ESCAPE_CODE_DCS:-\033]0;}%s${ESCAPE_CODE_ST:-\007}"\
"${PWD##*/}"'
else
export PROMPT_COMMAND='printf\
"${ESCAPE_CODE_DCS:-\033]0;}%s@%s:%s${ESCAPE_CODE_ST:-\007}"\
"${USER}"\
"${HOSTNAME%%.*}"\
"${PWD##*/}"'
fi
unset ESCAPE_CODE_DCS ESCAPE_CODE_ST
}
# function ps1_set: Export custom PS1
ps1_set() {
case "$0" in
*sh)
COLOR_DGRAY="\[\033[1;30m\]"
COLOR_RED="\[\033[01;31m\]"
COLOR_GREEN="\[\033[01;32m\]"
COLOR_BROWN="\[\033[0;33m\]"
COLOR_YELLOW="\[\033[01;33m\]"
COLOR_BLUE="\[\033[01;34m\]"
COLOR_CYAN="\[\033[0;36m\]"
COLOR_GRAY="\[\033[0;37m\]"
COLOR_RESET="\[\033[0m\]"
;;
*)
;;
esac
PS1_STATUS="\$?"
PS1_COUNT="${COLOR_DGRAY}[\`
case \"$PS1_STATUS\" in
0)
printf \"${COLOR_BLUE}${PS1_STATUS}\";;
1)
printf \"${COLOR_YELLOW}${PS1_STATUS}\";;
*)
printf \"${COLOR_RED}${PS1_STATUS}\";;
esac
type process_count >/dev/null 2>&1 && printf\
\"${COLOR_DGRAY}|${COLOR_BLUE}%s\"\
\"\$(process_count 2>/dev/null)\"
type user_count >/dev/null 2>&1 && printf\
\"${PS1_COUNT}${COLOR_DGRAY}|${COLOR_BLUE}%s\"\
\"\$(user_count 2>/dev/null)\"
type load_average >/dev/null 2>&1 && printf\
\"${PS1_COUNT}${COLOR_DGRAY}|${COLOR_BLUE}%s\"\
\"\$(load_average 2>/dev/null)\"
\`${COLOR_DGRAY}]${COLOR_RESET}"
PS1_END="${COLOR_DGRAY}\$(
if [ \"\$(id -u)\" = 0 ]; then
printf \"#\";
else
printf \"\$\";
fi
)${COLOR_RESET}"
PS1_GIT="\$(
if type __git_ps1 >/dev/null 2>&1; then
printf \"\$(__git_ps1 2>/dev/null \" (%s)\")\"
else
printf \"\$(BRANCH=\$(git rev-parse --abbrev-ref HEAD 2>/dev/null);\
[ -n \"\${BRANCH}\" ] && printf \" (\${BRANCH})\")\"
fi
)"
PS1_GIT="${COLOR_CYAN}${PS1_GIT}${COLOR_RESET}"
PS1_HOSTNAME_COLOR="\`case \"\${ENV}${HOSTNAME%%.*}\" in
*[Pp][Rr][0Oo][Dd]*|*[Pp][Rr][Dd]*)
printf \"${COLOR_RED}\";;
*)
if [ -n \"\${ENV}\" ]; then
printf \"${COLOR_YELLOW}\";
else
printf \"${COLOR_GREEN}\";
fi;;
esac\`"
PS1_HOSTNAME="${PS1_HOSTNAME_COLOR}\$(hostname |sed 's/\..*//')${COLOR_RESET}"
PS1_USER_COLOR="\$(
if [ \"\$(id -u)\" = 0 ]; then
printf \"${COLOR_RED}\";
else
printf \"${COLOR_BROWN}\";
fi
)"
PS1_USER="${PS1_USER_COLOR}\$(id -nu):\$(id -u)${COLOR_RESET}"
PS1_WORKDIR="${COLOR_GRAY}\$(
pwd |sed 's|^'\${HOME}'\(/.*\)*$|~\1|'
)${COLOR_RESET}"
PS1="${PS1_COUNT}${PS1_USER}${COLOR_DGRAY}@${PS1_HOSTNAME}"
PS1="${PS1}${COLOR_DGRAY}:${PS1_WORKDIR}${PS1_GIT}${PS1_END} "
export 'PS1'
unset PS1_COUNT PS1_END PS1_GIT PS1_HOSTNAME PS1_HOSTNAME_COLOR\
PS1_USER PS1_USER_COLOR PS1_STATUS PS1_WORKDIR
}
# function screen_attach: Attach existing screen session or Create a new one
screen_attach() {
command -v screen >/dev/null 2>&1 || return
SCREEN_SESSION="$(id -nu)@$(hostname |sed 's/\..*//')"
if [ -z "${STY}" ]; then
# attach screen in tmux window 0 only ;)
[ -n "${TMUX}" ] \
&& [ "$(tmux list-window 2>/dev/null |awk '$NF == "(active)" {print $1}'\
|sed 's/:$//')" != "0" ] \
&& return
printf 'Attaching screen.' && sleep 1\
&& printf '.' && sleep 1\
&& printf '.' && sleep 1
exec screen -xRR -S "${SCREEN_SESSION}"
fi
unset SCREEN_SESSION
}
# function screen_detach: Detach current screen session
screen_detach() {
screen -d
}
# function ssh_add: Load all private keys in ~/.ssh/ to ssh agent
ssh_add() {
command -v ssh-agent >/dev/null 2>&1 && command -v ssh-add >/dev/null 2>&1 || return
SSH_AGENT_DIR="/tmp/ssh-$(id -u)"
SSH_AGENT_SOCK="${SSH_AGENT_DIR}/agent@$(hostname |sed 's/\..*//')"
# launch a new agent
if [ -z "${SSH_AUTH_SOCK}" ]; then
[ ! -d "${SSH_AGENT_DIR}" ] \
&& mkdir -p "${SSH_AGENT_DIR}" 2>/dev/null\
&& chmod 0700 "${SSH_AGENT_DIR}"
# search for an already running agent
if ps wwx -o args |awk '$1 ~ "ssh-agent$" && $3 == "'"${SSH_AGENT_SOCK}"'"' |wc -l |grep -q 0; then
rm -f "${SSH_AGENT_SOCK}"
ssh-agent -a "${SSH_AGENT_SOCK}" >/dev/null 2>&1
fi
fi
# attach to agent
export SSH_AUTH_SOCK="${SSH_AUTH_SOCK:-${SSH_AGENT_SOCK}}"
# list private keys to add
# shellcheck disable=SC2068
for dir in ${@:-${HOME}/.ssh}; do
if [ "${SSH_ADD_RECURSIVE:-}" = true ]; then
GREP_RECURSIVE_FLAG="r"
else
GREP_RECURSIVE_CHAR="*"
fi
SSH_PRIVATE_KEYS="${SSH_PRIVATE_KEYS:-} ${dir}/id_ed25519 ${dir}/id_rsa $(grep -l${GREP_RECURSIVE_FLAG:-} 'PRIVATE KEY' "${dir}/"${GREP_RECURSIVE_CHAR:-} 2>/dev/null |grep -vwE "${dir}/id_(rsa|ed25519)")"
done
# shellcheck disable=SC2086
printf '%s\n' ${SSH_PRIVATE_KEYS} |while read -r file; do
[ -r "${file}" ] || continue
# add private key to agent
ssh-add -l |grep -q "$(ssh-keygen -lf "${file}" 2>/dev/null |awk '{print $2}')" 2>/dev/null || ssh-add "${file}"
done
unset GREP_RECURSIVE_CHAR GREP_RECURSIVE_FLAG SSH_AGENT_DIR SSH_AGENT_SOCK SSH_PRIVATE_KEYS
}
# function ssh_del: removes all private keys in ~/.ssh/ from ssh agent
ssh_del() {
command -v ssh-add >/dev/null 2>&1 || return
# attach to agent
if [ -z "${SSH_AUTH_SOCK}" ]; then
return
fi
# list private keys to del
# shellcheck disable=SC2068
for dir in ${@:-${HOME}/.ssh}; do
if [ "${SSH_DEL_RECURSIVE:-}" = true ]; then
GREP_RECURSIVE_FLAG="r"
else
GREP_RECURSIVE_CHAR="*"
fi
SSH_PRIVATE_KEYS="${SSH_PRIVATE_KEYS:-} ${dir}/id_ed25519 ${dir}/id_rsa $(grep -l${GREP_RECURSIVE_FLAG:-} 'PRIVATE KEY' "${dir}/"${GREP_RECURSIVE_CHAR:-} 2>/dev/null |grep -vwE "${dir}/id_(rsa|ed25519)")"
done
# shellcheck disable=SC2086
printf '%s\n' ${SSH_PRIVATE_KEYS} |while read -r file; do
[ -r "${file}" ] || continue
# remove private key from agent
ssh-add -l |grep -q "$(ssh-keygen -lf "${file}" 2>/dev/null |awk '{print $2}')" 2>/dev/null && ssh-add -d "${file}"
done
unset GREP_RECURSIVE_CHAR GREP_RECURSIVE_FLAG SSH_PRIVATE_KEYS
}
# function tmux_attach: Attach existing tmux session or Create a new one
tmux_attach() {
command -v tmux >/dev/null 2>&1 || return
TMUX_SESSION="$(id -nu)@$(hostname |sed 's/\..*//')"
# do not attach tmux in screen ;)
if [ -z "${TMUX}" -a -z "${STY}" ]; then
printf 'Attaching tmux.' && sleep 1\
&& printf '.' && sleep 1\
&& printf '.' && sleep 1
exec tmux -L"${TMUX_SESSION}" new-session -A -s"${TMUX_SESSION}"
fi
unset TMUX_SESSION
}
# function tmux_detach: Detach current tmux session
tmux_detach() {
tmux detach
}
# function user_count: Print number of "users sessions"/"users"/"logged users"
user_count() {
ps ax -o pid,user,tty,comm 2>/dev/null |awk '
$3 ~ /^(pts\/|tty[sS]?|[0-9]+,)[0-9]+$/ && $4 != "getty" { users_sessions++; logged[$2]++; };
$1 ~ /^[0-9]+$/ { count[$2]++; }
END {
for (uc in count) { c = c" "uc; }; users_count=split(c,v," ");
for (ul in logged) { l = l" "ul; }; users_logged=split(l,v," ");
print users_sessions+0"/"users_count+0"/"users_logged+0;
}'
}

View File

@ -2,10 +2,10 @@ FROM pinidh/nginx-proxy:alpine
ARG DOCKER_BUILD_DIR
RUN sed -i 's/\(function _resolvers() {\)$/function _nginx_config() {\n\t\/app\/nginx-config.sh\n}\n\n\1/;s/\(\t_default_certificate\)$/\1\n\n\t_nginx_config/' /app/docker-entrypoint.sh \
&& sed -i 's|\(\treturn 503;\)$|\t{{ if (exists (printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default"))) }}\n\tinclude {{ printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default") }};\n\t {{ if (exists (printf "/etc/nginx/vhost.d/default_location")) }}\n{{ if $.Env.DEFAULT_LOCATION }}\tinclude {{ printf "/etc/nginx/vhost.d/default_location" }};{{ end }}\n\t {{ if (exists (printf "/etc/nginx/vhost.d/default_location_php")) }}\n{{ if $.Env.DEFAULT_LOCATION_PHP }}\tinclude {{ printf "/etc/nginx/vhost.d/default_location_php" }};{{ end }}\n\t {{ end }}\n\t {{ if (exists (printf "/etc/nginx/vhost.d/default_location_ipfs")) }}\n{{ if $.Env.DEFAULT_LOCATION_IPFS }}\tinclude {{ printf "/etc/nginx/vhost.d/default_location_ipfs" }};{{ end }}\n\t {{ end }}\n\t {{ end }}\n\t{{ else }}\n\1\n\t{{ end }}|' /app/nginx.tmpl \
&& sed -i 's|\({{ if (exists "/etc/nginx/proxy.conf") }}\)|{{ if (exists "/etc/nginx/vhost.d/nginx.conf") }}\ninclude /etc/nginx/vhost.d/nginx.conf;\n{{ end }}\n\n\1|' /app/nginx.tmpl \
&& sed -i 's|exists "/etc/nginx/vhost.d/default"|exists (printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default"))|;s|include /etc/nginx/vhost.d/default;|include {{ printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default") }};|' /app/nginx.tmpl \
&& sed -i 's|\(include /etc/nginx/vhost.d/default_location;\)|\1\n\t\t{{ if (exists (printf "/etc/nginx/vhost.d/default_location_php")) }}\n{{ if $.Env.DEFAULT_LOCATION_PHP }}\tinclude {{ printf "/etc/nginx/vhost.d/default_location_php" }};{{ end }}\n\t\t{{ end }}\n\t\t{{ if (exists (printf "/etc/nginx/vhost.d/default_location_ipfs")) }}\n{{ if $.Env.DEFAULT_LOCATION_IPFS }}\tinclude {{ printf "/etc/nginx/vhost.d/default_location_ipfs" }};{{ end }}\n\t\t{{ end }}|' /app/nginx.tmpl \
&& sed -i 's|\(include /etc/nginx/vhost.d/default_location;\)|\1\n {{- end }}\n {{- if (and (exists "/etc/nginx/vhost.d/default_location_php") ($.Env.DEFAULT_LOCATION_PHP)) }}\n include /etc/nginx/vhost.d/default_location_php;\n {{- end }}\n {{- if (and (exists "/etc/nginx/vhost.d/default_location_ipfs") ($.Env.DEFAULT_LOCATION_IPFS)) }}\n include /etc/nginx/vhost.d/default_location_ipfs;|' /app/nginx.tmpl \
&& sed -i 's|\( return 503;\)$|{{- if (exists (printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default"))) }}\n include {{ (printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default")) }};\n{{- if (and (exists "/etc/nginx/vhost.d/default_location") ($.Env.DEFAULT_LOCATION)) }}\n include /etc/nginx/vhost.d/default_location;\n{{- end }}\n{{- if (and (exists "/etc/nginx/vhost.d/default_location_php") ($.Env.DEFAULT_LOCATION_PHP)) }}\n include /etc/nginx/vhost.d/default_location_php;\n{{- end }}\n{{- if (and (exists "/etc/nginx/vhost.d/default_location_ipfs") ($.Env.DEFAULT_LOCATION_IPFS)) }}\n include /etc/nginx/vhost.d/default_location_ipfs;\n{{- end }}\n{{- else }}\n\1\n{{- end }}|' /app/nginx.tmpl \
&& sed -i 's|\({{-\? if (exists "/etc/nginx/proxy.conf") }}\)|{{- if (exists "/etc/nginx/vhost.d/nginx.conf") }}\ninclude /etc/nginx/vhost.d/nginx.conf;\n{{ end }}\n\n\1|' /app/nginx.tmpl \
&& sed -i 's|exists "/etc/nginx/vhost.d/default"|exists (printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default"))|;s|include /etc/nginx/vhost.d/default;|include {{ (printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default")) }};|' /app/nginx.tmpl \
&& awk '/proxy_pass \{\{ trim .Proto \}\}/{sub(/else/, "else if ne .Proto \"local\"", last)} NR>1{print last} {last=$0} END {print last}' /app/nginx.tmpl > /tmp/nginx.tmpl && mv /tmp/nginx.tmpl /app/
COPY ${DOCKER_BUILD_DIR}/nginx* /app

View File

@ -4,7 +4,7 @@ set -eu
##
# CONFIG
sed -i 's/fastcgi_param * SERVER_SOFTWARE *.*/fastcgi_param SERVER_SOFTWARE nginx;/' /etc/nginx/fastcgi_params
sed -i 's/fastcgi_param * SERVER_SOFTWARE *.*/fastcgi_param SERVER_SOFTWARE nstix;/' /etc/nginx/fastcgi_params
##
# DEFAULT

View File

@ -7,3 +7,10 @@ map $host $host_dir {
~(?:(?<sd>[a-z0-9-]+)\.)(?<dom>[a-z0-9-]+)\.(?<tld>[a-z0-9-]+)$ ${tld}/${dom}/${sd};
~(?<dom>[a-z0-9-]+)\.(?<tld>[a-z0-9-]+)$ ${tld}/${dom};
}
set_real_ip_from 192.168.0.0/16;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 2001:0db8::/32;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

View File

@ -22,17 +22,16 @@ RUN apk --no-cache add \
ARG PACKER_VERSION=1.8.3
RUN { OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')"; \
ARCH="$(echo ${DOCKER_MACHINE} |awk '/x86_64/ {print "amd64"}; /aarch64/ {print "arm64"}')"; \
wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_${OS}_${ARCH}.zip \
&& wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_SHA256SUMS \
&& wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_SHA256SUMS.sig \
&& GNUPGHOME="./.gnupg" gpg --batch --recv-keys C874011F0AB405110D02105534365D9472D7468F \
&& GNUPGHOME="./.gnupg" gpg --batch --verify packer_${PACKER_VERSION}_SHA256SUMS.sig packer_${PACKER_VERSION}_SHA256SUMS \
&& grep packer_${PACKER_VERSION}_${OS}_${ARCH}.zip packer_${PACKER_VERSION}_SHA256SUMS |sha256sum -c - \
&& unzip "packer_${PACKER_VERSION}_${OS}_${ARCH}.zip" -d /usr/local/bin \
&& rm -f "packer_${PACKER_VERSION}_${OS}_${ARCH}.zip" packer_${PACKER_VERSION}_SHA256SUMS.sig packer_${PACKER_VERSION}_SHA256SUMS ./.gnupg \
; }
RUN OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')" \
&& ARCH="$(echo ${DOCKER_MACHINE} |awk '{print /x86_64/ ? "amd64" : /arch64/ ? "arm64" : /armv(6|7)/ ? "arm" : $0}')" \
&& wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_${OS}_${ARCH}.zip \
&& wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_SHA256SUMS \
&& wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_SHA256SUMS.sig \
&& GNUPGHOME="./.gnupg" gpg --batch --recv-keys C874011F0AB405110D02105534365D9472D7468F \
&& GNUPGHOME="./.gnupg" gpg --batch --verify packer_${PACKER_VERSION}_SHA256SUMS.sig packer_${PACKER_VERSION}_SHA256SUMS \
&& grep packer_${PACKER_VERSION}_${OS}_${ARCH}.zip packer_${PACKER_VERSION}_SHA256SUMS |sha256sum -c - \
&& unzip "packer_${PACKER_VERSION}_${OS}_${ARCH}.zip" -d /usr/local/bin \
&& rm -rf "packer_${PACKER_VERSION}_${OS}_${ARCH}.zip" packer_${PACKER_VERSION}_SHA256SUMS.sig packer_${PACKER_VERSION}_SHA256SUMS ./.gnupg
ENTRYPOINT ["/usr/local/bin/packer"]

View File

@ -193,6 +193,7 @@ ssh@%:
.PHONY: stack
stack:
$(foreach stackz,$(STACK),$(call docker-stack,$(stackz)))
$(call compose-file,$(MYOS_STACK),$(MYOS_STACK_FILE))
# target stack-%: Call docker-compose-% target on STACK
## it splits % on dashes and extracts stack from the beginning and command from
@ -239,7 +240,7 @@ upgrade: update app-upgrade release-upgrade ## Upgrade application
# target %: Always fired target
## it fires the stack and %-rule-exists targets everytime
%: FORCE stack %-rule-exists ;
%: FORCE %-rule-exists ;
# target %-rule-exists: Print a warning message if % target does not exists
%-rule-exists:

View File

@ -1,7 +1,6 @@
COMPOSE_FILE ?= $(wildcard docker-compose.yml docker/docker-compose.yml $(foreach file,$(patsubst docker/docker-compose.%,%,$(basename $(wildcard docker/docker-compose.*.yml))),$(if $(filter true,$(COMPOSE_FILE_$(file)) $(COMPOSE_FILE_$(call UPPERCASE,$(file)))),docker/docker-compose.$(file).yml)))
COMPOSE_FILE_$(ENV) ?= true
COMPOSE_FILE_DEBUG ?= $(if $(DEBUG),true)
COMPOSE_FILE_MYOS ?= true
COMPOSE_FILE_DNS ?= false
COMPOSE_FILE_HOME ?= false
COMPOSE_FILE_NFS ?= $(MOUNT_NFS)
COMPOSE_FILE_SSH ?= true
ifneq ($(SUBREPO),)
@ -9,6 +8,8 @@ COMPOSE_FILE_SUBREPO ?= true
else
COMPOSE_FILE_APP ?= true
endif
COMPOSE_FILE_SUFFIX ?= $(foreach suffix,$(call LOWERCASE,$(filter-out SUFFIX,$(patsubst COMPOSE_FILE_%,%,$(filter COMPOSE_FILE_%,$(MAKE_FILE_VARS))))),$(if $(filter-out false False FALSE,$(COMPOSE_FILE_$(call UPPERCASE,$(suffix)))),$(suffix)))
COMPOSE_FILE_WWW ?= false
COMPOSE_IGNORE_ORPHANS ?= false
COMPOSE_PROJECT_NAME ?= $(if $(DOCKER_COMPOSE_PROJECT_NAME),$(DOCKER_COMPOSE_PROJECT_NAME),$(subst .,,$(call LOWERCASE,$(USER)-$(APP_NAME)-$(ENV)$(addprefix -,$(subst /,,$(subst -,,$(APP_PATH)))))))
COMPOSE_SERVICE_NAME ?= $(if $(DOCKER_COMPOSE_SERVICE_NAME),$(DOCKER_COMPOSE_SERVICE_NAME),$(subst _,-,$(COMPOSE_PROJECT_NAME)))
@ -18,7 +19,7 @@ CONTEXT_DEBUG += DOCKER_BUILD_TARGET DOCKER_COMPOSE_PROJECT_NA
DOCKER_AUTHOR ?= $(DOCKER_AUTHOR_NAME) <$(DOCKER_AUTHOR_EMAIL)>
DOCKER_AUTHOR_EMAIL ?= $(subst +git,+docker,$(GIT_AUTHOR_EMAIL))
DOCKER_AUTHOR_NAME ?= $(GIT_AUTHOR_NAME)
DOCKER_BUILD_ARGS ?= $(if $(filter true,$(DOCKER_BUILD_NO_CACHE)),--pull --no-cache) $(foreach var,$(DOCKER_BUILD_VARS),$(if $($(var)),--build-arg $(var)='$($(var))')) --build-arg GID='$(if $(STACK_HOST),$(HOST_GID),$(GID))' --build-arg UID='$(if $(STACK_HOST),$(HOST_UID),$(UID))'
DOCKER_BUILD_ARGS ?= $(if $(filter true,$(DOCKER_BUILD_NO_CACHE)),--pull --no-cache) $(foreach var,$(DOCKER_BUILD_VARS),$(if $($(var)),--build-arg $(var)='$($(var))')) --build-arg GID='$(if $(HOST_STACK),$(HOST_GID),$(GID))' --build-arg UID='$(if $(HOST_STACK),$(HOST_UID),$(UID))'
DOCKER_BUILD_CACHE ?= true
DOCKER_BUILD_LABEL ?= $(foreach var,$(filter $(BUILD_LABEL_VARS),$(MAKE_FILE_VARS)),$(if $($(var)),--label $(var)='$($(var))'))
DOCKER_BUILD_NO_CACHE ?= false
@ -26,10 +27,12 @@ DOCKER_BUILD_TARGET ?= $(if $(filter $(ENV),$(DOCKER_BUILD_TARGETS))
DOCKER_BUILD_TARGET_DEFAULT ?= master
DOCKER_BUILD_TARGETS ?= $(ENV_DEPLOY)
DOCKER_BUILD_VARS ?= APP BRANCH COMPOSE_VERSION DOCKER_GID DOCKER_MACHINE DOCKER_REPOSITORY DOCKER_SYSTEM GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME SSH_REMOTE_HOSTS USER VERSION
DOCKER_COMPOSE ?= $(or $(shell docker-compose --version 2>/dev/null |awk '$$4 != "v'"$(COMPOSE_VERSION)"'" {exit 1} END {if (NR == 0) exit 1}' && printf 'docker-compose\n'),$(shell docker compose >/dev/null 2>&1 && printf 'docker compose\n'))
DOCKER_COMPOSE := $(or $(shell docker-compose --version 2>/dev/null |awk '$$4 != "v'"$(COMPOSE_VERSION)"'" {exit 1} END {if (NR == 0) exit 1}' && printf 'docker-compose\n'),$(shell docker compose >/dev/null 2>&1 && printf 'docker compose\n'))
DOCKER_COMPOSE_ARGS ?= --ansi=auto
DOCKER_COMPOSE_DOWN_OPTIONS ?=
DOCKER_COMPOSE_PROJECT_NAME ?= $(if $(STACK_HOST),$(HOST_COMPOSE_PROJECT_NAME),$(if $(STACK_USER),$(USER_COMPOSE_PROJECT_NAME)))
DOCKER_COMPOSE_FILE ?= docker-compose
DOCKER_COMPOSE_LOGS_OPTIONS ?= --follow --tail=100
DOCKER_COMPOSE_PROJECT_NAME ?= $(if $(HOST_STACK),$(HOST_COMPOSE_PROJECT_NAME),$(if $(USER_STACK),$(USER_COMPOSE_PROJECT_NAME)))
DOCKER_COMPOSE_RUN_ENTRYPOINT ?= $(patsubst %,--entrypoint=%,$(DOCKER_COMPOSE_ENTRYPOINT))
DOCKER_COMPOSE_RUN_OPTIONS ?= --rm $(DOCKER_COMPOSE_RUN_ENTRYPOINT) $(DOCKER_COMPOSE_RUN_WORKDIR)
DOCKER_COMPOSE_RUN_WORKDIR ?= $(if $(DOCKER_COMPOSE_WORKDIR),-w $(DOCKER_COMPOSE_WORKDIR))
@ -62,6 +65,15 @@ DOCKER_COMPOSE_DOWN_OPTIONS := --rmi all -v
DOCKER_COMPOSE_UP_OPTIONS := -d --build
endif
# function compose-file: Search compose files to update variable COMPOSE_FILE
define compose-file
$(call INFO,compose-file,$(1)$(comma) $(2)$(comma) $(3)$(comma) $(4))
$(eval path := $(or $(1),. $(APP_DOCKER_DIR)))
$(eval name := $(or $(2),$(DOCKER_COMPOSE_FILE)))
$(eval suffix := $(or $(3),$(COMPOSE_FILE_SUFFIX)))
$(eval extension := $(or $(4),yml yaml))
$(eval COMPOSE_FILE += $(wildcard $(foreach e,$(extension),$(foreach n,$(name),$(foreach p,$(path),$(p)/$(n).$(e) $(p)/$(n).$(ENV).$(e) $(foreach s,$(suffix),$(p)/$(n).$(s).$(e) $(p)/$(n).$(s).$(ENV).$(e)))))))
endef
# function docker-build: Build docker image
define docker-build
$(call INFO,docker-build,$(1)$(comma) $(2)$(comma) $(3))
@ -135,9 +147,8 @@ define docker-stack-update
$(eval stack := $(patsubst %.yml,%,$(notdir $(1))))
$(eval name := $(firstword $(subst :, ,$(stack))))
$(eval version := $(or $(2),$(if $(findstring :,$(stack)),$(lastword $(subst :, ,$(stack))),latest)))
$(eval path := $(patsubst %/,%,$(or $(3),$(if $(findstring /,$(1)),$(if $(wildcard stack/$(1) stack/$(1).yml),stack/$(if $(findstring .yml,$(1)),$(dir $(1)),$(if $(wildcard stack/$(1).yml),$(dir $(1)),$(1))),$(dir $(1)))),stack/$(name))))
$(eval COMPOSE_FILE += $(wildcard $(path)/$(name).yml $(path)/$(name).$(ENV).yml $(path)/$(name).$(ENV).$(version).yml $(path)/$(name).$(version).yml))
$(eval COMPOSE_FILE := $(strip $(COMPOSE_FILE)))
$(eval path := $(patsubst %/,%,$(or $(3),$(if $(findstring /,$(1)),$(if $(wildcard stack/$(1) stack/$(1).yml),stack/$(if $(findstring .yml,$(1)),$(dir $(1)),$(if $(wildcard stack/$(1).yml),$(dir $(1)),$(1))),$(if $(wildcard stack/$(stackz)/$(1) stack/$(stackz)/$(1).yml),stack/$(stackz)/$(if $(findstring .yml,$(1)),$(dir $(1)),$(if $(wildcard stack/$(stackz)/$(1).yml),$(dir $(1)),$(1))),$(dir $(1))))),$(firstword $(wildcard stack/$(stackz)/$(name) stack/$(stackz) stack/$(name))))))
$(call compose-file,$(path),$(name),$(COMPOSE_FILE_SUFFIX) $(version))
$(if $(wildcard $(path)/.env.dist),$(call .env,,$(path)/.env.dist,$(wildcard $(CONFIG)/$(ENV)/$(APP)/.env $(path)/.env.$(ENV) .env)))
endef
# function docker-tag: Tag docker image

View File

@ -1,8 +1,13 @@
APP_DIR ?= $(CURDIR)
APP_DOCKER_DIR ?= $(DOCKER_DIR)
APP_DOMAIN ?= $(patsubst %,$(APP_DOMAIN_PREFIX)%,$(DOMAIN))
APP_DOMAIN_PREFIX ?= $(if $(STACK_HOST),,$(addsuffix .,$(filter-out $(ENV_DEPLOY),$(ENV)))$(USER).)
APP_HOST ?= $(patsubst %,$(APP_HOST_PREFIX)%,$(APP_DOMAIN))$(if $(HOST_LB),$(space)$(APP_DOMAIN))
APP_HOST_PREFIX ?= $(addsuffix .,$(if $(STACK_HOST),$(HOSTNAME),$(if $(APP_LB),,$(APP_NAME))))
APP_DOMAIN_PREFIX ?= $(if $(HOST_STACK),,$(addsuffix .,$(if $(APP_HOST_MULTI_ENV),$(filter-out $(ENV_DEPLOY),$(ENV))))$(if $(APP_HOST_MULTI_USER),$(USER).))
APP_HOST ?= $(patsubst %,$(APP_HOST_PREFIX)%,$(APP_DOMAIN))$(if $(HOST_STACK),$(if $(HOST_LB),$(space)$(DOMAIN)))
APP_HOST_PREFIX ?= $(addsuffix .,$(if $(HOST_STACK),$(HOSTNAME),$(if $(APP_HOST_MULTI_APP),$(APP_NAME))))
APP_HOST_MULTI ?= false
APP_HOST_MULTI_APP ?= $(if $(filter true,$(APP_HOST_MULTI)),true)
APP_HOST_MULTI_ENV ?= $(if $(filter true,$(APP_HOST_MULTI)),true)
APP_HOST_MULTI_USER ?= $(if $(filter true,$(APP_HOST_MULTI)),true)
APP_INSTALLED ?= $(APPS)
APP_PARENT ?= $(MONOREPO)
APP_PARENT_DIR ?= $(MONOREPO_DIR)
@ -19,6 +24,7 @@ APP_UPSTREAM_REPOSITORY ?= $(or $(shell git config --get remote.upstream
APP_URI ?= $(patsubst %,%/$(APP_PATH),$(APP_HOST))
APP_URIS ?= $(APP_URI)
APP_URL ?= $(patsubst %,$(APP_SCHEME)://%,$(APP_URI))
APP_VERSION ?= $(VERSION)
CONTEXT += APP APPS BRANCH DOMAIN VERSION RELEASE
CONTEXT_DEBUG += APP_DIR APP_URL APP_REPOSITORY APP_UPSTREAM_REPOSITORY ENV_DEPLOY
ENV_DEPLOY ?= $(patsubst origin/%,%,$(shell git rev-parse --symbolic --remotes=origin |sed '/origin\/HEAD/d' 2>/dev/null))

View File

@ -8,59 +8,59 @@ docker-build: docker-images-myos
# target docker-build-%: Call docker-build for each Dockerfile in docker/% folder
.PHONY: docker-build-%
docker-build-%:
docker-build-%: stack
$(if $(wildcard docker/$*/Dockerfile),$(call docker-build,docker/$*))
$(if $(findstring :,$*),$(eval DOCKER_FILE := $(wildcard docker/$(subst :,/,$*)/Dockerfile)),$(eval DOCKER_FILE := $(wildcard docker/$*/*/Dockerfile)))
$(foreach dockerfile,$(DOCKER_FILE),$(call docker-build,$(dir $(dockerfile)),$(DOCKER_REPOSITORY)/$(word 2,$(subst /, ,$(dir $(dockerfile)))):$(lastword $(subst /, ,$(dir $(dockerfile)))),""))
# target docker-commit: Call docker-commit for each SERVICES
.PHONY: docker-commit
docker-commit:
docker-commit: stack
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-commit,$(service)))
# target docker-commit-%: Call docker-commit with tag % for each SERVICES
.PHONY: docker-commit-%
docker-commit-%:
docker-commit-%: stack
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-commit,$(service),,,$*))
# target docker-compose-build: Fire docker-images-myos, Call docker-compose build SERVICE
.PHONY: docker-compose-build
docker-compose-build: DOCKER_RUN_OPTIONS += -it
docker-compose-build: docker-images-myos
docker-compose-build: docker-images-myos stack
$(call docker-compose,build $(DOCKER_BUILD_ARGS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
# target docker-compose-config: Call docker-compose config
.PHONY: docker-compose-config
docker-compose-config:
docker-compose-config: stack
$(call docker-compose,config)
# target docker-compose-connect: Call docker-compose exec SERVICE DOCKER_SHELL
.PHONY: docker-compose-connect
docker-compose-connect: SERVICE ?= $(DOCKER_SERVICE)
docker-compose-connect: DOCKER_RUN_OPTIONS += -it
docker-compose-connect:
docker-compose-connect: stack
$(call docker-compose,exec $(SERVICE) $(DOCKER_SHELL))
# target docker-compose-down: Call docker-compose rm SERVICE or docker-compose down
.PHONY: docker-compose-down
docker-compose-down: DOCKER_RUN_OPTIONS += -it
docker-compose-down:
docker-compose-down: stack
$(if $(filter $(SERVICE),$(SERVICES)),$(call docker-compose,rm -fs $(SERVICE)),$(call docker-compose,down $(DOCKER_COMPOSE_DOWN_OPTIONS) ||:))
# target docker-compose-exec: Call docker-compose-exec SERVICE ARGS
.PHONY: docker-compose-exec
docker-compose-exec: SERVICE ?= $(DOCKER_SERVICE)
docker-compose-exec:
docker-compose-exec: stack
$(call docker-compose-exec-sh,$(SERVICE),$(ARGS))
# target docker-compose-logs: Call docker-compose logs SERVICE
.PHONY: docker-compose-logs
docker-compose-logs:
$(call docker-compose,logs -f --tail=100 $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
docker-compose-logs: stack
$(call docker-compose,logs $(DOCKER_COMPOSE_LOGS_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
# target docker-compose-ps: Call docker-compose ps
.PHONY: docker-compose-ps
docker-compose-ps:
docker-compose-ps: stack
$(call docker-compose,ps)
# target docker-compose-rebuild: Call docker-compose-build target with DOCKER_BUILD_NO_CACHE=true
@ -74,42 +74,42 @@ docker-compose-recreate: docker-compose-rm docker-compose-up
# target docker-compose-restart: Call docker-compose restart SERVICE
.PHONY: docker-compose-restart
docker-compose-restart:
docker-compose-restart: stack
$(call docker-compose,restart $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
# target docker-compose-rm: Call docker-compose rm SERVICE
.PHONY: docker-compose-rm
docker-compose-rm: DOCKER_RUN_OPTIONS += -it
docker-compose-rm:
docker-compose-rm: stack
$(call docker-compose,rm -fs $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
# target docker-compose-run: Call docker-compose run SERVICE ARGS
.PHONY: docker-compose-run
docker-compose-run: SERVICE ?= $(DOCKER_SERVICE)
docker-compose-run: DOCKER_RUN_OPTIONS += -it
docker-compose-run:
docker-compose-run: stack
$(call docker-compose,run $(DOCKER_COMPOSE_RUN_OPTIONS) $(SERVICE) $(ARGS))
# target docker-compose-scale: Call docker-compose up --scale SERVICE=NUM
.PHONY: docker-compose-scale
docker-compose-scale: SERVICE ?= $(DOCKER_SERVICE)
docker-compose-scale:
docker-compose-scale: stack
$(call docker-compose,up $(DOCKER_COMPOSE_UP_OPTIONS) --scale $(SERVICE)=$(NUM))
# target docker-compose-start: Call docker-compose start SERVICE
.PHONY: docker-compose-start
docker-compose-start:
docker-compose-start: stack
$(call docker-compose,start $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
# target docker-compose-stop: Call docker-compose stop SERVICE
.PHONY: docker-compose-stop
docker-compose-stop:
docker-compose-stop: stack
$(call docker-compose,stop $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
# target docker-compose-up: Fire docker-image-myos, Call docker-compose up SERVICE
.PHONY: docker-compose-up
docker-compose-up: DOCKER_RUN_OPTIONS += -it
docker-compose-up: docker-images-myos bootstrap-stack
docker-compose-up: docker-images-myos bootstrap-stack stack
$(call docker-compose,up $(DOCKER_COMPOSE_UP_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
# target docker-images-myos: Call myos-docker-build-% target for each DOCKER_IMAGES_MYOS
@ -178,7 +178,7 @@ docker-plugin-install:
# target docker-push: Call docker-push for each SERVICES
.PHONY: docker-push
docker-push:
docker-push: stack
ifneq ($(filter $(DEPLOY),true),)
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-push,$(service)))
else
@ -187,7 +187,7 @@ endif
# target docker-push-%: Call docker-push with tag % for each SERVICES
.PHONY: docker-push-%
docker-push-%:
docker-push-%: stack
ifneq ($(filter $(DEPLOY),true),)
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-push,$(service),,$*))
else
@ -231,7 +231,7 @@ docker-run-%: docker-build-%
# target docker-tag: Call docker-tag for each SERVICES
.PHONY: docker-tag
docker-tag:
docker-tag: stack
ifneq ($(filter $(DEPLOY),true),)
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-tag,$(service)))
else
@ -240,7 +240,7 @@ endif
# target docker-tag-%: Call docker-tag with target tag % for each SERVICES
.PHONY: docker-tag-%
docker-tag-%:
docker-tag-%: stack
ifneq ($(filter $(DEPLOY),true),)
$(foreach service,$(or $(SERVICE),$(SERVICES)),$(call docker-tag,$(service),,,,$*))
else

View File

@ -39,14 +39,7 @@ endif
# target setup-ufw: Install ufw-docker
.PHONY: setup-ufw
setup-ufw: COMPOSE_PROJECT_NAME := $(HOST_COMPOSE_PROJECT_NAME)
setup-ufw: DOCKER_RUN_NETWORK :=
setup-ufw: DOCKER_RUN_OPTIONS := --rm -d --cap-add NET_ADMIN -v /etc/ufw:/etc/ufw $(if wildcard /etc/default/ufw,-v /etc/default/ufw:/etc/default/ufw) --network host --restart always
setup-ufw:
setup-ufw: ufw-install ufw-bootstrap ufw-build ufw-up
ifeq ($(SETUP_UFW),true)
$(call app-install,$(SETUP_UFW_REPOSITORY))
$(call app-bootstrap,$(lastword $(subst /, ,$(SETUP_UFW_REPOSITORY))))
$(call app-build)
$(call app-up)
$(call ufw-docker,install)
endif

View File

@ -3,6 +3,20 @@
ufw:
$(call ufw,$(ARGS))
# target ufw-bootstrap: Eval ufw-docker app variables
ufw-bootstrap:
$(eval APP_COMPOSE_FILE :=)
$(eval DOCKER_COMPOSE_PROJECT_NAME := $(HOST_COMPOSE_PROJECT_NAME))
$(eval DOCKER_SERVICE := ufw-docker)
$(eval DOCKER_STACK :=)
$(eval MYOS_STACK :=)
$(eval MYOS_STACK_FILE :=)
$(call app-bootstrap,$(lastword $(subst /, ,$(SETUP_UFW_REPOSITORY))))
# target ufw-build: Build ufw-docker docker
ufw-build:
$(call app-build)
# target ufw-delete: Fire ufw-update UFW_DELETE=true
.PHONY: ufw-delete
ufw-delete: UFW_DELETE := true
@ -13,23 +27,36 @@ ufw-delete: ufw-update
ufw-docker:
$(call ufw-docker,$(ARGS))
# target ufw-docker: Call ufw and ufw-docker foreach service UFW_UPDATE
# target ufw-install: Download ufw-docker application
ufw-install:
$(call app-install,$(SETUP_UFW_REPOSITORY))
# target ufw-up: Start ufw-docker docker
ufw-up: DOCKER_RUN_NETWORK :=
ufw-up: DOCKER_RUN_OPTIONS := --restart always -d --cap-add NET_ADMIN -v /etc/ufw:/etc/ufw $(if wildcard /etc/default/ufw,-v /etc/default/ufw:/etc/default/ufw) --network host
ufw-up:
$(call app-up)
# target ufw-update: Call ufw and ufw-docker foreach service UFW_UPDATE
.PHONY: ufw-update
ufw-update: debug-UFW_UPDATE
$(eval name := $(COMPOSE_PROJECT_NAME))
ufw-update: stack $(if $(HOST_STACK),setup-ufw) debug-UFW_UPDATE
$(eval APP_COMPOSE_FILE :=)
$(eval DOCKER_SERVICE := ufw-docker)
$(eval project_name := $(COMPOSE_PROJECT_NAME))
$(foreach UPDATE,$(call UPPERCASE,$(UFW_UPDATE)), \
$(eval ufw_update := $($(if $(STACK_HOST),HOST_)$(UPDATE)_UFW_UPDATE)) \
$(eval ufw_docker := $($(if $(STACK_HOST),HOST_)$(UPDATE)_UFW_DOCKER)) \
$(eval ufw_update := $($(if $(HOST_STACK),HOST_)$(UPDATE)_UFW_UPDATE)) \
$(eval ufw_docker := $($(if $(HOST_STACK),HOST_)$(UPDATE)_UFW_DOCKER)) \
$(foreach port,$(ufw_docker), \
$(call ufw-docker,$(if $(UFW_DELETE),delete) allow $(name)-$(call LOWERCASE,$(UPDATE)) $(port) ||:) \
$(call ufw-docker,$(if $(UFW_DELETE),delete) allow $(project_name)-$(call LOWERCASE,$(UPDATE))$(if $(HOST_STACK),,-1) $(port) ||:) \
) \
$(foreach port,$(ufw_update), \
$(call ufw,$(if $(UFW_DELETE),delete) allow $(port)) \
) \
)
# target ufw-%: Call ufw target for specific stack
## ex: ufw-host-update will update ufw rules for stack host
.PHONY: stack-%
.PHONY: ufw-%
ufw-%:
$(eval stack := $(subst -$(lastword $(subst -, ,$*)),,$*))
$(eval command := $(lastword $(subst -, ,$*)))

View File

@ -10,10 +10,20 @@ $(APP): myos-user
# target app-%: Call app-$(command) for APP in APP_DIR
## it splits % on dashes and extracts app from the beginning and command from the last part of %
## ex: app-foo-build will call app-build for app foo in ../foo
## it includes apps/$(app)/*.mk file and hydrates APP_* variables
## ex: APP_REPOSITORY_URL is set with value from variable $(APP)_REPOSITORY_URL
.PHONY: app-%
app-%:
$(eval app := $(subst -$(lastword $(subst -, ,$*)),,$*))
$(eval command := $(lastword $(subst -, ,$*)))
$(eval COMPOSE_FILE :=)
$(eval STACK :=)
$(eval app := $(subst -$(lastword $(subst -, ,$*)),,$*))
$(eval command := $(lastword $(subst -, ,$*)))
$(eval include $(wildcard apps/def.mk apps/$(app).mk apps/$(app)/*.mk))
$(foreach var,$(filter $(call UPPERCASE,$(app))_%,$(MAKE_FILE_VARS)), \
$(if $(filter $(subst $(call UPPERCASE,$(app))_,APP_,$(var)),$(MAKE_FILE_VARS)), \
$(eval $(subst $(call UPPERCASE,$(app))_,APP_,$(var)) := $($(var))) \
) \
)
$(if $(wildcard $(RELATIVE)$(app)), \
$(if $(filter app-$(command),$(.VARIABLES)), \
$(call app-bootstrap,$(app)) \
@ -26,7 +36,11 @@ app-%:
) \
) \
, \
$(call WARNING,Unable to find app,$(app),in dir,$(RELATIVE)$(app)) \
$(if $($(call UPPERCASE,$(APP))_REPOSITORY_URL), \
$(call app-install) \
$(call app-bootstrap) \
,$(call WARNING,Unable to find app,$(app),in dir,$(RELATIVE)$(app)) \
) \
)
# target app-required-install: Call app-install for each APP_REQUIRED

View File

@ -3,10 +3,13 @@ MAKECMDARGS += app-%-exec app-%-run
# function app-attach: Call docker-attach for each Dockerfile in dir 1
define app-attach
$(call INFO,app-attach,$(1)$(comma))
$(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-attach)
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,logs -f $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-attach)
)
)
endef
@ -16,30 +19,63 @@ define app-bootstrap
$(eval APP := $(or $(1), $(APP)))
$(eval APP_DIR := $(or $(2), $(RELATIVE)$(APP)))
$(eval APP_NAME := $(or $(3),$(subst -,,$(subst .,,$(call LOWERCASE,$(APP))))))
$(eval COMPOSE_FILE := $(wildcard $(APP_DIR)/docker-compose.yml $(APP_DIR)/docker-compose.$(ENV).yml $(APP_DIR)/docker/docker-compose.yml $(foreach file,$(patsubst $(APP_DIR)/docker/docker-compose.%,%,$(basename $(wildcard $(APP_DIR)/docker/docker-compose.*.yml))),$(if $(filter true,$(COMPOSE_FILE_$(file)) $(COMPOSE_FILE_$(call UPPERCASE,$(file)))),$(APP_DIR)/docker/docker-compose.$(file).yml))))
$(eval COMPOSE_PROJECT_NAME := $(or $(DOCKER_COMPOSE_PROJECT_NAME),$(subst .,,$(call LOWERCASE,$(USER)-$(APP_NAME)-$(ENV)$(addprefix -,$(subst /,,$(subst -,,$(APP_PATH))))))))
$(eval COMPOSE_SERVICE_NAME := $(or $(DOCKER_COMPOSE_SERVICE_NAME),$(subst _,-,$(COMPOSE_PROJECT_NAME))))
$(eval DOCKER_BUILD_DIR := $(APP_DIR))
$(if $(wildcard $(APP_DIR)/.env.dist), $(call .env,$(APP_DIR)/.env,$(APP_DIR)/.env.dist))
$(if $(wildcard $(APP_DIR)/.env.example), $(call .env,$(APP_DIR)/.env,$(APP_DIR)/.env.example))
$(if $(wildcard $(APP_DIR)/.env.sample), $(call .env,$(APP_DIR)/.env,$(APP_DIR)/.env.sample))
$(call compose-file,$(APP_DIR) $(APP_DIR)/$(or $(APP_DOCKER_DIR),$(DOCKER_DIR)),docker-compose)
$(call compose-file,apps apps/$(APP),$(APP))
$(eval APP_COMPOSE_FILE ?= $(COMPOSE_FILE))
$(foreach stackz,$(or $(DOCKER_STACK),$(STACK)),$(call docker-stack,$(stackz)))
$(call compose-file,$(MYOS_STACK),$(MYOS_STACK_FILE))
$(call .env,$(APP_DIR)/.env,$(APP_DIR)/.env.dist $(APP_DIR)/.env.example $(APP_DIR)/.env.sample)
endef
# function app-build: Call docker-build for each Dockerfile in dir 1
define app-build
$(call INFO,app-build,$(1)$(comma))
$(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-build, $(dir $(dockerfile)), $(DOCKER_IMAGE), "" )
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,build $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-build, $(dir $(dockerfile)), $(DOCKER_IMAGE), "" )
)
)
endef
# function app-clean: Remove docker images and volumes for each Dockerfile in dir 1
define app-clean
$(call INFO,app-clean,$(1)$(comma))
$(eval DOCKER_COMPOSE_DOWN_OPTIONS += --rmi all --volumes)
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,down $(DOCKER_COMPOSE_DOWN_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-rm)
)
)
endef
# function app-config: Call docker-compose config with each docker-compose.yml in dir 1
define app-config
$(call INFO,app-config,$(1)$(comma))
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,config)
, $(call WARNING,Unable to find a file docker-compose.yml in dir,$(APP_DIR)) \
)
endef
# function app-connect: Call docker exec $(DOCKER_SHELL) for each Dockerfile in dir 1
define app-connect
$(call INFO,app-connect,$(1)$(comma))
$(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-connect)
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,exec $(or $(SERVICE),$(DOCKER_SERVICE)) $(DOCKER_SHELL))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-connect)
)
)
endef
@ -50,7 +86,7 @@ define app-docker
$(eval dockerfile := $(or $(1)))
$(if $(wildcard $(dockerfile)),
$(eval service := $(or $(DOCKER_SERVICE),$(subst .,,$(call LOWERCASE,$(lastword $(subst /, ,$(patsubst %/Dockerfile,%,$(dockerfile)))))),undefined))
$(eval docker := ${COMPOSE_SERVICE_NAME}-$(service))
$(eval docker := $(or $(DOCKER_COMPOSE_SERVICE_NAME),$(COMPOSE_SERVICE_NAME))-$(service))
$(eval DOCKER_IMAGE := $(DOCKER_REPOSITORY)/$(service):$(DOCKER_IMAGE_TAG))
$(eval DOCKER_LABELS := SERVICE_NAME=$(docker) SERVICE_TAGS=$(call urlprefix,$(APP_PATH),,$(service).$(APP_HOST)))
$(eval DOCKER_NAME := $(docker))
@ -62,54 +98,66 @@ endef
# function app-down: Call docker rm for each Dockerfile in dir 1
define app-down
$(call INFO,app-down,$(1)$(comma))
$(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-rm)
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,down $(DOCKER_COMPOSE_DOWN_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-rm)
)
)
endef
# function app-exec: Call docker exec $(ARGS) for each Dockerfile in dir 1
define app-exec
$(call INFO,app-exec,$(1)$(comma) $(2))
$(call docker-file,$(1))
$(eval args := $(or $(2), $(ARGS)))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call exec,$(args))
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,exec $(or $(SERVICE),$(DOCKER_SERVICE)) $(args))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call exec,$(args))
)
)
endef
# function app-install: Run 'git clone url 1 dir 2'
define app-install
$(call INFO,app-install,$(1)$(comma) $(2))
$(eval url := $(or $(1), $(APP_REPOSITORY_URL)))
$(eval url := $(or $(1), $(REPOSITORY_URL), $(APP_REPOSITORY_URL)))
$(eval dir := $(or $(2), $(RELATIVE)$(lastword $(subst /, ,$(url)))))
$(if $(wildcard $(dir)/.git),
$(call INFO,app $(url) already installed in dir $(dir))
, $(RUN) git clone $(QUIET) $(url) $(dir)
, $(RUN) git clone $(QUIET) $(url) $(dir) && if [ -n "$(APP_VERSION)" ]; then cd $(dir) && git reset --hard $(QUIET) "$(APP_VERSION)"; fi
)
endef
# function app-logs: Call docker logs $(ARGS) for each Dockerfile in dir 1
define app-logs
$(call INFO,app-logs,$(1)$(comma) $(2))
$(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-logs)
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,logs $(DOCKER_COMPOSE_LOGS_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-logs)
)
)
endef
# function app-ps: Call docker ps for each Dockerfile in dir 1
define app-ps
$(call INFO,app-ps,$(1)$(comma))
$(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(eval DOCKERS += $(DOCKER_NAME))
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,ps $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(eval DOCKERS += $(DOCKER_NAME))
)
$(RUN) docker ps $(patsubst %,-f name=%,$(DOCKERS)) 2>/dev/null
)
$(RUN) docker ps $(patsubst %,-f name=%,$(DOCKERS)) 2>/dev/null
endef
# function app-rebuild: Call app-build with DOCKER_BUILD_CACHE=false
@ -119,17 +167,65 @@ define app-rebuild
$(call app-build,$(1))
endef
# function app-restart: Call app-stop and app-start
define app-restart
$(call INFO,app-restart,$(1)$(comma))
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,restart $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
, $(call app-stop,$(1)) # NEED FIX
$(call app-start,$(1))
)
endef
# function app-run: Call docker-run for each Dockerfile in dir 1 with args 2
define app-run
$(call INFO,app-run,$(1)$(comma) $(2))
$(call docker-file,$(1))
$(eval args := $(or $(2), $(ARGS)))
$(eval DOCKER_RUN_OPTIONS += -it)
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(if $(shell docker images -q $(DOCKER_IMAGE) 2>/dev/null),
$(call docker-run,$(DOCKER_IMAGE),$(args))
, $(call ERROR,Unable to find docker image,$(DOCKER_IMAGE))
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,run $(DOCKER_RUN_OPTIONS) $(or $(SERVICE),$(DOCKER_SERVICE)) $(args))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(if $(shell docker images -q $(DOCKER_IMAGE) 2>/dev/null),
$(call docker-run,$(DOCKER_IMAGE),$(args))
, $(call ERROR,Unable to find docker image,$(DOCKER_IMAGE))
)
)
)
endef
# function app-scale: Call docker-compose scale in dir 1
define app-scale
$(call INFO,app-scale,$(1)$(comma))
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,up $(DOCKER_COMPOSE_UP_OPTIONS) --scale $(or $(SERVICE),$(DOCKER_SERVICE))=$(NUM))
, $(call WARNING,Unable to find a file docker-compose.yml in dir,$(APP_DIR)) \
)
endef
# function app-start: Call docker start for each Dockerfile in dir 1
define app-start
$(call INFO,app-start,$(1)$(comma))
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,start $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-start)
)
)
endef
# function app-stop: Call docker stop for each Dockerfile in dir 1
define app-stop
$(call INFO,app-stop,$(1)$(comma))
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,stop $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
, $(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
$(call docker-stop)
)
)
endef
@ -137,20 +233,23 @@ endef
# function app-up: Call docker-run (-d) for each Dockerfile in dir 1
define app-up
$(call INFO,app-up,$(1)$(comma))
$(eval DOCKER_RUN_OPTIONS += -d)
$(if $(shell docker ps -q -f name=$(DOCKER_NAME) 2>/dev/null),
$(call INFO,docker $(DOCKER_NAME) already running)
, $(call app-run,$(1))
$(eval DOCKER_RUN_OPTIONS := -d)
$(if $(APP_COMPOSE_FILE),
$(call docker-compose,up $(DOCKER_COMPOSE_UP_OPTIONS) $(if $(filter $(SERVICE),$(SERVICES)),$(SERVICE)))
, $(if $(shell docker ps -q -f name=$(DOCKER_NAME) 2>/dev/null),
$(call INFO,docker $(DOCKER_NAME) already running)
, $(call app-run,$(1))
)
)
endef
# function app-update: Run 'cd dir 1 && git pull' or Call app-install
define app-update
$(call INFO,app-update,$(1)$(comma) $(2))
$(eval url := $(or $(1), $(APP_REPOSITORY_URL)))
$(eval url := $(or $(1), $(REPOSITORY_URL), $(APP_REPOSITORY_URL)))
$(eval dir := $(or $(2), $(APP_DIR)))
$(if $(wildcard $(dir)/.git),
$(RUN) sh -c 'cd $(dir) && git pull $(QUIET)'
$(RUN) sh -c 'cd $(dir) && git pull $(QUIET) && if [ -n "$(APP_VERSION)" ]; then git reset --hard $(QUIET) "$(APP_VERSION)"; fi'
, $(call app-install,$(url),$(dir))
)
endef

View File

@ -1,10 +1,11 @@
DOCKER_DIR ?= docker
DOCKER_ENV_ARGS ?= $(docker_env_args)
DOCKER_EXEC_OPTIONS ?=
DOCKER_GID ?= $(call gid,docker)
DOCKER_IMAGE ?= $(USER_DOCKER_IMAGE)
DOCKER_MACHINE ?= $(shell docker run --rm alpine uname -m 2>/dev/null)
DOCKER_MACHINE := $(shell docker run --rm alpine uname -m 2>/dev/null)
DOCKER_NAME ?= $(USER_DOCKER_NAME)
DOCKER_NETWORK ?= $(if $(STACK_USER),$(USER),$(DOCKER_NETWORK_PRIVATE))
DOCKER_NETWORK ?= $(if $(USER_STACK),$(USER),$(DOCKER_NETWORK_PRIVATE))
DOCKER_NETWORK_PRIVATE ?= $(USER)-$(ENV)
DOCKER_NETWORK_PUBLIC ?= $(HOSTNAME)
# DOCKER_RUN: if empty, run system command, else run it in a docker
@ -15,7 +16,7 @@ DOCKER_RUN_NETWORK += --network $(DOCKER_NETWORK)
DOCKER_RUN_OPTIONS += --rm
DOCKER_RUN_VOLUME ?= $(patsubst %,-v %,$(DOCKER_VOLUME))
DOCKER_RUN_WORKDIR ?= $(if $(DOCKER_WORKDIR),-w $(DOCKER_WORKDIR))
DOCKER_SYSTEM ?= $(shell docker run --rm alpine uname -s 2>/dev/null)
DOCKER_SYSTEM := $(shell docker run --rm alpine uname -s 2>/dev/null)
DOCKER_VOLUME ?= /var/run/docker.sock:/var/run/docker.sock
DOCKER_WORKDIR ?= $(PWD)
ENV_VARS += DOCKER_MACHINE DOCKER_NETWORK DOCKER_NETWORK_PRIVATE DOCKER_NETWORK_PUBLIC DOCKER_SYSTEM HOST_COMPOSE_PROJECT_NAME HOST_COMPOSE_SERVICE_NAME HOST_DOCKER_REPOSITORY HOST_DOCKER_VOLUME HOST_GID HOST_UID USER_COMPOSE_PROJECT_NAME USER_COMPOSE_SERVICE_NAME USER_DOCKER_IMAGE USER_DOCKER_NAME USER_DOCKER_REPOSITORY USER_DOCKER_VOLUME
@ -25,15 +26,17 @@ HOST_DOCKER_REPOSITORY ?= $(subst -,/,$(subst _,/,$(HOST_COMPOSE_PROJEC
HOST_DOCKER_VOLUME ?= $(HOST_COMPOSE_PROJECT_NAME)
HOST_GID ?= 100
HOST_UID ?= 123
HOST_STACK ?= $(filter host,$(firstword $(subst /, ,$(STACK))))
MYOS_STACK ?= $(MYOS)/stack/myos
MYOS_STACK_FILE ?= networks volumes
RESU_DOCKER_REPOSITORY ?= $(subst -,/,$(USER_COMPOSE_PROJECT_NAME))
STACK_HOST ?= $(filter host,$(firstword $(subst /, ,$(STACK))))
STACK_USER ?= $(filter User,$(firstword $(subst /, ,$(STACK))))
USER_COMPOSE_PROJECT_NAME ?= $(subst .,-,$(RESU))
USER_COMPOSE_SERVICE_NAME ?= $(USER_COMPOSE_PROJECT_NAME)
USER_DOCKER_IMAGE ?= $(USER_DOCKER_REPOSITORY):${DOCKER_IMAGE_TAG}
USER_DOCKER_NAME ?= $(USER_COMPOSE_PROJECT_NAME)
USER_DOCKER_REPOSITORY ?= $(subst -,/,$(subst _,/,$(USER)))
USER_DOCKER_VOLUME ?= $(USER_COMPOSE_PROJECT_NAME)
USER_STACK ?= $(filter User,$(firstword $(subst /, ,$(STACK))))
# https://github.com/docker/libnetwork/pull/2348
ifeq ($(SYSTEM),Darwin)
@ -156,15 +159,20 @@ endef
define docker-file
$(call INFO,docker-file,$(1)$(comma))
$(eval dir := $(or $(1),$(APP_DIR)))
$(eval DOCKER_FILE := $(wildcard $(dir)/docker/*/Dockerfile $(dir)/*/Dockerfile $(dir)/Dockerfile))
$(eval DOCKER_FILE := $(wildcard $(dir)/$(DOCKER_DIR)/*/Dockerfile $(dir)/$(DOCKER_DIR)/Dockerfile $(dir)/Dockerfile))
$(if $(DOCKER_FILE),
, $(call ERROR,Unable to find a,Dockerfile,in dir,$(dir))
)
endef
# function docker-exited: Print exited dockers matching DOCKER_NAME
define docker-exited
$(shell docker ps -q -f status=exited $(patsubst %,-f name=%,$(or $(1), ^$(DOCKER_NAME)$$, ^$)) 2>/dev/null)
endef
# function docker-running: Print running dockers matching DOCKER_NAME
define docker-running
$(shell docker ps -q $(patsubst %,-f name=%,$(or $(1), ^$(DOCKER_NAME)$$, ^$)) 2>/dev/null)
$(shell docker ps -q -f status=running $(patsubst %,-f name=%,$(or $(1), ^$(DOCKER_NAME)$$, ^$)) 2>/dev/null)
endef
# function docker-rm: Remove docker 1
@ -177,6 +185,29 @@ define docker-rm
$(RUN) docker rm -f $(rm)
endef
# function docker-start: Start docker 1
define docker-start
$(call INFO,docker-start,$(1)$(comma))
$(eval start := $(or $(1),$(DOCKER_NAME)))
$(if $(call docker-running,^$(start)$),
$(call WARNING,docker,$(start),is already running)
, $(if $(call docker-exited,^$(start)$),
$(RUN) docker start $(start)
, $(call WARNING,Unable to find docker,$(start),in state exited)
)
)
endef
# function docker-stop: Stop docker 1
define docker-stop
$(call INFO,docker-stop,$(1)$(comma))
$(eval stop := $(or $(1),$(DOCKER_NAME)))
$(if $(call docker-running,^$(stop)$),
$(RUN) docker stop $(stop)
, $(call WARNING,docker,$(stop),is not running)
)
endef
# function docker-volume-copy: Copy files from a docker volume to another
define docker-volume-copy
$(call INFO,docker-volume-copy,$(1)$(comma) $(2))

View File

@ -78,7 +78,7 @@ INSTALL_CMDS ?= APK_INSTALL APT_INSTALL
$(foreach cmd,$(INSTALL_CMDS),$(if $(CMD_$(cmd)),$(eval INSTALL_CMD ?= $(CMD_$(cmd)))))
LOG_LEVEL ?= $(if $(DEBUG),debug,$(if $(VERBOSE),info,error))
MAIL ?= $(GIT_AUTHOR_EMAIL)
MAKE_ARGS ?= $(foreach var,$(MAKE_VARS),$(if $($(var)),$(var)='$($(var))'))
MAKE_ARGS = $(foreach var,$(MAKE_VARS),$(if $($(var)),$(var)='$($(var))'))
MAKE_SUBDIRS ?= $(if $(filter myos,$(MYOS)),monorepo,$(if $(APP),apps $(foreach type,$(APP_LOAD),$(if $(wildcard $(MAKE_DIR)/apps/$(type)),apps/$(type)))))
MAKE_CMD_ARGS ?= $(foreach var,$(MAKE_CMD_VARS),$(var)='$($(var))')
MAKE_CMD_VARS ?= $(strip $(foreach var, $(filter-out .VARIABLES,$(.VARIABLES)), $(if $(filter command\ line,$(origin $(var))),$(var))))
@ -90,7 +90,7 @@ MAKE_OLDFILE ?= $@
MAKE_TARGETS ?= $(filter-out $(.VARIABLES),$(shell $(MAKE) -qp 2>/dev/null |awk -F':' '/^[a-zA-Z0-9][^$$\#\/\t=]*:([^=]|$$)/ {print $$1}' 2>/dev/null |sort -u))
MAKE_UNIXTIME_START := $(shell date -u +'%s' 2>/dev/null)
MAKE_UNIXTIME_CURRENT = $(shell date -u "+%s" 2>/dev/null)
MAKE_VARS ?= ENV
MAKE_VARS := ENV COMPOSE_FILE DOCKER_COMPOSE DOCKER_MACHINE DOCKER_SERVICES DOCKER_SYSTEM
MAKECMDARGS ?= apps-install install-app
MONOREPO ?= $(if $(filter myos,$(MYOS)),$(notdir $(CURDIR)),$(if $(APP),$(notdir $(realpath $(CURDIR)/..))))
MONOREPO_DIR ?= $(if $(MONOREPO),$(if $(filter myos,$(MYOS)),$(realpath $(CURDIR)),$(if $(APP),$(realpath $(CURDIR)/..))))
@ -126,13 +126,13 @@ endif
# Guess OS
ifeq ($(OSTYPE),cygwin)
SYSTEM := cygwin
SYSTEM ?= cygwin
else ifeq ($(OS),Windows_NT)
SYSTEM := Windows_NT
SYSTEM ?= Windows_NT
else
SYSTEM := $(shell uname -s 2>/dev/null)
SYSTEM ?= $(shell uname -s 2>/dev/null)
endif
MACHINE := $(shell uname -m 2>/dev/null)
MACHINE ?= $(shell uname -m 2>/dev/null)
ifeq ($(SYSTEM),Darwin)
SED_SUFFIX := ''
@ -225,6 +225,12 @@ force = $$(while true; do \
# macro gid: Return GID of group 1
gid = $(shell awk -F':' '$$1 == "$(1)" {print $$3}' /etc/group 2>/dev/null)
# macro newer: Return the newest file
newer = $(shell stat -c '%Y %n' $(1) $(2) $(if $(DEBUG),,2>/dev/null) |sort -n |tail -n1 |awk '{print $$2}')
# older newer: Return the oldest file
older = $(shell stat -c '%Y %n' $(1) $(2) $(if $(DEBUG),,2>/dev/null) |sort -n |head -n1 |awk '{print $$2}')
# macro pop: Return last word of string 1 according to separator 2
pop = $(patsubst %$(or $(2),/)$(lastword $(subst $(or $(2),/), ,$(1))),%,$(1))

View File

@ -2,8 +2,9 @@
# ENV
# target .env: Update file .env
## it updates file .env when file .env.dist is newer
.env: .env.dist
## it updates file .env
.PHONY: .env
.env:
$(call .env,,,$(wildcard $(CONFIG)/$(ENV)/$(APP)/.env .env.$(ENV)))
# target .env-clean: Remove file .env
@ -33,23 +34,25 @@ docker.env.file ?= $(patsubst %,--env-file %,$(wildcard $(ENV_FILE)))
docker_env_args = $(docker.env.args) $(docker.env.dist) $(docker.env.file)
env.args = $(foreach var,$(ENV_VARS),$(if $($(var)),$(var)='$($(var))'))
env.dist ?= $(shell printenv |awk -F '=' 'NR == FNR { if($$1 !~ /^(\#|$$)/) { A[$$1]; next } } ($$1 in A)' .env.dist - 2>/dev/null)
env.file ?= $(shell cat $(or $(ENV_FILE),/dev/null) 2>/dev/null |sed '/^[ \t]*$$/d;/^[ \t]*\#/d;s/='\''/=/;s/'\''$$//;s/='\"'/=/;s/'\"'$$//;' |awk -F '=' '{print $$1"='\''"$$2"'\''"}')
env.file ?= $(shell cat $(or $(ENV_FILE),/dev/null) 2>/dev/null |sed '/^[ \t]*$$/d;/^[ \t]*\#/d;s/='\''/=/;s/'\''$$//;s/='\"'/=/;s/'\"'$$//;s/=/='\''/;s/$$/'\''/;')
env_args = $(env.args) $(env.dist) $(env.file)
SHELL:=/bin/bash
# function .env: Call .env_update function
## it sets .env, .env.dist and .env.ENV files paths
## it calls .env_update function if .env.dist file exists
## it calls .env_update function if .env.dist exists and is newer than .env
## of when file .env does not exist
# 1st arg: path to .env file to update, default to .env
# 2nd arg: path to .env.dist file, default to .env.dist
# 3rd arg: path to .env override files, default to .env.$(ENV)
define .env
$(call INFO,.env,$(1)$(comma) $(2)$(comma) $(3))
$(eval env_file:=$(or $(1),.env))
$(eval env_dist:=$(or $(2),$(env_file).dist))
$(eval env_over:=$(or $(wildcard $(3)),$(wildcard $(env_file).$(ENV))))
$(if $(wildcard $(env_dist)), $(call .env_update))
$(eval env_dists:=$(wildcard $(or $(2),$(env_file).dist)))
$(eval env_over:=$(wildcard $(or $(3),$(env_file).$(ENV))))
$(if $(FORCE)$(filter $(env_file),$(call newer,$(env_file) $(env_dists) $(env_over))),
,$(foreach env_dist,$(env_dists),$(call .env_update)))
endef
# function .env_update: Update .env file with values from .env.dist
@ -80,7 +83,7 @@ endef
# add variables definition to the .env file
define .env_update
$(call INFO,.env_update,$(env_file)$(comma) $(env_dist)$(comma) $(env_over))
touch $(env_file) $(if $(VERBOSE)$(DEBUG),,2> /dev/null)
touch $(env_file) $(if $(VERBOSE)$(DEBUG),,2> /dev/null) ||:
printenv \
|awk -F '=' 'NR == FNR { if($$1 !~ /^(#|$$)/) { A[$$1]; next } } !($$1 in A)' - $(env_dist) \
|cat $(env_over) - \
@ -98,5 +101,5 @@ define .env_update
awk '{while(match($$0,"[$$]{[^}]*}")) {var=substr($$0,RSTART+2,RLENGTH-3);gsub("[$$]{"var"}",ENVIRON[var])} print}') \
|sed -e /^$$/d -e /^#/d \
|sort \
>> $(env_file);
>> $(env_file) $(if $(VERBOSE)$(DEBUG),,2> /dev/null) ||:;
endef

View File

@ -18,7 +18,7 @@ contexts: $(foreach var,$(CONTEXT),context-$(var))
# target context-% print-%: Print % value
.PHONY: context-% print-%
context-% print-%:
context-% print-%: stack
@printf "${COLOR_HIGHLIGHT}%-37s${COLOR_RESET}" $*
@printf "${COLOR_VALUE}"
@$(call PRINTF,$($*))

View File

@ -12,15 +12,15 @@ MAKE_LATEST := $(MAKE_DIR)/end.mk
## it includes $(MAKE_FIRST)
include $(wildcard $(MAKE_FIRST))
## it includes $(MAKE_DIR)/*/def.mk $(MAKE_DIR)/*/def.*.mk
## it includes $(MAKE_DIR)/$(MAKE_SUBDIRS)/def.mk $(MAKE_DIR)/$(MAKE_SUBDIRS)/def.*.mk
include $(foreach subdir,$(MAKE_SUBDIRS),$(wildcard $(MAKE_DIR)/$(subdir)/def.mk $(MAKE_DIR)/$(subdir)/def.*.mk))
## it includes def.mk def.*.mk */def.mk */def.*.mk if not myos nor monorepo
## if not in $(MYOS) nor $(MONOREPO), it includes def.mk def.*.mk */def.mk */def.*.mk
include $(if $(filter-out . myos,$(MYOS)),$(wildcard def.mk def.*.mk */def.mk */def.*.mk))
## it includes $(MAKE_DIR)/*.mk
include $(filter-out $(wildcard $(MAKE_FILE) $(MAKE_FIRST) $(MAKE_LATEST)),$(wildcard $(MAKE_DIR)/*.mk))
## it includes $(MAKE_DIR)/*/*.mk
## it includes $(MAKE_DIR)/$(MAKE_SUBDIRS)/*.mk
include $(foreach subdir,$(MAKE_SUBDIRS),$(filter-out $(wildcard $(MAKE_DIR)/$(subdir)/def.mk $(MAKE_DIR)/$(subdir)/def.*.mk),$(wildcard $(MAKE_DIR)/$(subdir)/*.mk)))
## it includes *.mk */*.mk if not myos nor monorepo, stack/*.mk if myos
## if not in $(MYOS) nor $(MONOREPO), it includes *.mk */*.mk, else stack/*.mk if in $(MYOS)
include $(if $(filter-out myos,$(MYOS)),$(if $(filter-out .,$(MYOS)),$(filter-out $(wildcard def.mk def.*.mk */def.mk */def.*.mk),$(wildcard *.mk */*.mk)),$(wildcard stack/*.mk stack/*/*.mk)))
## it includes $(MAKE_LATEST)
include $(wildcard $(MAKE_LATEST))

View File

@ -5,6 +5,7 @@
#
################################################################################
# source : https://raw.githubusercontent.com/buildroot/buildroot/master/support/misc/utils.mk
# customized for myos
# Strip quotes and then whitespaces
qstrip = $(strip $(subst ",,$(1)))
@ -14,6 +15,8 @@ qstrip = $(strip $(subst ",,$(1)))
comma := ,
empty :=
space := $(empty) $(empty)
tab := $(empty) $(empty)
escape := $(shell printf '\x1b')
# make 4.3:
# https://lwn.net/Articles/810071/
@ -69,6 +72,7 @@ reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1))) $(firstword
# and in rules. Particularly useful for VCS version strings, that can contain
# slashes, colons (OK in filenames but not in rules), and spaces.
sanitize = $(subst $(space),_,$(subst :,_,$(subst /,_,$(strip $(1)))))
# customized for myos: slugify macro cleans up strings so it can be used as url
slugify = $(subst $(space),,$(subst :,,$(subst /,,$(subst .,,$(1)))))
# MESSAGE Macro -- display a message in bold type
@ -86,9 +90,17 @@ finddirclauses = $(call notfirstword,$(patsubst %,-o -path '$(1)/%',$(2)))
# notfirstword(wordlist): returns all but the first word in wordlist
notfirstword = $(wordlist 2,$(words $(1)),$(1))
# build a comma-separated list of quoted items, from a space-separated
# build a comma-separated list of items, from a space-separated
# list of items: a b c d --> a, b, c, d
make-comma-list = $(subst $(space),$(comma)$(space),$(strip $(1)))
# build a comma-separated list of double-quoted items, from a space-separated
# list of unquoted items: a b c d --> "a", "b", "c", "d"
make-comma-list = $(subst $(space),$(comma)$(space),$(patsubst %,"%",$(strip $(1))))
make-dq-comma-list = $(call make-comma-list,$(patsubst %,"%",$(strip $(1))))
# build a comma-separated list of single-quoted items, from a space-separated
# list of unquoted items: a b c d --> 'a', 'b', 'c', 'd'
make-sq-comma-list = $(call make-comma-list,$(patsubst %,'%',$(strip $(1))))
# Needed for the foreach loops to loop over the list of hooks, so that
# each hook call is properly separated by a newline.
@ -124,10 +136,10 @@ QUOTE = '
# (that's why the single-quotes are escaped they way they are, above,
# and why the dollar sign is not escaped) to printf(1). A trailing
# newline is apended, too.
# Note: Removing the apended trailing newline for custom needs
#
# Note: leading or trailing spaces are *not* stripped.
#
# customized for myos: Removing the trailing newline
define PRINTF
printf '$(subst $(sep),\n,\
$(subst $(PERCENT),$(PERCENT)$(PERCENT),\

View File

@ -49,8 +49,3 @@ volumes:
user:
external: true
name: ${USER_DOCKER_VOLUME}
networks:
private:
external: true
name: ${DOCKER_NETWORK}

View File

@ -88,17 +88,9 @@ services:
soft: 65536
hard: 65536
volumes:
- host:/home:delegated
- home:/home:delegated
volumes:
host:
home:
external: true
name: ${HOST_DOCKER_VOLUME}_home
networks:
private:
external: true
name: ${DOCKER_NETWORK}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -0,0 +1,35 @@
version: '3.6'
services:
apprise:
image: caronc/apprise:latest
environment:
- APPRISE_STATELESS_URLS
- APPRISE_CONFIG_LOCK=${APPRISE_CONFIG_LOCK:-true}
labels:
- SERVICE_8000_CHECK_HTTP=${APPRISE_SERVICE_8000_CHECK_HTTP:-/}
- SERVICE_8000_NAME=${COMPOSE_SERVICE_NAME:-alerting}-apprise-8000
- SERVICE_8000_TAGS=${APPRISE_SERVICE_8000_TAGS:-urlprefix-localhost/apprise/*}
networks:
- public
restart: always
volumes:
- apprise:/config
apprise-webhook:
image: zzeneg/apprise-webhook
environment:
- APPRISE_URL=http://apprise:8000/notify
- TEMPLATE=alertmanager
labels:
# - SERVICE_3000_CHECK_HTTP=${APPRISE_WEBHOOK_SERVICE_3000_CHECK_HTTP:-/}
# - SERVICE_3000_CHECK_HTTP_METHOD=${APPRISE_WEBHOOK_SERVICE_3000_CHECK_HTTP_METHOD:-POST}
- SERVICE_3000_CHECK_TCP=${APPRISE_WEBHOOK_SERVICE_3000_CHECK_TCP:-true}
- SERVICE_3000_NAME=${COMPOSE_SERVICE_NAME:-alerting}-webhook-3000
- SERVICE_3000_TAGS=${APPRISE_WEBHOOK_SERVICE_3000_TAGS:-urlprefix-localhost/webhook/*}
networks:
- public
restart: always
volumes:
apprise:

View File

@ -23,11 +23,3 @@ services:
volumes:
nextcloud:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -17,8 +17,3 @@ services:
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}

View File

@ -33,11 +33,3 @@ services:
volumes:
drone:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -11,8 +11,3 @@ services:
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}

19
stack/duniter/v2s.mk Normal file
View File

@ -0,0 +1,19 @@
ENV_VARS += DUNITER_UI_SERVICE_80_TAGS DUNITER_UI_WS_URL DUNITER_V2S_DUNITER_CHAIN_NAME DUNITER_V2S_DUNITER_NODE_NAME DUNITER_V2S_DUNITER_PUBLIC_ADDR DUNITER_V2S_DUNITER_PRUNING_PROFILE DUNITER_V2S_SERVICE_9615_TAGS DUNITER_V2S_SERVICE_9933_TAGS DUNITER_V2S_SERVICE_9944_TAGS DUNITER_V2S_SERVICE_30333_TAGS
DUNITER_UI_SERVICE_NAME ?= $(DUNITER_V2S_SERVICE_NAME)
DUNITER_UI_SERVICE_80_PATH ?= ui/
DUNITER_UI_SERVICE_80_STRIP ?= /ui
DUNITER_UI_SERVICE_80_TAGS ?= $(call tagprefix,DUNITER_UI,80)
DUNITER_UI_WS_URL ?= wss://$(DUNITER_V2S_SERVICE_NAME).$(firstword $(APP_URIS))$(firstword $(DUNITER_V2S_SERVICE_9944_PATH))
DUNITER_V2S_DUNITER_CHAIN_NAME ?= gdev
DUNITER_V2S_DUNITER_NODE_NAME ?= $(USER)-$(ENV)-$(DUNITER_V2S_DUNITER_PRUNING_PROFILE)
DUNITER_V2S_DUNITER_PUBLIC_ADDR ?= /dns/$(DUNITER_V2S_SERVICE_NAME).$(firstword $(APP_HOST))/tcp/443/wss
DUNITER_V2S_DUNITER_PRUNING_PROFILE ?= archive
DUNITER_V2S_SERVICE_NAME ?= $(DUNITER_V2S_DUNITER_CHAIN_NAME)
DUNITER_V2S_SERVICE_9615_PATH ?= metrics/
DUNITER_V2S_SERVICE_9615_TAGS ?= $(call tagprefix,DUNITER_V2S,9615)
DUNITER_V2S_SERVICE_9933_PATH ?= http/
DUNITER_V2S_SERVICE_9933_TAGS ?= $(call tagprefix,DUNITER_V2S,9933)
DUNITER_V2S_SERVICE_9944_PATH ?= ws/
DUNITER_V2S_SERVICE_9944_STRIP ?= /ws
DUNITER_V2S_SERVICE_9944_TAGS ?= $(call tagprefix,DUNITER_V2S,9944)
DUNITER_V2S_SERVICE_30333_TAGS ?= $(call tagprefix,DUNITER_V2S,30333)

76
stack/duniter/v2s.yml Normal file
View File

@ -0,0 +1,76 @@
# This is a minimal docker-compose.yml template for running a Duniter instance
# For more detailed examples, look at docker/compose folder
version: "3.5"
services:
# duniter-oracle:
# entrypoint: docker-distance-entrypoint
# environment:
# ORACLE_RPC_URL: "ws://duniter-v2s:9944"
# ORACLE_RESULT_DIR: "/var/lib/duniter/chains/${DUNITER_V2S_DUNITER_CHAIN_NAME:-gdev}/distance/"
# ORACLE_EXECUTION_INTERVAL: "1800"
# ORACLE_MAX_DEPTH: "5"
# ORACLE_LOG_LEVEL: "info"
# image: duniter/duniter-v2s-gdev:latest
# networks:
# - private
# restart: always
# volumes:
# - duniter-v2s-data:/var/lib/duniter
duniter-ui:
environment:
- WS_URL=${DUNITER_UI_WS_URL:-duniter-v2s:9944}
image: jacogr/polkadot-js-apps:latest
labels:
- SERVICE_80_CHECK_HTTP=${DUNITER_UI_SERVICE_80_CHECK_HTTP:-/}
- SERVICE_80_NAME=${COMPOSE_SERVICE_NAME}-duniter-ui-80
- SERVICE_80_TAGS=${DUNITER_UI_SERVICE_80_TAGS:-urlprefix-gdev.localhost/ui/*}
networks:
- private
ports:
- 80
restart: always
duniter-v2s:
environment:
- DUNITER_CHAIN_NAME=${DUNITER_V2S_DUNITER_CHAIN_NAME:-gdev}
# - DUNITER_LISTEN_ADDR=${DUNITER_V2S_DUNITER_LISTEN_ADDR:-/ip4/0.0.0.0/tcp/30333/ws}
- DUNITER_NODE_NAME=${DUNITER_V2S_DUNITER_NODE_NAME:-duniter_local}
- DUNITER_PRUNING_PROFILE=${DUNITER_V2S_DUNITER_PRUNING_PROFILE:-default}
# - DUNITER_PUBLIC_ADDR=${DUNITER_V2S_DUNITER_PUBLIC_ADDR:-/dns/localhost/tcp/30333/ws}
- DUNITER_VALIDATOR=${DUNITER_V2S_DUNITER_VALIDATOR:-false}
image: duniter/duniter-v2s-gdev:latest
labels:
# - SERVICE_9615_CHECK_HTTP=${DUNITER_V2S_SERVICE_9615_CHECK_HTTP:-/}
# - SERVICE_9615_NAME=${COMPOSE_SERVICE_NAME}-duniter-v2s-9615
# - SERVICE_9615_TAGS=${DUNITER_V2S_SERVICE_9615_TAGS:-urlprefix-gdev.localhost/metrics/*}
# - SERVICE_9933_CHECK_HTTP=${DUNITER_V2S_SERVICE_9933_CHECK_HTTP:-/}
# - SERVICE_9933_CHECK_HTTP_METHOD=${DUNITER_V2S_SERVICE_9933_CHECK_HTTP_METHOD:-POST}
# - SERVICE_9933_NAME=${COMPOSE_SERVICE_NAME}-duniter-v2s-9933
# - SERVICE_9933_TAGS=${DUNITER_V2S_SERVICE_9933_TAGS:-urlprefix-gdev.localhost/http/*}
- SERVICE_9944_CHECK_TCP=true
- SERVICE_9944_NAME=${COMPOSE_SERVICE_NAME}-duniter-v2s-9944
- SERVICE_9944_TAGS=${DUNITER_V2S_SERVICE_9944_TAGS:-urlprefix-gdev.localhost/ws/*}
- SERVICE_30333_CHECK_TCP=true
- SERVICE_30333_NAME=${COMPOSE_SERVICE_NAME}-duniter-v2s-30333
- SERVICE_30333_TAGS=${DUNITER_V2S_SERVICE_30333_TAGS:-urlprefix-gdev.localhost/*}
networks:
- private
ports:
# telemetry
- 9615
# rpc
- 9933
# rpc-ws
- 9944
# p2p
- 30333
volumes:
- duniter-v2s-data:/var/lib/duniter
restart: always
volumes:
duniter-v2s-data:

View File

@ -19,11 +19,3 @@ services:
ports:
- 8200
restart: always
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -16,11 +16,3 @@ services:
ports:
- 8200
restart: always
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -19,8 +19,3 @@ services:
networks:
- private
restart: always
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}

View File

@ -4,4 +4,3 @@ services:
elasticsearch:
environment:
- discovery.type=single-node

View File

@ -38,11 +38,3 @@ services:
volumes:
elasticsearch:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -12,11 +12,3 @@ services:
ports:
- 5601
restart: always
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -12,11 +12,3 @@ services:
ports:
- 5601
restart: always
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -30,11 +30,3 @@ services:
volumes:
grafana:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -1,3 +1,5 @@
ENV_VARS += HOST_ACME_POST_HOOK HOST_ACME_PRE_HOOK
HOST_ACME_DOMAIN_PATH_VALID ?= $$(echo $${DOMAIN_PATH:-} |awk "'"/^[0-9a-z_\-\.\+\/]+@[0-9a-z\-]+\.[a-z0-9_\-\.\+\/]+$$/"'")
HOST_ACME_POST_HOOK ?= [ "$(HOST_ACME_DOMAIN_PATH_VALID)" ] && cp fullchain.cer /host/certs/$${domain}-cert.pem 2>/dev/null && cp $${domain}.key /host/certs/$${domain}-key.pem
HOST_ACME_DOMAIN_PATH_VALID ?= $$(echo $${DOMAIN_PATH:-} |awk "'"/^[0-9a-z_\-\.+\/]+@[0-9a-z_\-\.]+\.[a-z0-9_\-\.\+\/]+$$/"'")
HOST_ACME_DOMAIN_CERT_MODULUS ?= $$(openssl x509 -in fullchain.cer -noout -modulus)
HOST_ACME_DOMAIN_KEY_MODULUS ?= $$(openssl rsa -in $${domain}.key -noout -modulus)
HOST_ACME_POST_HOOK ?= [ "$(HOST_ACME_DOMAIN_PATH_VALID)" ] && cp -a fullchain.cer /host/certs/$${domain}-cert.pem 2>/dev/null && [ "$(HOST_ACME_DOMAIN_CERT_MODULUS)" = "$(HOST_ACME_DOMAIN_KEY_MODULUS)" ] && cp -a $${domain}.key /host/certs/$${domain}-key.pem

View File

@ -31,8 +31,3 @@ volumes:
host:
external: true
name: ${HOST_DOCKER_VOLUME}
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -6,12 +6,6 @@ services:
- DOCUMENT_ROOT=/var/www
volumes:
- www:/var/www
nginx:
volumes:
- www:/var/www
php:
volumes:
- www:/var/www
volumes:
www:

View File

@ -29,8 +29,3 @@ services:
volumes:
backup:
web:
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC:-localhost}

View File

@ -18,4 +18,3 @@ services:
volumes:
restic:

View File

@ -20,8 +20,3 @@ services:
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /var/run:/var/run:rw
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -23,8 +23,3 @@ services:
- /:/rootfs:ro
- /proc:/host/proc:ro
- /sys:/host/sys:ro
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

1
stack/host/ftps.mk Normal file
View File

@ -0,0 +1 @@
HOST_FTPS_UFW_DOCKER ?= 21/tcp 18700/tcp 18701/tcp 18702/tcp 18703/tcp 18704/tcp 18705/tcp 18706/tcp 18707/tcp 18708/tcp 18709/tcp 18710/tcp

32
stack/host/ftps.yml Normal file
View File

@ -0,0 +1,32 @@
version: '3.6'
services:
ftps:
container_name: ${HOST_COMPOSE_PROJECT_NAME}-ftps
environment:
- FTPS_EXTERNAL_IP=${DOCKER_HOST_INET4}
- FTPS_PASS=${HOST_FTPS_PASS}
- FTPS_USER=${HOST_FTPS_USER}
- FTPS_UID=${HOST_FTPS_UID}
image: bfren/ftps:latest
labels:
- SERVICE_21_CHECK_TCP=true
- SERVICE_21_NAME=${COMPOSE_SERVICE_NAME}-ftps-21
networks:
- private
- public
ports:
- 21:21
- 18700-18710:18700-18710
restart: always
volumes:
- backup:/files
- host:/host
- ssl:/ssl
volumes:
backup:
host:
external: true
name: ${HOST_DOCKER_VOLUME}
ssl:

9
stack/host/ipfs.home.yml Normal file
View File

@ -0,0 +1,9 @@
version: '3.6'
services:
ipfs:
volumes:
- home:/home:delegated
volumes:
home:

View File

@ -6,5 +6,5 @@ HOST_IPFS_SERVICE_5001_PATH ?= api/
HOST_IPFS_SERVICE_5001_TAGS ?= $(call tagprefix,HOST_IPFS,5001)
HOST_IPFS_SERVICE_8080_ENVS ?= host
HOST_IPFS_SERVICE_8080_TAGS ?= $(call urlprefix,,,$(HOST_IPFS_SERVICE_8080_URIS) $(call servicenvs,HOST_IPFS,8080,URIS))
HOST_IPFS_SERVICE_8080_URIS ?= $(call uriprefix,*ipfs *ipns)
HOST_IPFS_UFW_DOCKER ?= 4001/tcp 4001/udp 8080
HOST_IPFS_SERVICE_8080_URIS ?= $(call uriprefix,ipfs *.ipns)
HOST_IPFS_UFW_UPDATE ?= 4001/tcp 4001/udp 8080

View File

@ -31,11 +31,11 @@ services:
- IPFS_BOOTSTRAP=${HOST_IPFS_BOOTSTRAP:-}
- IPFS_DATASTORE_GCPERIOD=${HOST_IPFS_DATASTORE_GCPERIOD:-}
- IPFS_DISK_USAGE_PERCENT=${HOST_IPFS_DISK_USAGE_PERCENT:-}
- IPFS_EXPERIMENTAL_ACCELERATEDDHTCLIENT=${HOST_IPFS_EXPERIMENTAL_ACCELERATEDDHTCLIENT:-}
- IPFS_EXPERIMENTAL_ACCELERATEDDHTCLIENT=${HOST_IPFS_EXPERIMENTAL_ACCELERATEDDHTCLIENT:-true}
- IPFS_EXPERIMENTAL_FILESTOREENABLED=${HOST_IPFS_EXPERIMENTAL_FILESTOREENABLED:-}
- IPFS_EXPERIMENTAL_GRAPHSYNCENABLED=${HOST_IPFS_EXPERIMENTAL_GRAPHSYNCENABLED:-}
- IPFS_EXPERIMENTAL_LIBP2PSTREAMMOUNTING=${HOST_IPFS_EXPERIMENTAL_LIBP2PSTREAMMOUNTING:-}
- IPFS_EXPERIMENTAL_P2PHTTPPROXY=${HOST_IPFS_EXPERIMENTAL_P2PHTTPPROXY:-}
- IPFS_EXPERIMENTAL_LIBP2PSTREAMMOUNTING=${HOST_IPFS_EXPERIMENTAL_LIBP2PSTREAMMOUNTING:-true}
- IPFS_EXPERIMENTAL_P2PHTTPPROXY=${HOST_IPFS_EXPERIMENTAL_P2PHTTPPROXY:-true}
- IPFS_EXPERIMENTAL_STRATEGICPROVIDING=${HOST_IPFS_EXPERIMENTAL_STRATEGICPROVIDING:-}
- IPFS_EXPERIMENTAL_URLSTOREENABLED=${HOST_IPFS_EXPERIMENTAL_URLSTOREENABLED:-}
- IPFS_IDENTITY_PEERID=${HOST_IPFS_IDENTITY_PEERID:-}
@ -45,12 +45,13 @@ services:
- IPFS_IPNS_USEPUBSUB=${HOST_IPFS_IPNS_USEPUBSUB:-true}
- IPFS_LOGGING=${HOST_IPFS_LOGGING:-error}
- IPFS_NETWORK=${HOST_IPFS_NETWORK:-public}
- IPFS_PATH=${HOST_IPFS_PATH:-/data/ipfs}
- IPFS_PROFILE=${HOST_IPFS_PROFILE:-${IPFS_PROFILE}}
- IPFS_PUBSUB_ENABLE=${HOST_IPFS_PUBSUB_ENABLE:-true}
- IPFS_PUBSUB_ROUTER=${HOST_IPFS_PUBSUB_ROUTER:-gossipsub}
- IPFS_ROUTING_TYPE=${HOST_IPFS_ROUTING_TYPE:-dht}
- IPFS_REPROVIDER_INTERVAL=${HOST_IPFS_REPROVIDER_INTERVAL:-}
- IPFS_REPROVIDER_STRATEGY=${HOST_IPFS_REPROVIDER_STRATEGY:-}
- IPFS_REPROVIDER_STRATEGY=${HOST_IPFS_REPROVIDER_STRATEGY:-roots}
- IPFS_SWARM_CONNMGR_HIGHWATER=${HOST_IPFS_SWARM_CONNMGR_HIGHWATER:-}
- IPFS_SWARM_CONNMGR_LOWWATER=${HOST_IPFS_SWARM_CONNMGR_LOWWATER:-}
- IPFS_SWARM_CONNMGR_TYPE=${HOST_IPFS_SWARM_CONNMGR_TYPE:-}
@ -60,6 +61,8 @@ services:
- IPFS_SWARM_RELAYCLIENT_ENABLED=${HOST_IPFS_SWARM_RELAYCLIENT_ENABLED:-}
- IPFS_SWARM_RELAYSERVICE_ENABLED=${HOST_IPFS_SWARM_RELAYSERVICE_ENABLED:-}
- IPFS_SWARM_TRANSPORTS_NETWORK_RELAY=${HOST_IPFS_SWARM_TRANSPORTS_NETWORK_RELAY:-}
healthcheck:
timeout: 5s
image: ${HOST_DOCKER_REPOSITORY}/ipfs:${DOCKER_IMAGE_TAG}
labels:
- SERVICE_4001_CHECK_TCP=true
@ -72,13 +75,7 @@ services:
- SERVICE_8080_NAME=${HOST_COMPOSE_SERVICE_NAME}-ipfs-8080
- SERVICE_8080_TAGS=${HOST_IPFS_SERVICE_8080_TAGS:-}
- SERVICE_8081_IGNORE=true
networks:
- public
ports:
- 4001:4001/tcp
- 4001:4001/udp
- 5001:5001/tcp
- 8080:8080/tcp
network_mode: host
restart: always
ulimits:
nofile:
@ -89,8 +86,3 @@ services:
volumes:
ipfs:
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -1,6 +1,7 @@
# ENV_VARS += HOST_MAILSERVER_ENABLE_MANAGESIEVE HOST_MAILSERVER_SPOOF_PROTECTION HOST_MAILSERVER_SSL_TYPE HOST_MAILSERVER_ENABLE_UPDATE_CHECK
HOST_MAILSERVER_ENABLE_FAIL2BAN ?= 1
HOST_MAILSERVER_ENABLE_MANAGESIEVE ?= 1
HOST_MAILSERVER_ENABLE_UPDATE_CHECK ?= 0
HOST_MAILSERVER_SPOOF_PROTECTION ?= 1
HOST_MAILSERVER_SSL_TYPE ?= letsencrypt
HOST_MAILSERVER_ENABLE_UPDATE_CHECK ?= 0
HOST_MAILSERVER_UFW_DOCKER ?= 25/tcp 465/tcp 587/tcp 993/tcp

View File

@ -28,7 +28,7 @@ services:
- ENABLE_AMAVIS=${HOST_MAILSERVER_ENABLE_AMAVIS:-1}
- AMAVIS_LOGLEVEL=${HOST_MAILSERVER_AMAVIS_LOGLEVEL:-0}
- ENABLE_DNSBL=${HOST_MAILSERVER_ENABLE_DNSBL:-0}
- ENABLE_FAIL2BAN=${HOST_MAILSERVER_ENABLE_FAIL2BAN:-0}
- ENABLE_FAIL2BAN=${HOST_MAILSERVER_ENABLE_FAIL2BAN:-1}
- FAIL2BAN_BLOCKTYPE=${HOST_MAILSERVER_FAIL2BAN_BLOCKTYPE:-drop}
- ENABLE_MANAGESIEVE=${HOST_MAILSERVER_ENABLE_MANAGESIEVE:-1}
- POSTSCREEN_ACTION=${HOST_MAILSERVER_POSTSCREEN_ACTION:-enforce}
@ -155,8 +155,3 @@ volumes:
host:
external: true
name: ${HOST_DOCKER_VOLUME}
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -1,19 +1,11 @@
version: '3.6'
services:
apache-php5:
environment:
- DOCUMENT_ROOT=/dns
volumes:
- dns:/dns
nginx:
environment:
- DEFAULT=default_dns
volumes:
- dns:/dns
php:
volumes:
- dns:/dns
volumes:
dns:

9
stack/host/nginx.www.yml Normal file
View File

@ -0,0 +1,9 @@
version: '3.6'
services:
nginx:
volumes:
- www:/var/www
volumes:
www:

View File

@ -15,7 +15,7 @@ services:
- DEFAULT_LOCATION_PHP=${HOST_NGINX_DEFAULT_LOCATION_PHP:-}
- DEFAULT_LOCATION_IPFS=${HOST_NGINX_DEFAULT_LOCATION_IPFS:-}
- LETSENCRYPT_HOST=${HOST_NGINX_LETSENCRYPT_HOST:-${HOST_NGINX_VIRTUAL_HOST:-}}
- LETSENCRYPT_EMAIL=${HOST_NGINX_LETSENCRYPT_EMAIL:-${DEFAULT_EMAIL:-${MAIL:-nginx@localhost}}}
- LETSENCRYPT_EMAIL=${HOST_NGINX_LETSENCRYPT_EMAIL:-${HOST_ACME_DEFAULT_EMAIL:-${DEFAULT_EMAIL:-${MAIL:-nginx@localhost}}}}
- LETSENCRYPT_SINGLE_DOMAIN_CERTS=${HOST_NGINX_LETSENCRYPT_SINGLE_DOMAIN_CERTS:-true}
- LETSENCRYPT_TEST=${HOST_NGINX_LETSENCRYPT_TEST:-${LETSENCRYPT_TEST:-}}
- SSL_POLICY=${HOST_NGINX_SSL_POLICY:-Mozilla-Modern}
@ -51,8 +51,3 @@ volumes:
htpasswd:
log:
vhost:
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

9
stack/host/php.dns.yml Normal file
View File

@ -0,0 +1,9 @@
version: '3.6'
services:
php:
volumes:
- dns:/dns
volumes:
dns:

9
stack/host/php.www.yml Normal file
View File

@ -0,0 +1,9 @@
version: '3.6'
services:
php:
volumes:
- www:/var/www
volumes:
www:

View File

@ -13,8 +13,4 @@ services:
image: php:fpm-alpine
networks:
- public
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}
restart: always

View File

@ -21,8 +21,3 @@ services:
volumes:
portainer:
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -18,8 +18,3 @@ services:
volumes:
static:
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -40,11 +40,6 @@ services:
- shared:/shared:cached
- shm:/dev/shm:delegated
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}
volumes:
home:
shared:

View File

@ -5,8 +5,8 @@ IPFS_SERVICE_NAME ?= ipfs
IPFS_SERVICE_5001_PATH ?= api/
IPFS_SERVICE_5001_TAGS ?= $(call tagprefix,ipfs,5001)
IPFS_SERVICE_8080_CHECK_HTTP ?= /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
IPFS_SERVICE_8080_TAGS ?= $(call tagprefix,ipfs,8080)
IPFS_SERVICE_8080_URIS ?= $(patsubst %,ipfs.%,$(APP_URIS)) $(patsubst %,*.ipfs.%,$(APP_URIS)) $(patsubst %,ipns.%,$(APP_URIS)) $(patsubst %,*.ipns.%,$(APP_URIS))
IPFS_SERVICE_8080_TAGS ?= $(call urlprefix,,,$(IPFS_SERVICE_8080_URIS))
IPFS_SERVICE_8080_URIS ?= $(call uriprefix,ipfs *.ipns)
IPFS_VERSION ?= 0.16.0
.PHONY: bootstrap-stack-ipfs

View File

@ -92,11 +92,3 @@ volumes:
type: none
device: ${HOME}/.ipfs
o: bind
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -11,8 +11,3 @@ services:
ports:
- 11211
restart: always
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}

7
stack/myos/networks.yml Normal file
View File

@ -0,0 +1,7 @@
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE:-docker}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC:-localhost}

View File

@ -0,0 +1,9 @@
version: '3.6'
volumes:
backup:
driver: local
driver_opts:
device: /var/lib/backup
o: bind
type: none

View File

@ -0,0 +1,9 @@
version: '3.6'
volumes:
home:
driver: local
driver_opts:
device: /home
o: bind
type: none

View File

@ -17,8 +17,3 @@ services:
volumes:
mysql:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}

View File

@ -12,8 +12,3 @@ services:
ports:
- 31339
restart: always
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}

View File

@ -45,11 +45,3 @@ volumes:
type: none
device: ${MONOREPO_DIR}
o: bind
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE:-docker}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC:-localhost}

View File

@ -19,11 +19,3 @@ services:
volumes:
static:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE:-docker}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC:-static.localhost}

View File

@ -20,8 +20,3 @@ services:
volumes:
portainer:
networks:
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -2,4 +2,4 @@ version: '3.6'
services:
postgres:
image: postgres:latest
image: postgres:alpine

View File

@ -4,6 +4,7 @@ services:
postgres:
environment:
- POSTGRES_DB=${POSTGRES_DB:-postgres}
- POSTGRES_HOST_AUTH_METHOD=${POSTGRES_HOST_AUTH_METHOD:-trust}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- POSTGRES_USER=${POSTGRES_USER:-postgres}
labels:
@ -19,8 +20,3 @@ services:
volumes:
postgres:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}

View File

@ -19,11 +19,3 @@ services:
ports:
- 9093
restart: always
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -18,11 +18,3 @@ services:
ports:
- 9115
restart: always
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -19,11 +19,3 @@ services:
ports:
- 9206
restart: always
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -25,11 +25,3 @@ services:
volumes:
prometheus:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -25,11 +25,3 @@ services:
volumes:
rabbitmq:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -17,11 +17,3 @@ services:
volumes:
redis:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -37,11 +37,3 @@ services:
volumes:
redmine:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -30,11 +30,3 @@ services:
volumes:
redmine3:
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -21,8 +21,3 @@ services:
restart: always
volumes:
- /var/run/docker.sock:/tmp/docker.sock
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}

View File

@ -46,11 +46,3 @@ volumes:
user:
external: true
name: ${USER_DOCKER_VOLUME}
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

View File

@ -40,14 +40,6 @@ services:
- vdi-shared:/shared:cached
- vdi-shm:/dev/shm:delegated
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}
volumes:
vdi-home:
vdi-shared: