Skip to content

Instantly share code, notes, and snippets.

@geerlingguy
Last active August 16, 2023 12:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geerlingguy/85b816ed7aff378ea2700b82ebde81c8 to your computer and use it in GitHub Desktop.
Save geerlingguy/85b816ed7aff378ea2700b82ebde81c8 to your computer and use it in GitHub Desktop.
BLT Artifactory - Build BLT deployment artifacts with Docker
#!/bin/bash
#
# BLT Deployment Artifact generator using a local Docker image.
#
# Source: https://gist.github.com/geerlingguy/85b816ed7aff378ea2700b82ebde81c8
#
# This script should be run from within the BLT project directory root. If it is
# run elsewhere, the project_dir should be updated accordingly.
name="blt-artifactory"
project_dir="."
# Remove any existing "deploy/" directory.
printf "Removing any previously-existing deployment artifacts.\n"
rm -rf $project_dir/deploy/
# Start the build container.
printf "Starting the build container.\n"
docker run -d --name $name -v `pwd`/$project_dir:/blt php:7.2-cli-stretch tail -f /dev/null
# Install dependencies.
docker exec $name bash -c "apt-get update && apt-get install -y gnupg unzip git libpng-dev libbz2-dev"
docker exec $name bash -c "docker-php-ext-install gd \
&& docker-php-ext-install bz2"
# Install Node.js 8.x.
docker exec $name bash -c "curl -sL https://deb.nodesource.com/setup_8.x | bash -"
docker exec $name bash -c "apt-get install -y nodejs"
# Install Composer.
docker exec $name bash -c "php -r \"copy('https://getcomposer.org/installer', 'composer-setup.php');\" \
&& php composer-setup.php \
&& mv composer.phar /usr/local/bin/composer"
# Install dependencies and BLT alias.
docker exec $name bash -c "cd /blt && composer install"
# Generate the deployment artifact.
printf "Generating the deployment artifact.\n"
docker exec $name bash -c "cd /blt && vendor/bin/blt artifact:build"
# Destroy the build container.
docker rm -f $name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment