Compare commits

...

9 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
qo-op 5b6084aad6 fix certbot version 2023-01-09 20:13:24 +00:00
33 changed files with 951 additions and 172 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

@ -1,47 +1,58 @@
# FROM certbot/certbot:latest as dist
FROM python:3.8-alpine as dist
FROM python:3.11-alpine as dist
LABEL maintainer aynic.os <support+docker@asycn.io>
ARG DOCKER_BUILD_DIR
ARG CERTBOT_VERSION=1.32.0
# RUN pip install \
RUN apk --no-cache add --virtual .build-deps \
augeas-dev \
build-base \
libffi-dev \
&& pip install \
certbot \
acme==$CERTBOT_VERSION \
certbot==$CERTBOT_VERSION \
# certbot-apache \
certbot-dns-azure \
# certbot-dns-bunny \
# certbot-dns-clouddns \
certbot-dns-clouddns \
certbot-dns-cloudflare \
# certbot-dns-cloudxns \
certbot-dns-cloudxns \
certbot-dns-digitalocean \
# certbot-dns-dnsmadeeasy \
# certbot-dns-dnsimple \
certbot-dns-dnsmadeeasy \
certbot-dns-dnsimple \
# certbot-dns-gehirn \
# certbot-dns-godaddy \
certbot-dns-godaddy \
certbot-dns-google \
certbot-dns-infomaniak \
# certbot-dns-inwx \
certbot-dns-ispconfig \
# certbot-dns-lightsail \
certbot-dns-lightsail \
certbot-dns-linode \
# certbot-dns-luadns \
# certbot-dns-njalla \
certbot-dns-luadns \
certbot-dns-njalla \
# certbot-dns-nsone \
certbot-dns-ovh \
certbot-dns-rfc2136 \
certbot-dns-route53 \
# certbot-dns-sakuracloud \
certbot-dns-standalone \
# certbot-dns-yandexcloud \
certbot-dns-yandexcloud \
# certbot-ext-auth future \
certbot-nginx \
certbot-plugin-gandi \
certbot-s3front \
# certbot_dns_duckdns \
# certbot_dns_porkbun \
certbot_dns_duckdns \
certbot_dns_porkbun \
# letsencrypt-pritunl \
# letsencrypt-proxmox \
&& apk del .build-deps
&& runDeps="$( \
scanelf --needed --nobanner --recursive /usr \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk del .build-deps \
&& apk add --no-cache --virtual .run-deps $runDeps
COPY ${DOCKER_BUILD_DIR}/certbot-renew /etc/periodic/daily/
COPY ${DOCKER_BUILD_DIR}/docker-entrypoint.sh /docker-entrypoint.sh

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} |awk '/armv7l/ {print "armv7"}')"; \
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"}; /armv7/ {print "arm"};')"; \
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

@ -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

