Root — docker-compose.yml

Module: root-docker-compose-yml Cohesion: 0.80 Members: 0

Root — docker-compose.yml

This document details the docker-compose.yml file, which serves as the primary orchestration tool for developing and running the Grok CLI application within Docker containers.

docker-compose.yml Overview

The docker-compose.yml file defines and configures the multi-container Docker application for the Grok CLI. Its main purpose is to:

  1. Standardize Development Environments: Ensure all developers work with the same dependencies and environment setup.
  2. Simplify Production Deployment: Provide a consistent way to build and run the CLI in a production-like container.
  3. Manage Dependencies: Define how the application's services interact and share resources like volumes.

This file acts as the blueprint for building the Docker images and running the containers that host the Grok CLI.

Key Components

The docker-compose.yml file defines two primary services: grok for production-like execution and grok-dev for development, along with a named volume for persistent configuration.

graph TD
    A[docker-compose.yml] --> B(Service: grok)
    A --> C(Service: grok-dev)
    B -- Builds from --> D(Dockerfile: production target)
    C -- Builds from --> E(Dockerfile: development target)
    B -- Mounts --> F(Volume: grok-config)
    C -- Mounts --> F

Services

grok Service (Production Environment)

This service is designed for running the Grok CLI in a production-ready or testing environment. It builds the application using the optimized production target from the project's Dockerfile.

Usage Example: To run the Grok CLI with a prompt:

GROK_API_KEY="your_api_key" docker-compose run --rm grok "explain this code"

grok-dev Service (Development Environment)

This service is tailored for active development, providing a live-reloading environment. It uses the development target from the Dockerfile, which typically includes development tools and dependencies.

Usage Example: To start the development server:

GROK_API_KEY="your_api_key" docker-compose run --rm grok-dev

Or, to build and run the dev container in detached mode:

GROK_API_KEY="your_api_key" docker-compose up -d grok-dev

Volumes

grok-config

This is a named Docker volume defined at the root level of the docker-compose.yml.

Connection to the Codebase

The docker-compose.yml file is intrinsically linked to the rest of the codebase through the build: context: . directive. This means that the Dockerfile located in the project root is used to build the Docker images for both grok and grok-dev services.

This setup ensures that the application's runtime environment is consistent and reproducible, whether for local development or potential deployment. Developers can rely on docker-compose to quickly spin up a fully configured environment without manually installing dependencies or configuring paths.