Skip to content

Instantly share code, notes, and snippets.

@benrowe
Last active February 27, 2018 00:33
Show Gist options
  • Save benrowe/9e3159700811ff7fdb36a3fbfb3c5b26 to your computer and use it in GitHub Desktop.
Save benrowe/9e3159700811ff7fdb36a3fbfb3c5b26 to your computer and use it in GitHub Desktop.
composer and php 7 on unraid via docker

Install composer

  1. sudo nano /usr/local/bin/composer
  2. Add
    #!/bin/sh
    export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
    echo "Current working directory: '"$(pwd)"'"
    docker run --rm -v $(pwd):/app -v ~/.ssh:/root/.ssh composer/composer $@
    
  3. chmod +x /usr/local/bin/composer

Cli entry point

  1. cd /mnt/user/path/to/scripts
  2. touch cli.php
  3. touch cli
  4. chmod +x cli
  5. #!/bin/bash
    # runs the ./cli.php in the php:7.0-cli container
    TMP_DOCKER_NAME="my-scripts"
    DOCKER_IMAGE="php:7.0-cli"
    PHP_ENTRY="cli.php"
    docker run -it --rm --name $TMP_DOCKER_NAME -v "$PWD":/usr/src/myapp -w /usr/src/myapp "$DOCKER_IMAGE" php $PHP_ENTRY $@
    

Docker should now run globally and you should be able to execute cli.php with

./cli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment