-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathstack
More file actions
executable file
·115 lines (95 loc) · 3.76 KB
/
Copy pathstack
File metadata and controls
executable file
·115 lines (95 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env bash
STACK_PATH=$(pwd)
PROJECT_PATH=$(pwd)
set -ae
. "${STACK_PATH}/.env.dist" # default settings
if [ -f "${STACK_PATH}/.env" ]; then
. "${STACK_PATH}/.env" # custom *global* settings
elif [ -f "${PROJECT_PATH}/.env" ]; then
. "${PROJECT_PATH}/.env" # custom *local* settings
fi
if [ $# -eq 0 ] || [ "help" = "${1}" ]; then
echo "Usage: stack [component] <docker/podman compose command>"
echo ""
echo "Components:"
echo " mysql MySQL & phpMyAdmin (http://localhost:${PHPMYADMIN_PORT})"
echo " postgres PostgreSQL & pgAdmin (http://localhost:${PGADMIN_PORT})"
echo " redis Redis & RedisInsight (http://localhost:${REDISINSIGHT_PORT})"
echo " mongo MongoDB & Mongo Express (http://localhost:${MONGO_EXPRESS_PORT})"
echo " kafka Kafka and UI for Apache Kafka (http://localhost:${KAFKA_UI_PORT})"
echo " rabbitmq RabbitMQ & Management Plugin (http://localhost:${RABBITMQ_UI_PORT})"
echo " aws AWS services via LocalStack (http://localhost:${AWS_PORT})"
echo " aws-ministack AWS services via MiniStack (http://localhost:${AWS_MINISTACK_PORT})"
echo " hyperdx HyperDX local. (http://localhost:${HYPERDX_APP_PORT})"
echo " o11y OTel Collectors, Jaeger UI, Prometheus & Grafana"
echo ""
echo "Observability (o11y):"
echo " OTel Collector: Jaeger HTTP (Port: ${JAEGER_PORT})"
echo " OTel Collector: Statsd UDP (Port: ${STATSD_PORT})"
echo " OTel Collector: OTLP gRPC (Port: 4317)"
echo " OTel Collector: OTLP HTTP (Port: 4318)"
echo " Jaeger UI: Traces (http://localhost:${JAEGER_UI_PORT})"
echo " Prometheus: Metrics (http://localhost:${PROMETHEUS_PORT})"
echo " Grafana Dashboards & Alerts (http://localhost:${GRAFANA_PORT})"
echo ""
exit
fi
if [ "path" = "${1}" ]; then
echo "Stack path: ${STACK_PATH}"
echo "Project path: ${PROJECT_PATH}"
exit
fi
CONTAINER_BIN=
if command -v docker > /dev/null 2>&1; then
CONTAINER_BIN=docker
elif command -v podman > /dev/null 2>&1; then
CONTAINER_BIN=podman
else
echo "Could not find neither \"docker\" nor \"podman\", aborting"
exit 1
fi
CONTAINER_COMPOSE=
if docker compose --help > /dev/null 2>&1; then
CONTAINER_COMPOSE="docker compose"
elif command -v docker-compose > /dev/null 2>&1; then
CONTAINER_COMPOSE=docker-compose
elif command -v podman-compose > /dev/null 2>&1; then
CONTAINER_COMPOSE=podman-compose
else
echo "Could not find \"docker compose\", \"docker-compose\" or \"podman-compose\", aborting"
exit 1
fi
if [ "ps" = "${1}" ] || [ "ls" = "${1}" ]; then
$CONTAINER_BIN ps | grep "opencodeco"
exit
fi
if [ "network" = "${1}" ]; then
NET=$($CONTAINER_BIN network ls --filter name='^opencodeco$' --quiet)
if [ -z "$NET" ]; then
echo "OpenCodeCo network not found. Creating one..."
if [ $($CONTAINER_BIN network create opencodeco) ]; then
echo "🕸️ Done!"
else
echo "🕸️ Failed to create OpenCodeCo network!"
exit 1
fi
else
echo "🕸️ OpenCodeCo network already exists!"
fi
exit
fi
COMPONENT="${STACK_PATH}/${1}"
if [ ! -d "${COMPONENT}" ]; then
printf "\033[0;31mWhoops! Component \"%s\" does not exists.\033[0m\\n" "${COMPONENT}" >&2
exit 1
fi
if [ ! -f "${COMPONENT}/docker-compose.yml" ]; then
printf "\033[0;31mWhoops! Component \"%s\" does not define a \"docker-compose.yml\".\033[0m\\n" "${COMPONENT}" >&2
exit 1
fi
CMD="${@:2}"
COMPOSE_FILES="-f ${COMPONENT}/docker-compose.yml"
if [ -f "${COMPONENT}/docker-compose.override.yml" ]; then
COMPOSE_FILES="${COMPOSE_FILES} -f ${COMPONENT}/docker-compose.override.yml"
fi
$CONTAINER_COMPOSE $COMPOSE_FILES ${CMD:-up -d}