first apps :)

This commit is contained in:
Yann Autissier 2023-11-26 05:14:30 +01:00
parent 5e3782c944
commit 2699a04c84
12 changed files with 122 additions and 15 deletions

View File

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

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
embeddings-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 @@
APP_DOCKER_DIR ?= deploy/docker/clickhouse-setup
APP_REPOSITORY_URL ?= https://github.com/SigNoz/signoz
APP_VERSION ?= v0.34.3
ENV_VARS += SIGNOZ_FRONTEND_SERVICE_3301_TAGS
SIGNOZ_FRONTEND_SERVICE_3301_TAGS ?= $(call urlprefix)
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

@ -192,7 +192,6 @@ ssh@%:
## it updates COMPOSE_FILE with all .yml files of the current stack
.PHONY: stack
stack:
$(call compose-file)
$(foreach stackz,$(STACK),$(call docker-stack,$(stackz)))
$(call compose-file,$(MYOS_STACK),$(MYOS_STACK_FILE))

View File

@ -30,6 +30,7 @@ DOCKER_BUILD_VARS ?= APP BRANCH COMPOSE_VERSION DOCKER_GID DOCKER_
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_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)

View File

@ -56,7 +56,7 @@ docker-compose-exec:
# 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)))
$(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

View File

@ -12,8 +12,11 @@ $(APP): myos-user
## ex: app-foo-build will call app-build for app foo in ../foo
.PHONY: app-%
app-%:
$(eval COMPOSE_FILE :=)
$(eval STACK :=)
$(eval app := $(subst -$(lastword $(subst -, ,$*)),,$*))
$(eval command := $(lastword $(subst -, ,$*)))
$(eval include $(wildcard apps/$(app).mk apps/$(app)/$(app).mk)) \
$(if $(wildcard $(RELATIVE)$(app)), \
$(if $(filter app-$(command),$(.VARIABLES)), \
$(call app-bootstrap,$(app)) \
@ -26,7 +29,11 @@ app-%:
) \
) \
, \
$(call WARNING,Unable to find app,$(app),in dir,$(RELATIVE)$(app)) \
$(if $(wildcard apps/$(app).mk apps/$(app)/$(app).mk), \
$(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

@ -16,12 +16,13 @@ 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 :=)
$(call compose-file,$(APP_DIR) $(APP_DIR)/docker apps/$(APP),docker-compose $(APP))
$(call compose-file,$(MYOS_STACK),$(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 DOCKER_BUILD_DIR := $(APP_DIR))
$(call compose-file,$(APP_DIR) $(APP_DIR)/$(or $(APP_DOCKER_DIR),$(DOCKER_DIR)),docker-compose)
$(call compose-file,apps apps/$(APP),$(APP))
$(foreach stackz,$(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
@ -70,7 +71,7 @@ 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),
$(if $(filter-out $(MYOS_STACK_FILE),$(COMPOSE_FILE)),$(call docker-compose,down $(DOCKER_COMPOSE_DOWN_OPTIONS)),
$(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
@ -92,18 +93,18 @@ 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),
$(if $(filter-out $(MYOS_STACK_FILE),$(COMPOSE_FILE)),$(call docker-compose,logs $(DOCKER_COMPOSE_LOGS_OPTIONS)),
$(call docker-file,$(1))
$(foreach dockerfile,$(DOCKER_FILE),
$(call app-docker,$(dockerfile))
@ -148,7 +149,7 @@ endef
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 $(filter-out $(MYOS_STACK_FILE),$(COMPOSE_FILE)),$(call docker-compose,up $(DOCKER_COMPOSE_UP_OPTIONS)),
$(if $(shell docker ps -q -f name=$(DOCKER_NAME) 2>/dev/null),
$(call INFO,docker $(DOCKER_NAME) already running)
, $(call app-run,$(1))
@ -158,10 +159,10 @@ 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,3 +1,4 @@
DOCKER_DIR ?= *
DOCKER_ENV_ARGS ?= $(docker_env_args)
DOCKER_EXEC_OPTIONS ?=
DOCKER_GID ?= $(call gid,docker)
@ -158,7 +159,7 @@ 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))
)

View File

@ -34,7 +34,7 @@ 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

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: