Blossom Logo Blossom

Buildpack Customizations

2 min read

The buildpack strategy in Blossom allows you to customize your Docker image after the buildpack has created the base image. This is perfect for adding additional packages, setting environment variables, or performing any custom setup without having to learn the intricacies of the build process.

Note: This applies when your project is using the auto (the default) or buildpack build config build type strategy. You also achieve customization by using a Dockerfile build type instead. For most users, I think using the .blossom/build is easiest.

How It Works

  1. Blossom uses pack to build your application with the Heroku buildpack
  2. A Dockerfile is generated that uses the buildpack image as the base
  3. If a custom build script is detected, it’s automatically included in the Dockerfile
  4. The final Docker image is built with your customizations

Custom Build Script

To add customizations, simply create an executable script at .blossom/build in your project root:

.blossom/build

#!/bin/bash

echo "===> Running custom build script..."

# Install additional packages
apt-get update && apt-get install -y curl jq

# Set environment variables
echo "export CUSTOM_VAR=value" >> /etc/environment

# Create custom directories
mkdir -p /workspace/custom

# Copy additional files
cp -r /tmp/custom-files/* /workspace/

echo "===> Custom build script completed"

What You Can Do

Your custom build script can:

  • Install packages: Use apt-get since the heroku buildpack is ubuntu based
  • Set environment variables: Add custom environment variables
  • Run commands: Execute any commands needed for your application

Example Use Cases

Installing Additional Tools

#!/bin/bash
set -e

echo "===> Installing additional tools..."
curl -sSL https://get.docker.com | sh

Detection

Blossom automatically detects your custom build script when:

  • The file .blossom/build exists

You’ll see a log message when the script is detected:

===> Detected custom build script: .blossom/build

Troubleshooting

If your script isn’t being detected:

  • Ensure the file is at .blossom/build (not .blossom/build.sh)

If your script fails during build:

  1. Check the Docker build logs for error messages
  2. Test your script locally first
  3. Use set -e to catch errors early
  4. Add debug output with echo statements