@ -3,7 +3,7 @@ BUILD_DATE ?= $(shell TZ=UTC date "+%Y%m%dT%H%M%SZ" 2>/dev/
BUILD_DESCRIPTION ?= Lot of Love
BUILD_DOCUMENTATION ?= $(APP_REPOSITORY_URL)$(if $(wildcard README.md),/blob/$(COMMIT)/README.md)
BUILD_ENV_VARS ?= APP BRANCH BUILD_DATE BUILD_STATUS COMMIT DEPLOY_HOOK_URL ENV UID USER VERSION
BUILD_LABEL_VARS ?= org.label-schema.% org.opencontainers.% os.my.%
BUILD_LABEL_VARS ?= org.opencontainers.% os.my.%
BUILD_LABEL_ARGS ?= $(foreach var,$(filter $(BUILD_LABEL_VARS),$(MAKE_FILE_VARS)),$(if $($(var)),$(var)='$($(var))'))
BUILD_LICENSE ?= GPL-3.0
BUILD_NAME ?= $(COMPOSE_SERVICE_NAME)-$(BUILD_SERVICE)

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)) $(MYOS_STACK_FILE))
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)))
@ -26,9 +27,11 @@ 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_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)
@ -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))
@ -136,8 +148,7 @@ define docker-stack-update
$(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))),$(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))))))
$(eval COMPOSE_FILE += $(wildcard $(foreach file,$(name) $(name).$(ENV) $(name).$(ENV).$(version) $(name).$(version) $(foreach env,$(COMPOSE_FILE_ENV),$(name).$(env)),$(path)/$(file).yml)))
$(eval COMPOSE_FILE := $(strip $(COMPOSE_FILE)))
$(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 $(HOST_STACK),,$(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 $(HOST_STACK),$(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

@ -5,6 +5,12 @@ ufw:
# 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
@ -26,21 +32,22 @@ ufw-install:
$(call app-install,$(SETUP_UFW_REPOSITORY))
# target ufw-up: Start ufw-docker docker
ufw-up: COMPOSE_PROJECT_NAME := $(HOST_COMPOSE_PROJECT_NAME)
ufw-up: DOCKER_RUN_NETWORK :=
ufw-up: 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
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 $(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)) \

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,38 +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)) $(foreach file,$(APP) $(APP).$(ENV) $(foreach env,$(COMPOSE_FILE_ENV),$(APP).$(env)),apps/$(APP)/$(file).yml)) $(MYOS_STACK_FILE))
$(eval COMPOSE_PROJECT_NAME := $(if $(DOCKER_COMPOSE_PROJECT_NAME),$(DOCKER_COMPOSE_PROJECT_NAME),$(subst .,,$(call LOWERCASE,$(USER)-$(APP_NAME)-$(ENV)$(addprefix -,$(subst /,,$(subst -,,$(APP_PATH))))))))
$(eval COMPOSE_SERVICE_NAME := $(if $(DOCKER_COMPOSE_SERVICE_NAME),$(DOCKER_COMPOSE_SERVICE_NAME),$(subst _,-,$(COMPOSE_PROJECT_NAME))))
$(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))
$(call docker-compose,config)
$(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
@ -58,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))
@ -70,56 +98,66 @@ endef
# function app-down: Call docker rm for each Dockerfile in dir 1
define app-down
$(call INFO,app-down,$(1)$(comma))
$(if $(filter-out $(MYOS_STACK_FILE),$(COMPOSE_FILE)),$(call docker-compose,down -v),
$(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))
$(if $(filter-out $(MYOS_STACK_FILE),$(COMPOSE_FILE)),$(call docker-compose,logs),
$(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
@ -129,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
@ -147,21 +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 $(filter-out $(MYOS_STACK_FILE),$(COMPOSE_FILE)),$(call docker-compose,up),
$(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,8 +1,9 @@
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 $(USER_STACK),$(USER),$(DOCKER_NETWORK_PRIVATE))
DOCKER_NETWORK_PRIVATE ?= $(USER)-$(ENV)
@ -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
@ -27,7 +28,7 @@ HOST_GID ?= 100
HOST_UID ?= 123
HOST_STACK ?= $(filter host,$(firstword $(subst /, ,$(STACK))))
MYOS_STACK ?= $(MYOS)/stack/myos
MYOS_STACK_FILE ?= $(wildcard $(MYOS_STACK)/networks.yml $(MYOS_STACK)/*.$(ENV).yml)
MYOS_STACK_FILE ?= networks volumes
RESU_DOCKER_REPOSITORY ?= $(subst -,/,$(USER_COMPOSE_PROJECT_NAME))
USER_COMPOSE_PROJECT_NAME ?= $(subst .,-,$(RESU))
USER_COMPOSE_SERVICE_NAME ?= $(USER_COMPOSE_PROJECT_NAME)
@ -158,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
@ -179,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 DOCKER_COMPOSE DOCKER_MACHINE DOCKER_SYSTEM
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)/..))))
@ -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

@ -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:

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

@ -94,7 +94,7 @@ host-certbot-staging: host-docker-build-certbot
# target host-docker-build-%: Build % docker
.PHONY: host-docker-build-%
host-docker-build-%:
$(call docker-build,docker/$*,host/$*:$(DOCKER_IMAGE_TAG))
$(call docker-build,docker/$*,$(HOST_DOCKER_REPOSITORY)/$*:$(DOCKER_IMAGE_TAG))
# target host-docker-rebuild-%: Rebuild % docker
.PHONY: host-docker-rebuild-%