Takeout Documentation

repository·main·Indexed 23 days ago

https://github.com/tighten/takeout

Takeout is a CLI tool that manages development environment dependencies by spinning up isolated Docker containers for services such as MySQL, Redis, and PostgreSQL. It serves as a lightweight, global alternative to project-specific docker-compose setups and is often used with Laravel Valet. The tool provides commands to enable, disable, start, stop, and shell into service containers, while managing a dedicated Docker network for predictable service aliasing.

Tokens
3.4K
Snippets
11
Records
27
Agent score
81%

What's inside Takeout

  1. How Takeout networking and aliasing works

    main

    All Takeout containers are automatically added to a dedicated Docker network named takeout. This allows containers to communicate with each other using predictable aliases.

    Each container is assigned two aliases on the takeout network:

    1. Base Alias: Based on the core dependency name (e.g., mysql, postgres).
    2. Full Alias: A combination of the base alias and the version (e.g., mysql8.0, postgres13).

    This networking model allows you to run multiple versions of the same dependency simultaneously on different ports and different volume names.

  2. Install Takeout via Composer

    main

    If you have a PHP environment available, you can install Takeout globally via Composer. Note that this method is not recommended and only supports the current major version of PHP.

    composer global require "tightenco/takeout:~2.9"
  3. Enable services with Takeout

    main

    Use the enable command to spin up Docker containers for your dependencies. You can enable a single service, multiple services, or use defaults to skip interactive prompts.

    • List available services: takeout enable
    • Enable specific services: takeout enable <service_name> (e.g., takeout enable mysql redis)
    • Enable with default parameters: takeout enable <service_name> --default (skips parameter prompts)

    Customizing the docker run command

    You can pass extra options to the underlying docker run command using the --run flag, and extra arguments to the container's entrypoint using the -- separator.

    • Extra docker run options: takeout enable mysql --run="{docker-run-options}"
    • Container Entrypoint arguments: takeout enable mysql -- -hsome.mysql.host -usome-user
    • Combining both: takeout enable mysql --run="{docker-run-options}" -- -hsome.mysql.host -usome-user
    takeout enable mysql --run="{docker-run-options}" -- -hsome.mysql.host -usome-user
  4. Build the Docker image manually

    main

    To build and publish a new version of the Docker image for multiple platforms (linux/amd64 and linux/arm64), use the docker buildx build command.

    Important: Ensure you have built the latest Takeout phar file locally (using php ./takeout app:build) before building the container, as the build process copies the file from ./builds/takeout into the image.

    docker buildx build --platform=linux/amd64,linux/arm64 -t tighten/takeout:latest --push .
  5. Install Takeout via Docker alias (Recommended)

    main

    The recommended installation method uses a Docker alias to run the Takeout CLI directly from a container. This avoids the need for a local PHP/Composer environment. Add the appropriate command to your shell configuration file (e.g., ~/.bashrc, ~/.zshrc).

    Linux or macOS:

    alias takeout="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --add-host=host.docker.internal:host-gateway -it tighten/takeout:latest"

    Windows 10|11 (Bash):

    alias takeout="docker run --rm -v //var/run/docker.sock:/var/run/docker.sock --add-host=host.docker.internal:host-gateway -it tighten/takeout:latest"

    Windows 10|11 (PowerShell):

    function takeout { docker run --rm -v //var/run/docker.sock:/var/run/docker.sock --add-host=host.docker.internal:host-gateway -it tighten/takeout:latest $args }

    To update the Takeout image, run docker pull tighten/takeout.

    alias takeout="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --add-host=host.docker.internal:host-gateway -it tighten/takeout:latest"
  6. Disable services with Takeout

    main

    Use the disable command to stop and remove containers. Because Takeout uses Docker persistent volumes, disabling a service does not delete its data. Re-enabling the service with the same parameters will restore your data.

    • List enabled services: takeout disable
    • Disable specific services: takeout disable <service_name>
    • Disable all services: takeout disable --all
  7. Manage container lifecycle (start, stop, shell)

    main

    Once services are enabled or disabled, you can manage their running state using the following commands:

    Starting stopped containers

    • List stopped containers: takeout start
    • Start specific container(s): takeout start {container_id}
    • Start all stopped containers: takeout start --all

    Stopping running containers

    • List running containers: takeout stop
    • Stop specific container(s): takeout stop {container_id}

    Accessing a container shell

    To open a shell inside a running service container: takeout shell {service} (e.g., takeout shell mysql). Takeout will attempt to use bash or sh depending on container support.

    takeout shell mysql
  8. Troubleshoot Docker buildx platform errors

    main

    If you encounter the error ERROR: Multiple platforms feature is currently not supported for docker driver, it means your current Docker driver does not support multi-platform builds.

    You must create and switch to a new buildx builder instance to resolve this.

    docker buildx create --use
  9. Configure application settings in app.php

    main

    The config/app.php file defines the core identity and environment of the Takeout application. You can modify the following keys to change how the application identifies itself and which services are loaded:

    • 'name': The name of your application (e.g., 'Takeout'). Used in notifications and other system messages.
    • 'version': The current version of the application. It defaults to the value provided by app('git.version').
    • 'env': The application environment (e.g., 'development', 'production'). This is pulled from the APP_ENV environment variable and defaults to 'development'. Note that this can be overridden at runtime using the global --env command-line option when executing commands.
    • 'providers': An array of service provider classes that are automatically loaded when the application starts. Use this to register custom functionality.
    return [
        'name' => 'Takeout',
        'version' => app('git.version'),
        'env' => env('APP_ENV', 'development'),
        'providers' => [
            App\Providers\AppServiceProvider::class,
        ],
    ];
  10. Stop command signature and options

    main

    The stop command uses the following signature and options:

    Arguments:

    • containerId?*: One or more container IDs or service names. The ?* indicates these are optional and can be provided multiple times.

    Options:

    • --all: Stops all currently active Takeout containers.
    stop {containerId?*} {--all}
  11. Configure the list command flags

    main

    The list command supports the following options:

    • --json: Outputs the list of enabled services as a JSON array instead of a table. Each item in the JSON array includes the container details and a category field derived from the container name.
    • --networking: Includes networking information when retrieving the list of containers from Docker.