Skip to content

Instantly share code, notes, and snippets.

@carloscarucce
Last active April 3, 2024 02:21
Show Gist options
  • Save carloscarucce/c8b2380a1f347c2437e0303e939a9320 to your computer and use it in GitHub Desktop.
Save carloscarucce/c8b2380a1f347c2437e0303e939a9320 to your computer and use it in GitHub Desktop.
Determines whenever to run install, update or simply skip...
#!/bin/sh
# @author: Carlos A. Bertholdo Carucce
# <https://github.com/carloscarucce>
if [[ ! -f "composer.json" ]]; then
echo "[Composer] composer.json was not found" >&2
exit 1;
fi
if [[ -f "composer.lock" ]] && [[ -d "vendor" ]]; then
if [[ composer.json -nt composer.lock ]]; then
echo "[Composer] Updating dependencies: "
composer update --no-interaction
else
echo "[Composer] Nothing to install or update..."
fi
else
echo "[Composer] Installing dependencies: "
composer install --no-interaction
fi
# Example usage with Docker Compose
version: "1.0"
services:
composer:
image: composer:latest
volumes:
- ./:/app
working_dir: /app
command: ./composer-bootstrap.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment