Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 39 additions & 59 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,58 @@ version: '3.8'

services:
elasticsearch:
build:
context: ./src/elasticsearch
container_name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
container_name: copilot-elasticsearch
environment:
- discovery.type=single-node
- xpack.security.enabled=true
- ELASTIC_PASSWORD=hiFc1SbV
- xpack.security.http.ssl.enabled=false
- xpack.security.transport.ssl.enabled=false
ports:
- "9200:9200"
- "9300:9300"
volumes:
- data:/usr/share/elasticsearch/data
- logs:/usr/share/elasticsearch/logs
mem_limit: 1g
cpus: 1
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health/"]
interval: 30s
timeout: 10s
retries: 5
- elasticsearch_data:/usr/share/elasticsearch/data
networks:
- copilot-network

grafana:
build:
context: ./src/grafana
container_name: grafana
mem_limit: 1g
cpus: 0.5
image: grafana/grafana:latest
container_name: copilot-grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
ports:
- "3000:80"
depends_on:
- elasticsearch
- "3000:3000"
volumes:
- grafana:/var/lib/grafana
environment:
GF_LOG_LEVEL: debug
GF_SERVER_HTTP_PORT: 80
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: copilot
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80/api/health"]
interval: 30s
timeout: 10s
retries: 5

init-grafana:
mem_limit: 0.5g
cpus: 0.25
build:
context: ./src/cpuad-updater/grafana
container_name: init-grafana
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
depends_on:
- grafana
- elasticsearch
- cpuad-updater
environment:
ELASTICSEARCH_URL: http://elasticsearch:9200
GRAFANA_URL: http://grafana:80
GRAFANA_USERNAME: admin
GRAFANA_PASSWORD: copilot
restart: "no"
networks:
- copilot-network

cpuad-updater:
mem_limit: 0.5g
cpus: 0.25
python-updater:
build:
context: ./src/cpuad-updater
container_name: cpuad-updater
dockerfile: Dockerfile
container_name: copilot-updater
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
- ELASTICSEARCH_USER=elastic
- ELASTICSEARCH_PASS=hiFc1SbV
- GITHUB_PAT=${GITHUB_PAT}
- ORGANIZATION_SLUGS=${ORGANIZATION_SLUGS}
depends_on:
- elasticsearch
environment:
GITHUB_PAT: ${GITHUB_PAT}
ORGANIZATION_SLUGS: cody-test-org
ELASTICSEARCH_URL: http://elasticsearch:9200
# Add other environment variables as needed
restart: "no"
networks:
- copilot-network

volumes:
data:
logs:
grafana:
elasticsearch_data:
grafana_data:

networks:
copilot-network:
driver: bridge
2 changes: 2 additions & 0 deletions elastic-start-local/config/telemetry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
start-local:
version: 0.11.0
85 changes: 85 additions & 0 deletions elastic-start-local/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${ES_LOCAL_VERSION}
container_name: ${ES_LOCAL_CONTAINER_NAME}
volumes:
- dev-elasticsearch:/usr/share/elasticsearch/data
ports:
- 127.0.0.1:${ES_LOCAL_PORT}:9200
environment:
- discovery.type=single-node
- ELASTIC_PASSWORD=${ES_LOCAL_PASSWORD}
- xpack.security.enabled=true
- xpack.security.http.ssl.enabled=false
- xpack.license.self_generated.type=trial
- xpack.ml.use_auto_machine_memory_percent=true
- ES_JAVA_OPTS=${ES_LOCAL_JAVA_OPTS}
- cluster.routing.allocation.disk.watermark.low=${ES_LOCAL_DISK_SPACE_REQUIRED}
- cluster.routing.allocation.disk.watermark.high=${ES_LOCAL_DISK_SPACE_REQUIRED}
- cluster.routing.allocation.disk.watermark.flood_stage=${ES_LOCAL_DISK_SPACE_REQUIRED}
ulimits:
memlock:
soft: -1
hard: -1
healthcheck:
test:
[
"CMD-SHELL",
"curl --output /dev/null --silent --head --fail -u elastic:${ES_LOCAL_PASSWORD} http://elasticsearch:9200",
]
interval: 10s
timeout: 10s
retries: 30

kibana_settings:
depends_on:
elasticsearch:
condition: service_healthy
image: docker.elastic.co/elasticsearch/elasticsearch:${ES_LOCAL_VERSION}
container_name: ${KIBANA_LOCAL_SETTINGS_CONTAINER_NAME}
restart: 'no'
command: >
bash -c '
echo "Setup the kibana_system password";
start_time=$$(date +%s);
timeout=60;
until curl -s -u "elastic:${ES_LOCAL_PASSWORD}" -X POST http://elasticsearch:9200/_security/user/kibana_system/_password -d "{\"password\":\"${KIBANA_LOCAL_PASSWORD}\"}" -H "Content-Type: application/json" | grep -q "^{}"; do
if [ $$(($$(date +%s) - $$start_time)) -ge $$timeout ]; then
echo "Error: Elasticsearch timeout";
exit 1;
fi;
sleep 2;
done;
'

kibana:
depends_on:
kibana_settings:
condition: service_completed_successfully
image: docker.elastic.co/kibana/kibana:${ES_LOCAL_VERSION}
container_name: ${KIBANA_LOCAL_CONTAINER_NAME}
volumes:
- dev-kibana:/usr/share/kibana/data
- ./config/telemetry.yml:/usr/share/kibana/config/telemetry.yml
ports:
- 127.0.0.1:${KIBANA_LOCAL_PORT}:5601
environment:
- SERVER_NAME=kibana
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
- ELASTICSEARCH_USERNAME=kibana_system
- ELASTICSEARCH_PASSWORD=${KIBANA_LOCAL_PASSWORD}
- XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY=${KIBANA_ENCRYPTION_KEY}
- ELASTICSEARCH_PUBLICBASEURL=http://localhost:${ES_LOCAL_PORT}
healthcheck:
test:
[
"CMD-SHELL",
"curl -s -I http://kibana:5601 | grep -q 'HTTP/1.1 302 Found'",
]
interval: 10s
timeout: 10s
retries: 30

volumes:
dev-elasticsearch:
dev-kibana:
47 changes: 47 additions & 0 deletions elastic-start-local/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh
# Start script for start-local
# More information: https://github.com/elastic/start-local
set -eu

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "${SCRIPT_DIR}"
today=$(date +%s)
. ./.env
# Check disk space
available_gb=$(($(df -k / | awk 'NR==2 {print $4}') / 1024 / 1024))
required=$(echo "${ES_LOCAL_DISK_SPACE_REQUIRED}" | grep -Eo '[0-9]+')
if [ "$available_gb" -lt "$required" ]; then
echo "----------------------------------------------------------------------------"
echo "WARNING: Disk space is below the ${required} GB limit. Elasticsearch will be"
echo "executed in read-only mode. Please free up disk space to resolve this issue."
echo "----------------------------------------------------------------------------"
echo "Press ENTER to confirm."
# shellcheck disable=SC2034
read -r line
fi
if [ -z "${ES_LOCAL_LICENSE:-}" ] && [ "$today" -gt 1761894959 ]; then
echo "---------------------------------------------------------------------"
echo "The one-month trial period has expired. You can continue using the"
echo "Free and open Basic license or request to extend the trial for"
echo "another 30 days using this form:"
echo "https://www.elastic.co/trialextension"
echo "---------------------------------------------------------------------"
echo "For more info about the license: https://www.elastic.co/subscriptions"
echo
echo "Updating the license..."
docker compose up --wait elasticsearch >/dev/null 2>&1
result=$(curl -s -X POST "${ES_LOCAL_URL}/_license/start_basic?acknowledge=true" -H "Authorization: ApiKey ${ES_LOCAL_API_KEY}" -o /dev/null -w '%{http_code}\n')
if [ "$result" = "200" ]; then
echo "✅ Basic license successfully installed"
echo "ES_LOCAL_LICENSE=basic" >> .env
else
echo "Error: I cannot update the license"
result=$(curl -s -X GET "${ES_LOCAL_URL}" -H "Authorization: ApiKey ${ES_LOCAL_API_KEY}" -o /dev/null -w '%{http_code}\n')
if [ "$result" != "200" ]; then
echo "Elasticsearch is not running."
fi
exit 1
fi
echo
fi
docker compose up --wait
8 changes: 8 additions & 0 deletions elastic-start-local/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
# Stop script for start-local
# More information: https://github.com/elastic/start-local
set -eu

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "${SCRIPT_DIR}"
docker compose stop
60 changes: 60 additions & 0 deletions elastic-start-local/uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/sh
# Uninstall script for start-local
# More information: https://github.com/elastic/start-local
set -eu

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

ask_confirmation() {
echo "Do you confirm? (yes/no)"
read -r answer
case "$answer" in
yes|y|Y|Yes|YES)
return 0 # true
;;
no|n|N|No|NO)
return 1 # false
;;
*)
echo "Please answer yes or no."
ask_confirmation # Ask again if the input is invalid
;;
esac
}

cd "${SCRIPT_DIR}"
if [ ! -e "docker-compose.yml" ]; then
echo "Error: I cannot find the docker-compose.yml file"
echo "I cannot uninstall start-local."
fi
if [ ! -e ".env" ]; then
echo "Error: I cannot find the .env file"
echo "I cannot uninstall start-local."
fi
echo "This script will uninstall start-local."
echo "All data will be deleted and cannot be recovered."
if ask_confirmation; then
docker compose rm -fsv
docker compose down -v
rm docker-compose.yml .env uninstall.sh start.sh stop.sh config/telemetry.yml
if [ -z "$(ls -A config)" ]; then
rm -d config
fi
echo
echo "Do you want to remove the following Docker images?"
echo "- docker.elastic.co/elasticsearch/elasticsearch:9.1.4"
echo "- docker.elastic.co/kibana/kibana:9.1.4"
if ask_confirmation; then
if docker rmi "docker.elastic.co/elasticsearch/elasticsearch:9.1.4" >/dev/null 2>&1; then
echo "Image docker.elastic.co/elasticsearch/elasticsearch:9.1.4 removed successfully"
else
echo "Failed to remove image docker.elastic.co/elasticsearch/elasticsearch:9.1.4. It might be in use."
fi
if docker rmi docker.elastic.co/kibana/kibana:9.1.4 >/dev/null 2>&1; then
echo "Image docker.elastic.co/kibana/kibana:9.1.4 removed successfully"
else
echo "Failed to remove image docker.elastic.co/kibana/kibana:9.1.4. It might be in use."
fi
fi
echo "Start-local successfully removed"
fi
Loading