Skip to content

Commit

Permalink
feat: add clickhouse db create on app start (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
darshit-s3 authored May 4, 2024
1 parent 934e304 commit ea5cd7b
Show file tree
Hide file tree
Showing 6 changed files with 449 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ NEXTAUTH_URL_INTERNAL="${NEXT_PUBLIC_HOST}"
CLICK_HOUSE_HOST="http://langtrace-clickhouse:8123"
CLICK_HOUSE_USER="default"
CLICK_HOUSE_PASSWORD=""
CLICK_HOUSE_DATABASE_NAME="langtrace_dev"
CLICK_HOUSE_DATABASE_NAME="langtrace_traces"

# Admin login
ADMIN_EMAIL="[email protected]"
ADMIN_PASSWORD="langtraceadminpw"
NEXT_PUBLIC_ENABLE_ADMIN_LOGIN="true"
NEXT_PUBLIC_ENABLE_ADMIN_LOGIN="true"
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN npm install

EXPOSE 3000

CMD [ "/bin/sh", "-c", "npm run create-tables && npm run dev" ]
CMD [ "/bin/sh", "-c", "npm run dev" ]


# Intermediate image for building the application
Expand All @@ -36,10 +36,11 @@ COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/package.json .
COPY --from=builder /app/public ./public
COPY --from=builder /app/scripts ./scripts

# Install only production dependencies
RUN npm install --only=production --omit=dev

CMD [ "/bin/sh", "-c", "npm run create-tables && npm start" ]
CMD [ "/bin/sh", "-c", "npm start" ]

EXPOSE 3000
19 changes: 4 additions & 15 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

services:
langtrace-app:
container_name: langtrace
Expand All @@ -13,15 +11,17 @@ services:
- .env
ports:
- "3000:3000"
command: npm run dev
# Uncmment this for development
# volumes:
# - .:/app
restart: on-failure:5
depends_on:
postgres-db:
condition: service_started
required: true
clickhouse-init:
condition: service_completed_successfully
clickhouse-db:
condition: service_healthy
required: true

postgres-db:
Expand Down Expand Up @@ -49,17 +49,6 @@ services:
volumes:
- clickhouse-data:/var/lib/clickhouse

clickhouse-init:
container_name: langtrace-clickhouse-init
image: clickhouse/clickhouse-server:23.3.20.27-alpine
env_file:
- .env
depends_on:
clickhouse-db:
condition: service_healthy
required: true
command: clickhouse-client --host langtrace-clickhouse --query 'CREATE DATABASE IF NOT EXISTS $CLICK_HOUSE_DATABASE_NAME;'

langtrace-app-prod:
extends:
service: langtrace-app
Expand Down
Loading

0 comments on commit ea5cd7b

Please sign in to comment.