initial commit

This commit is contained in:
TakuyaYagam1 committed 2026-10-05 14:23:31 +03:00
commit 88c14b627e
224 files changed
+17204

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
services:
ml:
build:
context: ../..
dockerfile: ml/Dockerfile
ports:
- "${ML_BIND_ADDRESS:-127.0.0.1}:${ML_HTTP_PORT:-8000}:8000"
healthcheck:
test:
- CMD
- python
- -c
- "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=2)"
interval: 10s
timeout: 3s
retries: 5
start_period: 15s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "2.0"
memory: 4G
+279
View File
@@ -0,0 +1,279 @@
services:
prometheus-targets:
image: busybox:latest
command:
- /bin/sh
- -ec
- |
target="$${ML_METRICS_TARGET}"
if [ -z "$$target" ]; then
printf '%s\n' '[]' > /targets/ml.yml
exit 0
fi
case "$$target" in
*[!A-Za-z0-9._:-]*|*:*:*)
printf '%s\n' 'ML_METRICS_TARGET must be a private hostname or IPv4 address followed by a port.' >&2
exit 1
;;
esac
host="$${target%:*}"
port="$${target##*:}"
case "$$host" in
''|.*|*..*|-*|*-) printf '%s\n' 'ML_METRICS_TARGET has an invalid host.' >&2; exit 1 ;;
esac
case "$$port" in
''|*[!0-9]*) printf '%s\n' 'ML_METRICS_TARGET must end with a numeric port.' >&2; exit 1 ;;
esac
if [ "$$port" -lt 1 ] || [ "$$port" -gt 65535 ]; then
printf '%s\n' 'ML_METRICS_TARGET port must be between 1 and 65535.' >&2
exit 1
fi
printf '%s\n' '- targets:' " - \"$$host:$$port\"" > /targets/ml.yml
environment:
ML_METRICS_TARGET: ${ML_METRICS_TARGET:-}
volumes:
- prometheus_targets:/targets
networks:
- observability
read_only: true
tmpfs:
- /tmp
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: "no"
prometheus:
image: prom/prometheus:latest
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --storage.tsdb.retention.time=14d
- --storage.tsdb.retention.size=4GB
depends_on:
prometheus-targets:
condition: service_completed_successfully
volumes:
- ../../observability/prometheus:/etc/prometheus:ro
- prometheus_targets:/etc/prometheus/targets:ro
- prometheus_data:/prometheus
expose:
- "9090"
networks:
- observability
- app
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1G
postgres-exporter:
image: ghcr.io/prometheus-community/postgres-exporter:latest
environment:
DATA_SOURCE_URI: postgres:5432/${POSTGRES_DB:?Set POSTGRES_DB in the root .env file}?sslmode=disable
DATA_SOURCE_USER: ${POSTGRES_EXPORTER_USER:?Set POSTGRES_EXPORTER_USER in the root .env file}
DATA_SOURCE_PASS: ${POSTGRES_EXPORTER_PASSWORD:?Set POSTGRES_EXPORTER_PASSWORD in the root .env file}
expose:
- "9187"
networks:
- observability
- app
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "0.25"
memory: 128M
node-exporter:
image: prom/node-exporter:latest
command:
- --path.procfs=/host/proc
- --path.sysfs=/host/sys
- --path.rootfs=/host/root
- --collector.filesystem.mount-points-exclude=^/(dev|proc|sys|host|etc)($$|/)
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/host/root:ro,rslave
expose:
- "9100"
networks:
- observability
read_only: true
user: "65534:65534"
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "0.25"
memory: 128M
loki:
image: grafana/loki:latest
command:
- -config.file=/etc/loki/loki.yml
- -target=all
volumes:
- ../../observability/loki/loki.yml:/etc/loki/loki.yml:ro
- loki_data:/loki
expose:
- "3100"
networks:
- observability
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 1G
alloy:
image: grafana/alloy:latest
user: "473:473"
environment:
APP_PROJECT: ${APP_PROJECT:-app}
command:
- run
- --server.http.listen-addr=127.0.0.1:12345
- --storage.path=/var/lib/alloy/data
- /etc/alloy/app.alloy
depends_on:
- loki
- docker-socket-proxy
volumes:
- ../../observability/alloy/app.alloy:/etc/alloy/app.alloy:ro
- alloy_data:/var/lib/alloy/data
expose:
- "12347"
networks:
observability: {}
app:
aliases:
- faro-receiver
read_only: true
tmpfs:
- /tmp
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
docker-socket-proxy:
image: tecnativa/docker-socket-proxy:latest
environment:
CONTAINERS: "1"
EVENTS: "1"
IMAGES: "0"
INFO: "0"
NETWORKS: "0"
PING: "1"
POST: "0"
VERSION: "1"
volumes:
- type: bind
source: ${DOCKER_SOCKET_PATH:-/var/run/docker.sock}
target: /var/run/docker.sock
read_only: true
bind:
create_host_path: false
expose:
- "2375"
networks:
- observability
# The image entrypoint renders HAProxy configuration before starting.
tmpfs:
- /tmp
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
grafana:
image: grafana/grafana:latest
environment:
GF_SERVER_PROTOCOL: http
GF_SERVER_DOMAIN: localhost
GF_SERVER_ROOT_URL: http://localhost:${GRAFANA_PORT:-3000}/
GF_SECURITY_ADMIN_USER: ${GRAFANA_ADMIN_USER:?Set GRAFANA_ADMIN_USER in the root .env file}
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:?Set GRAFANA_ADMIN_PASSWORD in the root .env file}
GF_USERS_ALLOW_SIGN_UP: "false"
GF_ANALYTICS_REPORTING_ENABLED: "false"
ports:
- "127.0.0.1:${GRAFANA_PORT:-3000}:3000"
volumes:
- grafana_data:/var/lib/grafana
- ../../observability/grafana/provisioning:/etc/grafana/provisioning:ro
- ../../observability/grafana/dashboards:/var/lib/grafana/dashboards:ro
networks:
- observability
- app
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 768M
networks:
app:
name: ${APP_NETWORK:-app_default}
external: true
observability:
internal: true
volumes:
alloy_data:
grafana_data:
loki_data:
prometheus_data:
prometheus_targets:
+88
View File
@@ -0,0 +1,88 @@
services:
postgres:
image: postgres:alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:?Set POSTGRES_DB in the root .env file}
POSTGRES_USER: ${POSTGRES_USER:?Set POSTGRES_USER in the root .env file}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in the root .env file}
POSTGRES_EXPORTER_USER: ${POSTGRES_EXPORTER_USER:-}
POSTGRES_EXPORTER_PASSWORD: ${POSTGRES_EXPORTER_PASSWORD:-}
volumes:
- postgres_data:/var/lib/postgresql
- ./initdb/10-postgres-exporter.sh:/docker-entrypoint-initdb.d/10-postgres-exporter.sh:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 2G
backend:
build:
context: ../../backend
dockerfile: Dockerfile
environment:
DATABASE_URL: postgres://${POSTGRES_USER:?Set POSTGRES_USER}:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:?Set POSTGRES_DB}?sslmode=disable
depends_on:
postgres:
condition: service_healthy
expose:
- "8080"
- "9090"
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "1.0"
memory: 768M
frontend:
build:
context: ../..
dockerfile: frontend/Dockerfile
depends_on:
backend:
condition: service_started
ports:
- "127.0.0.1:${APP_HTTP_PORT:-8080}:8080"
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/healthz"]
interval: 10s
timeout: 3s
retries: 5
start_period: 5s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
deploy:
resources:
limits:
cpus: "0.5"
memory: 256M
volumes:
postgres_data:
name: ${APP_PROJECT:-app}_postgres_data
networks:
default:
name: ${APP_NETWORK:-app_default}
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ -z "${POSTGRES_EXPORTER_USER:-}" && -z "${POSTGRES_EXPORTER_PASSWORD:-}" ]]; then
exit 0
fi
: "${POSTGRES_EXPORTER_USER:?POSTGRES_EXPORTER_USER and POSTGRES_EXPORTER_PASSWORD must both be set}"
: "${POSTGRES_EXPORTER_PASSWORD:?POSTGRES_EXPORTER_USER and POSTGRES_EXPORTER_PASSWORD must both be set}"
psql \
--username "$POSTGRES_USER" \
--dbname "$POSTGRES_DB" \
--set=exporter_user="$POSTGRES_EXPORTER_USER" \
--set=exporter_password="$POSTGRES_EXPORTER_PASSWORD" <<'SQL'
SELECT format('CREATE ROLE %I LOGIN PASSWORD %L', :'exporter_user', :'exporter_password')
WHERE NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = :'exporter_user')
\gexec
GRANT pg_monitor TO :"exporter_user";
SQL