Search code examples
laravelstripe-paymentslaravel-sail

Install Stripe CLI on Laravel Sail so that it can be used from within the command line in a devcontainer


I would like to be able to use the Stripe CLI from within the Laravel Sail terminal, meaning that I'd like to be able to issue commands such as sail strip login or, even better, just stripe login from within a Devcontainer terminal.


Solution

  • Assuming you already have a Laravel project with Sail installed and working:

    Step 1

    Publish the Dockerfile of Laravel Sail following the docs by running sail artisan sail:publish or php artisan sail:publish depending on your context

    Step 2

    In your project root, there will now be a docker folder. Navigate to the php version specified in your docker-compose.yaml file which is also in the project root.

    Locate && apt-get update \ and replace with the following:

        && curl -sS https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | tee /etc/apt/keyrings/stripe.gpg >/dev/null \
        && echo "deb [signed-by=/etc/apt/keyrings/stripe.gpg] https://packages.stripe.dev/stripe-cli-debian-local stable main" | tee /etc/apt/sources.list.d/stripe.list \
        && apt-get update \
        && apt-get install -y stripe \
    

    Step 3

    Run the command sail build --no-cache or otherwise rebuild your container (ie: from the Deccontainer menu in VS Code, Storm etc)

    Step 4

    You will now be able to issue commands such as sail stripe login or even stripe login if you're using a Devcontainer terminal.