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

add docker compose and simple nginx config for it #245

Merged
merged 6 commits into from
Sep 16, 2024
Merged
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
2 changes: 1 addition & 1 deletion apps/opik-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ EXPOSE 3003
ARG OPIK_VERSION
ENV OPIK_VERSION=${OPIK_VERSION}

ENTRYPOINT ["./entrypoint.sh"]
CMD ["./entrypoint.sh"]
38 changes: 38 additions & 0 deletions deployment/docker-compose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Run opik with docker-compose

## Installation Prerequisites for local installation

- Docker - https://docs.docker.com/engine/install/
- Docker Compose - https://docs.docker.com/compose/install/

## Run docker-compose using the images

If you want to use a specific version, set opik version like
```bash
export OPIK_VERSION=0.1.10
```

otherwise it will use the latest images

Run docker-compose
From the root of the project

```bash
cd deployment/docker-compose
docker compose up -d
```

## Run docker-compose with building application from latest code

From the root of the project

```bash
cd deployment/docker-compose
docker compose up -d --build
```

## Stop opik

```bash
docker compose down
```
111 changes: 111 additions & 0 deletions deployment/docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: opik

services:
mysql:
image: mysql:8.4.2
hostname: mysql
environment:
MYSQL_ROOT_PASSWORD: opik
MYSQL_DATABASE: opik
MYSQL_USER: opik
MYSQL_PASSWORD: opik
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
timeout: 1s
interval: 1s
retries: 300
ports:
- "3306:3306"
volumes: # Mounted on your $HOME folder
- ~/opik/mysql:/var/lib/mysql/

redis:
image: redis:7.2.4-alpine3.19
hostname: redis
command: redis-server --requirepass opik
ports:
- '6379:6379'
healthcheck:
test: [ "CMD", "nc", "-z", "localhost", "6379" ]
interval: 2s
timeout: 4s
retries: 20
start_period: 30s
restart: always


clickhouse:
image: clickhouse/clickhouse-server:23.8.15.35-alpine
hostname: clickhouse
environment:
CLICKHOUSE_DB: opik
CLICKHOUSE_USER: opik
CLICKHOUSE_PASSWORD: opik
# Enables SQL-driven Access Control and Account Management:
# https://clickhouse.com/docs/en/operations/access-rights#enabling-access-control
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
ports:
- "8123:8123" # HTTP default port
- "9000:9000" # Native Protocol port
volumes: # Mounted on your $HOME folder
- ~/opik/clickhouse/data:/var/lib/clickhouse/
- ~/opik/clickhouse/logs:/var/log/clickhouse-server/
healthcheck:
test: [ "CMD", "wget", "--spider", "-q", "http://127.0.0.1:8123/ping" ]
interval: 1s
timeout: 1s
retries: 300

backend:
image: ghcr.io/comet-ml/opik/opik-backend:${OPIK_VERSION:-latest}
build:
context: ../../apps/opik-backend
dockerfile: Dockerfile
platform: linux/amd64
hostname: backend
command: ["bash", "-c", "./run_db_migrations.sh && ./entrypoint.sh"]
environment:
DOCKER_BUILDKIT: 1
STATE_DB_URL: "jdbc:mysql://mysql:3306/opik?createDatabaseIfNotExist=true&rewriteBatchedStatements=true"
STATE_DB_DATABASE_NAME: opik
STATE_DB_USER: opik
STATE_DB_PASS: opik
ANALYTICS_DB_MIGRATIONS_URL: "jdbc:clickhouse://clickhouse:8123"
ANALYTICS_DB_MIGRATIONS_USER: opik
ANALYTICS_DB_MIGRATIONS_PASS: opik
ANALYTICS_DB_PROTOCOL: "HTTP"
ANALYTICS_DB_HOST: "clickhouse"
ANALYTICS_DB_PORT: 8123
ANALYTICS_DB_USERNAME: opik
ANALYTICS_DB_DATABASE_NAME: opik
JAVA_OPTS: "-Dliquibase.propertySubstitutionEnabled=true"
REDIS_URL: redis://:opik@redis:6379/
ANALYTICS_DB_PASS: opik
ports:
- "8080:8080"
- "3003:3003"
depends_on:
mysql:
condition: service_healthy
clickhouse:
condition: service_healthy

frontend:
image: ghcr.io/comet-ml/opik/opik-frontend:${OPIK_VERSION:-latest}
build:
context: ../../apps/opik-frontend
dockerfile: Dockerfile
platform: linux/amd64
hostname: frontend
ports:
- "5173:5173"
extra_hosts:
- "apihost:host-gateway"
volumes:
- ./nginx_default_local.conf:/etc/nginx/conf.d/default.conf
depends_on:
backend:
condition: service_started

networks:
default:
27 changes: 27 additions & 0 deletions deployment/docker-compose/nginx_default_local.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
server {
listen 5173;
server_name localhost;
root /usr/share/nginx/html;
index index.html;

location /api/ {
rewrite /api/(.*) /$1 break;
proxy_pass http://apihost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_read_timeout 90;
proxy_connect_timeout 90;
proxy_send_timeout 90;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

location / {
try_files $uri $uri/ /index.html;
}
}