Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coolify deployment #54

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions coolify-demo/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env
readme.md
docker-compose.*
Dockerfile*
1 change: 1 addition & 0 deletions coolify-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
30 changes: 30 additions & 0 deletions coolify-demo/Dockerfile-KBN-noSSL
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ARG KBN_VERSION=8.14.3
FROM docker.elastic.co/kibana/kibana:${KBN_VERSION}

ARG KBN_VERSION
ARG ROR_VERSION=1.60.0

WORKDIR .

USER root
RUN apt-get update && apt-get install -y bash sed && rm -rf /var/lib/apt/lists/*

COPY ./ror-demo-cluster /ror-demo-cluster
WORKDIR /ror-demo-cluster

# disabling SSL in Kibana config
RUN sed -i 's/server.ssl.enabled: true/server.ssl.enabled: false/' conf/kbn/ror-newplatform-kibana.yml
RUN sed -i 's/server.ssl.enabled: true/server.ssl.enabled: false/' conf/kbn/ror-oldplatform-kibana.yml

RUN cp ./conf/kbn/ror-newplatform-kibana.yml /usr/share/kibana/config/ && \
cp ./conf/kbn/ror-oldplatform-kibana.yml /usr/share/kibana/config/ && \
# at least .key is required even without SSL enabled ssl_config will be run @ startup
cp ./conf/kbn/kibana.crt /usr/share/kibana/config/ && \
cp ./conf/kbn/kibana.key /usr/share/kibana/config/ && \
cp ./images/kbn/install-ror-kbn-using-api.sh /tmp/install-ror.sh

WORKDIR /usr/share/kibana
RUN /tmp/install-ror.sh && \
chown -R kibana:kibana /usr/share/kibana/config

USER kibana
11 changes: 11 additions & 0 deletions coolify-demo/build_starter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

echo "🏃🏿‍♂️‍➡️ build_starter: installing dependencies"
# coolify-helper image uses Alpine
apk update && apk add jq curl

echo "🏃🏿‍♂️‍➡️ build_starter: setting up environment variables"
source set_env_vars.sh

echo "🏃🏿‍♂️‍➡️ build_starter: starting the 🐳 build"
docker compose build
17 changes: 17 additions & 0 deletions coolify-demo/docker-compose.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:

es-ror:
networks:
- es-ror-network

kbn-ror:
networks:
- es-ror-network

initializer:
networks:
- es-ror-network

networks:
es-ror-network:
driver: bridge
83 changes: 83 additions & 0 deletions coolify-demo/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
services:

es-ror:
container_name: es-ror
env_file: ".env"
build:
context: ../ror-demo-cluster
dockerfile: images/es/Dockerfile-use-ror-binaries-from-api
args:
ES_VERSION: ${ES_VERSION:-8.14.3}
ROR_VERSION: ${ROR_ES_VERSION:-1.60.0}
ports:
- "19200:9200"
- "19300:9300"
- "5000:5000"
environment:
- cluster.name=ror-es-cluster
- node.name=es-ror-single
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5000"
- ES_VERSION=${ES_VERSION:-8.14.3}
healthcheck:
test: [ "CMD", "curl", "-fk", "-u", "admin:admin", "https://localhost:9200/_cluster/health" ]
interval: 10s
timeout: 10s
retries: 30
start_period: 60s
ulimits:
memlock:
soft: -1
hard: -1

kbn-ror:
container_name: kbn-ror
env_file: ".env"
build:
context: ..
dockerfile: coolify-demo/Dockerfile-KBN-noSSL
args:
KBN_VERSION: ${KBN_VERSION:-8.14.3}
ROR_VERSION: ${ROR_KBN_VERSION:-1.60.0}
depends_on:
es-ror:
condition: service_healthy
ports:
- "15601:5601"
environment:
ELASTICSEARCH_HOSTS: https://es-ror:9200
ROR_ACTIVATION_KEY: $ROR_ACTIVATION_KEY
healthcheck:
test: [ "CMD", "curl", "-fk", "-u", "admin:admin", "http://localhost:5601/api/features" ]
interval: 10s
timeout: 10s
retries: 30
start_period: 60s
ulimits:
memlock:
soft: -1
hard: -1

initializer:
container_name: initializer
build:
context: ../ror-demo-cluster
dockerfile: images/cluster-initializer/Dockerfile
depends_on:
es-ror:
condition: service_healthy
kbn-ror:
condition: service_healthy
environment:
ELASTICSEARCH_ADDRESS: https://es-ror:9200
ELASTICSEARCH_USER: kibana
ELASTICSEARCH_PASSWORD: kibana
healthcheck:
test: "test -f /tmp/init_done || exit 1"
interval: 10s
timeout: 10s
retries: 30
start_period: 60s
volumes:
- ../ror-demo-cluster/init-scripts:/scripts:ro
53 changes: 53 additions & 0 deletions coolify-demo/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Deploying ROR Playground cluster to Coolify

## Coolify deployment instructions

1. Add a new Resource
- Git Based / Public Repository
```
https://github.com/beshu-tech/ror-sandbox
```

2. Please set "Build Pack" => **Docker Compose**

3. Set the "Base Directory":
```
/coolify-demo
```

4. You may see an error message "fatal: Remote branch main not found in upstream origin"
- go to the "Sources" (inner left menu) and choose `master` as your Branch
- Save the changes and go to General => Reload Compose File
- if this doesn't work; reload the page with F5, make sure the "Sources" are set properly and try again'

5. Add the domain in "General/Domains":
- fill the "Domains for Kbn Ror" with whatever domain you want to use e.g. `https://ror-demo.anaphora.it`

6. Set the following in "General/Build":
- use *Custom Build Command* as follows:
```
chmod +x coolify-demo/build_starter.sh && cd coolify-demo && ./build_starter.sh
```
And the *Custom Start Command*:
```
cd coolify-demo && docker compose up --no-build -d
```
- please also check ☑️ "Preserve Repository During Deployment" option

7. Save the changes and hit the ▶️ Deploy button

8. Wait until the deployment is finished, open the URL you've entered in your browser and use the demo credentials:
- `admin` as a username and password

Enjoy! 🚀

## Local development instructions

To start the stack locally, please use the following command in current directory:
```shell
docker compose -f docker-compose.yaml -f docker-compose.local.yaml up --build -d
```
- please note that you'll need to run the pre-deployment script one time to create dotenv file:
```shell
chmod +x set_env_vars.sh && ./set_env_vars.sh
```
25 changes: 25 additions & 0 deletions coolify-demo/set_env_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

if ! command -v jq &> /dev/null
then
echo -e "jq is required:\n\nsudo apt-get update && sudo apt-get install jq"
exit 1
fi

response=$(curl -s https://api.beshu.tech/list_es_versions)
pluginVersion=$(echo "$response" | jq -r '.pluginVersion')
esVersion=$(echo "$response" | jq -r '.es[0]')
kbnVersion=$(echo "$response" | jq -r '.kbn_universal[0]')

# instead of exporting, we should add .env file we'll map in docker-compose services
output_file=".env"
mkdir -p "$(dirname "$output_file")"
{
echo "ROR_ES_VERSION=\"$pluginVersion\""
echo "ROR_KBN_VERSION=\"$pluginVersion\""
echo "ES_VERSION=\"$esVersion\""
echo "KBN_VERSION=\"$kbnVersion\""
} > "$output_file"

echo "Environment variables have been written to: $output_file"
cat "$output_file"