### Install Buildrunner requirements Source: https://github.com/adobe/buildrunner/blob/main/examples/README.rst Installs the Python dependencies listed in requirements.txt. ```sh pip install -r requirements.txt ``` -------------------------------- ### Create and activate virtual environment Source: https://github.com/adobe/buildrunner/blob/main/examples/README.rst Creates a Python virtual environment and activates it before installing Buildrunner requirements. ```sh python -m venv .venv source .venv/bin/activate ``` -------------------------------- ### Development Installation from Source Source: https://github.com/adobe/buildrunner/blob/main/docs/installation.rst Clones the Buildrunner repository and syncs dependencies using uv. After these steps, the buildrunner executable is available via 'uv run buildrunner'. ```bash git clone https://github.com/adobe/buildrunner.git cd buildrunner uv sync ``` -------------------------------- ### Run build with example configuration list file Source: https://github.com/adobe/buildrunner/blob/main/examples/build/builders/README.rst Alternative command using the global-config-list.yaml file. ```sh ./run-buildrunner.sh -f examples/build/builders/buildrunner.yaml -c examples/build/builders/global-config-list.yaml ``` -------------------------------- ### Run build with example configuration file Source: https://github.com/adobe/buildrunner/blob/main/examples/build/builders/README.rst Run from the base directory using the example configuration file. ```sh ./run-buildrunner.sh -f examples/build/builders/buildrunner.yaml -c examples/build/builders/global-config.yaml ``` -------------------------------- ### Run Buildrunner with basic example configuration Source: https://github.com/adobe/buildrunner/blob/main/examples/README.rst Example command that runs Buildrunner using the basic buildrunner.yaml configuration file. ```sh ./run-buildrunner.sh -f examples/build/basic/buildrunner.yaml ``` -------------------------------- ### Install buildrunner in another repository with uv tool install Source: https://github.com/adobe/buildrunner/blob/main/docs/development.rst Installs a working version of buildrunner in another repository using uv tool install. Replace the path with the actual path to the cloned buildrunner repository. ```bash uv tool install ../buildrunner ``` -------------------------------- ### Install dependencies with uv sync Source: https://github.com/adobe/buildrunner/blob/main/docs/development.rst Installs project dependencies using uv. Required after cloning the repository and before running tests or buildrunner. ```bash uv sync ``` -------------------------------- ### Install Buildrunner with uv tool install Source: https://github.com/adobe/buildrunner/blob/main/docs/installation.rst Installs Buildrunner directly on your local machine using Astral UV. UV manages Python versions, virtual environments, and dependencies. After running this command, the buildrunner executable is available in your path. ```bash uv tool install buildrunner ``` -------------------------------- ### Run buildrunner with --help Source: https://github.com/adobe/buildrunner/blob/main/docs/development.rst Runs buildrunner with the --help flag to display usage information. Use this after installing buildrunner in another repository to verify the installation. ```bash buildrunner --help ``` -------------------------------- ### Run Buildrunner with a configuration file Source: https://github.com/adobe/buildrunner/blob/main/examples/README.rst Executes Buildrunner using the specified configuration file path. ```sh ./run-buildrunner.sh -f examples/ ``` -------------------------------- ### Run buildrunner locally with uv run Source: https://github.com/adobe/buildrunner/blob/main/docs/development.rst Runs buildrunner locally using uv run to ensure the latest local changes are used. The examples/ directory contains example configuration files; this command uses examples/build/basic/buildrunner.yaml. ```bash uv run buildrunner -f examples/build/basic/buildrunner.yaml ``` -------------------------------- ### GitHub.com Configuration Example Source: https://github.com/adobe/buildrunner/blob/main/docs/fetching-files.rst Suggested configuration entry for referencing files from GitHub.com. Uses endpoint 'https://api.github.com' without a version field. ```yaml github: github: endpoint: 'https://api.github.com' username: 'USERNAME' app_token: 'APP_TOKEN' ``` -------------------------------- ### GitHub Enterprise Configuration Example Source: https://github.com/adobe/buildrunner/blob/main/docs/fetching-files.rst Suggested configuration entry for referencing files from GitHub Enterprise. Uses endpoint 'https://git.company.com/api' with version 'v3'. ```yaml github: company_github: endpoint: 'https://git.company.com/api' version: 'v3' username: 'USERNAME' app_token: 'APP_TOKEN' ``` -------------------------------- ### Clone the buildrunner repository Source: https://github.com/adobe/buildrunner/blob/main/docs/development.rst Clones the buildrunner repository from GitHub. Required as the first step for unit tests, running locally, and installing in another repository. ```bash git clone https://github.com/adobe/buildrunner.git ``` -------------------------------- ### Run Buildrunner with uvx Source: https://github.com/adobe/buildrunner/blob/main/docs/installation.rst Runs Buildrunner directly using the uvx command, which automatically downloads and installs Buildrunner into an isolated environment that is cached for subsequent runs. The second line shows how to run with a specific Python version (3.12). ```bash uvx buildrunner # Run with a specific python version uvx -p3.12 buildrunner ``` -------------------------------- ### Create builders script Source: https://github.com/adobe/buildrunner/blob/main/examples/build/builders/README.rst Run from the base directory to create builders. ```sh python examples/build/builders/create_builders.sh ``` -------------------------------- ### Run all unit tests with uv run pytest Source: https://github.com/adobe/buildrunner/blob/main/docs/development.rst Runs the full unit test suite using pytest. Executed from the repository root after dependencies are installed. ```bash uv run pytest ``` -------------------------------- ### Two-step workflow: package and integration test Source: https://github.com/adobe/buildrunner/blob/main/README.rst YAML example using one step to create a package and another to run an integration test. The first step builds a container and runs it to produce a WAR artifact; the second step is not shown in detail but is implied by the comment. ```yaml steps: package: # This build context contains a Dockerfile that create an image that runs # mvn as the default command in the /source directory. build: package-container run: artifacts: target/*.war: ``` -------------------------------- ### Single builder per platform configuration Source: https://github.com/adobe/buildrunner/blob/main/examples/build/builders/README.rst Alternative configuration with one builder per platform. ```yaml platform-builders: linux/amd64: builder1 linux/arm64: builder2 ``` -------------------------------- ### Buildrunner secrets configuration example Source: https://github.com/adobe/buildrunner/blob/main/README.rst Shows the secrets section format for buildrunner configuration, with file and environment variable secret examples. The syntax matches Docker's --secret option. ```yaml # Specify the secrets that should be used when building your image, # similar to the --secret option used by Docker # More info about secrets: https://docs.docker.com/build/building/secrets/ secrets: # Example of a secret that is a file - id=secret1,src= # Example of a secret that is an environment variable - id=secret2,env= ``` -------------------------------- ### Example Global Configuration YAML Source: https://github.com/adobe/buildrunner/blob/main/docs/global-configuration.rst Shows the available global configuration options for Buildrunner: 'env' sets environment variables available to all runs (values must be strings), 'build-servers' maps user@host servers to host aliases, and 'ssh-keys' lists SSH key configurations with a 'file' attribute for the local private key path. ```yaml # The 'env' global configuration may be used to set environment variables # available to all buildrunner runs that load this config file. Env vars do # not need to begin with a prefix to be included in this list (i.e. # BUILDRUNNER_ prefix is not needed for variables listed here). env: ENV_VAR1: 'value1' # Values must always be strings ENV_VAR2: 'true'' # The 'build-servers' global configuration consists of a map where each key # is a server user@host string and the value is a list of host aliases that # map to the server. This allows builders to configure Buildrunner to talk to # specific servers within their environment on a project by project basis. build-servers: user@host: - alias1 - alias2 # The 'ssh-keys' global configuration is a list of ssh key configurations. # The file attribute specifies the path to a local ssh private key. The key ``` -------------------------------- ### Multiple builders per platform configuration Source: https://github.com/adobe/buildrunner/blob/main/examples/build/builders/README.rst Recommended for load balancing. When multiple builders are available for a platform, Buildrunner randomly selects one to distribute the load. ```yaml platform-builders: linux/amd64: - builder1 - builder2 - builder3 linux/arm64: - builder4 - builder5 ``` -------------------------------- ### Run step with default command and artifacts Source: https://github.com/adobe/buildrunner/blob/main/README.rst YAML example of a 'run' definition that runs the default command from the specified Docker image and archives the given artifacts. The 'artifacts' map specifies a build artifact path with a platform label. ```yaml steps: package: run: image: myimages/image-with-cmd:latest artifacts: build/artifacts/*.x86_64.rpm: {platform: 'centos-8-x86_64'} ``` -------------------------------- ### Remove builders script Source: https://github.com/adobe/buildrunner/blob/main/examples/build/builders/README.rst Run from the base directory to remove builders. ```sh python examples/build/builders/remove_builders.sh ``` -------------------------------- ### Configure Docker Hub proxy registry in global config Source: https://github.com/adobe/buildrunner/blob/main/docs/common-issues.rst Adds the docker-registry key to the global configuration file (typically ~/.buildrunner.yaml) to point to a Docker Hub proxy registry. The example registry docker-mirror.example.com does not actually exist. ```yaml docker-registry: docker-mirror.example.com ``` -------------------------------- ### Build custom image and run with artifacts Source: https://github.com/adobe/buildrunner/blob/main/README.rst YAML example that builds a custom image using a build context and Dockerfile in a subdirectory of the project, then uses the resulting image for the run container. The 'build' key references the build context directory. ```yaml steps: package: build: package-container run: artifacts: build/artifacts/*.x86_64.rpm: ``` -------------------------------- ### Run a specific test file with uv run pytest Source: https://github.com/adobe/buildrunner/blob/main/docs/development.rst Runs a single test file by providing its path. Use this to target a specific test file, for example tests/test_buildrunner.py. ```bash uv run pytest tests/test_buildrunner.py ``` -------------------------------- ### Dockerfile: Multi-stage Dockerfile for building base and dependent images Source: https://github.com/adobe/buildrunner/blob/main/docs/common-issues.rst A multi-stage Dockerfile that defines stage1 and stage2. This is the recommended solution to avoid the failure described in the previous YAML example, as it builds both images in a single build process. ```dockerfile # Put this in a common Dockerfile used by both build steps below FROM {{ DOCKER_REGISTRY }}/busybox:latest AS stage1 CMD /do-something-cool FROM stage1 AS stage2 CMD /do-something-else ``` -------------------------------- ### Service Container Limits Configuration Source: https://github.com/adobe/buildrunner/blob/main/docs/resource-limits.rst Applies resource limits to a service container (e.g., database) within a run step. The example limits the 'database' service to 256m memory and 512 CPU shares, while the main container runs without explicit limits. ```yaml steps: my-step: run: image: ubuntu:20.04 services: database: image: postgres:13 mem-limit: "256m" cpu-shares: 512 env: POSTGRES_PASSWORD: example cmd: echo "Main container with limited database service" ``` -------------------------------- ### Rename artifacts with same name Source: https://github.com/adobe/buildrunner/blob/main/README.rst YAML example showing how to rename artifacts that would otherwise have the same name. Each artifact path is mapped to a 'rename' key to give it a unique name. ```yaml steps: package: build: package-container run: artifacts: build/artifacts/variation1/package-container.x86_64.rpm: rename: package-container1.x86_64.rpm build/artifacts/variation2/package-container.x86_64.rpm: rename: package-container2.x86_64.rpm ``` -------------------------------- ### Buildrunner configuration with secrets and Dockerfile Source: https://github.com/adobe/buildrunner/blob/main/README.rst Complete buildrunner configuration example showing use-legacy-builder set to false, a build step with a Dockerfile using --mount for secrets, and the secrets section with file and environment variable secrets. Requires updating the Dockerfile to add --mount at the beginning of each RUN command that needs the secret. ```yaml use-legacy-builder: false steps: build-my-container: build: dockerfile: | FROM alpine:latest # Using secrets inline RUN --mount=type=secret,id=secret1 \ --mount=type=secret,id=secret2 \ echo Using secrets in my build - secret1 file located at /run/secrets/secret1 with contents $(cat /run/secrets/secret1) and secret2=$(cat /run/secrets/secret2) # Using secrets in environment variables RUN --mount=type=secret,id=secret1 \ --mount=type=secret,id=secret2 \ SECRET1_FILE=/run/secrets/secret1 \ SECRET2_VARIABLE=$(cat /run/secrets/secret2) \ && echo Using secrets in my build - secret1 file located at $SECRET1_FILE with contents $(cat $SECRET1_FILE) and secret2=$SECRET2_VARIABLE secrets: # Example of a secret that is a file - id=secret1,src=examples/build/secrets/secret1.txt # Example of a secret that is an environment variable - id=secret2,env=SECRET2 ``` -------------------------------- ### List and force-remove orphaned buildrunner containers Source: https://github.com/adobe/buildrunner/blob/main/docs/common-issues.rst Commands to find and force-remove orphaned buildrunner containers on an agent using the labels passed via --container-labels. Adjust the label key to match your setup. ```bash # List all containers with buildrunner labels (adjust label key to match your setup) docker ps -a --filter label=com.example.build.source=buildrunner # Force-remove all orphaned buildrunner containers docker ps -q --filter label=com.example.build.source=buildrunner | xargs -r docker rm -f ``` -------------------------------- ### CPU Limits Configuration (cpu-shares, cpu-period, cpu-quota) Source: https://github.com/adobe/buildrunner/blob/main/docs/resource-limits.rst Configures CPU resource limits for a run step container. 'cpu-shares' is a relative weight (default 1024), 'cpu-period' is in microseconds (default 100000), and 'cpu-quota' limits CPU time within the period. The example sets a quota of 50000 with period 100000, giving 50% of one CPU core. ```yaml steps: my-step: run: image: ubuntu:20.04 cpu-shares: 512 # Relative weight (default 1024) cpu-period: 100000 # Period in microseconds cpu-quota: 50000 # Quota in microseconds (50% of one CPU) cmd: echo "Running with CPU limits" ``` -------------------------------- ### Push and commit to multiple repositories Source: https://github.com/adobe/buildrunner/blob/main/README.rst Shows how to push or commit an image to multiple repositories, where each list entry may be a string or a dictionary with additional tags. ```yaml steps: build-my-container: build: . # To push the docker image to multiple repositories push: - myimages/image1 - repository: myimages/image2 tags: [ 'latest' ] # OR to just commit it locally to use in subsequent steps commit: repository: myimages/image1 tags: [ 'latest' ] ``` -------------------------------- ### Fetch URL Syntax Source: https://github.com/adobe/buildrunner/blob/main/docs/fetching-files.rst Defines the URL format for referencing a fetch back-end: BACKEND://REPOSITORY/PATH. BACKEND is the fetch back-end (github, http, file, etc.), REPOSITORY is a label referencing configuration in Buildrunner configuration files, and PATH is the unique path or ID of the artifact. ```yaml ``BACKEND://REPOSITORY/PATH`` ``` -------------------------------- ### Simple pypi-push configuration with repository index Source: https://github.com/adobe/buildrunner/blob/main/README.rst Defines a pypi-push step that only specifies the repository index as defined in the ~/.pypirc file. The push only occurs if the --push argument is used, similar to pushing Docker images to remote registries. ```yaml steps: pypi: run: image: python:2 cmds: - python setup.py sdist artifacts: "dist/*.tar.gz": { type: 'python-sdist' } pypi-push: artifactory-releng ``` -------------------------------- ### Optional buildrunner configuration syntax version with services Source: https://github.com/adobe/buildrunner/blob/main/README.rst Shows a test step with a database and Tomcat service, including ports, environment variables, and a curl command to verify the app. ```yaml test: run: services: database-server: image: mysql:5.7 ports: 3306: tomcat-server: # The build context defined here contains a Dockerfile that # installs the war generated in the previous step. The war is # available at /artifacts/package/*.war. build: tomcat-server-container ports: 8080: env: # Pass the mysql connection string as an environment variable to # the container. DB_CONNECT_URL: jdbc:mysql://database-server:3306/dbname image: ubuntu:latest # Run a simple 'test' to verify the app is responding. cmd: 'curl -v http://tomcat-server:8080/myapp/test.html' ``` -------------------------------- ### Simple push and commit configuration Source: https://github.com/adobe/buildrunner/blob/main/README.rst Defines a step that builds the current directory and either pushes the image to a registry or commits it locally for later steps. ```yaml steps: build-my-container: build: . # To push the docker image to a registry push: myimages/image1 # OR to just commit it locally to use in subsequent steps commit: myimages/image1 ``` -------------------------------- ### Github Fetch Configuration Template Source: https://github.com/adobe/buildrunner/blob/main/docs/fetching-files.rst Required configuration entries for the github:// facility. The LABEL is a look-up key into Buildrunner configuration. The version field is optional. The app_token is a 40 hex digit token. ```yaml github: LABEL: endpoint: 'https://HOSTNAME/API_PATH' version: 'VERSION' // optional username: 'USERNAME' app_token: 'APP_TOKEN' ``` -------------------------------- ### Push and commit with additional tags and security scan Source: https://github.com/adobe/buildrunner/blob/main/README.rst Shows how to specify additional tags, disable the default build tag, and optionally configure a security scan for pushed images. The commit configuration does not support security scans. ```yaml steps: build-my-container: build: . # To push the docker image to a registry push: repository: myimages/image1 # Do not include default build tag add_build_tag: false tags: [ 'latest' ] # Optional security scan configuration may be provided for each configured push security-scan: # See docs/global-configuration.rst for more information on these attributes. #enabled: false #scanner: "trivy" #version: "0.69.3" # NOTE: Any configuration provided here will be merged with global/command line config #config: # optional-param: val1 # Set to a float to fail the build if the maximum score # is greater than or equal to this number #max-score-threshold: 8.9 # OR to just commit it locally to use in subsequent steps commit: repository: myimages/image1 tags: [ 'latest' ] # NOTE: Image security scans are disabled for images that are not pushed ``` -------------------------------- ### pypi-push with multiple repositories as list Source: https://github.com/adobe/buildrunner/blob/main/README.rst Defines pypi-push with multiple repositories as a list of strings or dictionary entries, similar to the push option. ```yaml steps: pypi: run: image: python:2 cmds: - python -m build artifacts: "dist/*.tar.gz": { type: 'python-sdist' } "dist/*.whl": { type: 'python-wheel' } pypi-push: - pypi-myownrepo1 - repository: https://artifactory.example.com/artifactory/api/pypi/pypi-myownrepo2 username: myuser password: mypass ``` -------------------------------- ### Multiple build contexts in one source tree (YAML) Source: https://github.com/adobe/buildrunner/blob/main/README.rst Produces multiple Docker images from a single source tree by placing different build contexts in different directories. ```yaml steps: build-container-1: build: container-1 build-container-2: build: container-2 ``` -------------------------------- ### pypi-push configuration with repository, username, and password Source: https://github.com/adobe/buildrunner/blob/main/README.rst Specifies repository, username, and password for pypi-push. All three must be specified when using this form. The skip_existing option skips uploading if the same version has already been uploaded. ```yaml steps: pypi: run: image: python:2 cmds: - python -m build artifacts: "dist/*.tar.gz": { type: 'python-sdist' } "dist/*.whl": { type: 'python-wheel' } pypi-push: repository: https://artifactory.example.com/artifactory/api/pypi/pypi-myownrepo username: myuser password: mypass # Used to skip uploading the artifact is the same version has already been uploaded skip_existing: true ``` -------------------------------- ### Build with root directory as context (YAML) Source: https://github.com/adobe/buildrunner/blob/main/README.rst Builds a Docker image using the root directory of the source tree as the build context, equivalent to running 'docker build .' in the source root. ```yaml steps: build-my-container: build: . ``` -------------------------------- ### Use configured Docker registry in a Dockerfile Source: https://github.com/adobe/buildrunner/blob/main/docs/common-issues.rst Uses an ARG DOCKER_REGISTRY build argument to reference the configured Docker registry in a Dockerfile. Assumes the image to pull is busybox:latest. ```dockerfile ARG DOCKER_REGISTRY FROM $DOCKER_REGISTRY/busybox:latest ``` -------------------------------- ### File Fetch Relative Path Source: https://github.com/adobe/buildrunner/blob/main/docs/fetching-files.rst Designates a relative path from the source directory. The file:// scheme cannot be used for relative paths. ```yaml relative/path/to/a/file.ext ``` -------------------------------- ### Redirect buildrunner.yaml Source: https://github.com/adobe/buildrunner/blob/main/docs/fetching-files.rst Single entry in buildrunner.yaml to redirect to a remote buildrunner.yaml using the fetch facility. Buildrunner repeatedly redirects until a file without a redirect directive is found; all other content is ignored when redirect is present. ```yaml redirect: 'github://gh-label/org/repo/sample-buildrunner.yaml' ``` -------------------------------- ### Pushing one image to multiple repositories with list entries Source: https://github.com/adobe/buildrunner/blob/main/README.rst Uses a list for push or commit configuration to push a single image to multiple repositories, with each entry either a string or a dictionary with additional tags. ```yaml+jinja steps: build-my-container: build: . push: - repository: myimages/image1 tags: [ 'latest' ] - myimages/image2 - repository: myimages/image3 tags: [ 'latest' ] # OR commit: - repository: myimages/image1 tags: [ 'latest' ] - myimages/image2 - repository: myimages/image3 tags: [ 'latest' ] ``` -------------------------------- ### Service container configuration options (YAML) Source: https://github.com/adobe/buildrunner/blob/main/README.rst Shows the available configuration options for service containers, which are linked to the primary build container and instantiated in order. Service containers have the same injected environment variables and volume mounts as build containers, but the /source mount is read-only. The 'build' and 'image' attributes are mutually exclusive; the image produced by a service container build cannot be pushed to a remote repository. ```yaml steps: my-build-step: run: services: my-service-container: # The 'build' attribute functions the same way that the step # 'build' attribute does. The only difference is that the image # produced by a service container build attribute cannot be pushed # to a remote repository. build: # The pre-built image to base the container on. The 'build' and # 'image' attributes are mutually exclusive in the service # container context. image: # The command to run. If ommitted Buildrunner runs the command # configured in the Docker image without modification. If provided # Buildrunner always sets the container command to a shell, running # the given command here within the shell. cmd: # A collection of provisioners to run. Provisioners work similar to # the way Packer provisioners do and are always run within a shell. # When a provisioner is specified Buildrunner always sets the # container command to a shell, running the provisioners within the # shell. Currently Buildrunner supports shell and salt # provisioners. provisioners: shell: path/to/script.sh salt: # The shell to use when specifying the cmd or provisioners # attributes. Defaults to /bin/sh. If the cmd and provisioners # attributes are not specified this setting has no effect. shell: /bin/sh # The directory to run commands within. Defaults to /source. cwd: /source # The user to run commands as. Defaults to the user specified in # the Docker image. user: # The hostname assigned to the service container. hostname: # Custom dns servers to use in the service container. dns: - 8.8.8.8 - 8.8.4.4 # A custom dns search path to use in the service container. dns_search: mydomain.com # Add entries to the hosts file # The keys are the hostnames. The values can be either # ip addresses or references to other service containers. extra_hosts: "www1.test.com": "192.168.0.1" "www2.test.com": "192.168.0.2" # A map specifying additional environment variables to be injected # into the container. Keys are the variable names and values are # variable values. env: ENV_VARIABLE_ONE: value1 ENV_VARIABLE_TWO: value2 ``` -------------------------------- ### Build with relative path context (YAML) Source: https://github.com/adobe/buildrunner/blob/main/README.rst Builds a Docker image using a relative path within the source tree as the build context, for when the Dockerfile is in another directory. ```yaml steps: build-my-container: build: my/container/build/context ``` -------------------------------- ### Build attribute map with path and inject options (YAML) Source: https://github.com/adobe/buildrunner/blob/main/README.rst Shows the map form of the 'build' attribute. The 'path' key defines the base context directory; the 'inject' map copies files outside the context into it, overriding same-name files. If 'path' is omitted, the source directory is not copied, improving performance, and all needed files must be injected. Destination directories require a trailing slash or '.' component. ```yaml steps: build-my-container: build: # Define the base context directory (same as string-only value) path: my/container/build/context # The inject map specifies other files outside the build context that # should be included in the context sent to the Docker daemon. Files # injected into the build context override files with the same name/path # contained in the path configuration above. # # NOTE: you do not need to specify a path attribute if you inject all # of the files you need, including a Dockerfile. When the path attribute # is NOT explicitly specified (either as 'path: .' or 'build: .'), the # source directory will NOT be copied into the build context. This # optimization improves build performance by avoiding unnecessary file # copying. Any files needed by the Dockerfile must be explicitly injected # when not specifying a path. # # NOTE: if the destination is a directory then it must be indicated with # an ending "/" or a "." component. inject: # Each entry in the map has a glob pattern key that resolves relative # to the source tree root with the value being the directory within # the build context that the file(s) should be copied to. These files # will be available to the Dockerfile at the given location during # the Docker build. Destination directories must have a trailing # slash (``/``). glob/to/files.*: dest/dir/ path/to/file1.txt: dest/dir/ path/to/file2.txt: . path/to/file3.txt: dest/filename.txt ``` -------------------------------- ### Use configured Docker registry in buildrunner.yaml Source: https://github.com/adobe/buildrunner/blob/main/docs/common-issues.rst References the configured Docker registry via the DOCKER_REGISTRY variable in a buildrunner.yaml step. Assumes the image to pull is busybox:latest. ```yaml+jinja steps: step1: run: image: {{ DOCKER_REGISTRY }}/busybox:latest ``` -------------------------------- ### BuildRunner YAML: Build base and dependent multi-platform images Source: https://github.com/adobe/buildrunner/blob/main/docs/common-issues.rst Defines two build steps in a BuildRunner configuration. The first builds a base image (test-image1) for linux/amd64 and linux/arm64/v8, and the second attempts to build a dependent image (test-image2) from that base. The second step will likely fail for platforms not configured to run locally via Docker buildx because the base image won't exist for those platforms. ```yaml steps: build-base: build: dockerfile: | FROM {{ DOCKER_REGISTRY }}/busybox:latest CMD /do-something-cool platforms: - linux/amd64 - linux/arm64/v8 push: test-image1 build-from-base: build: dockerfile: | FROM test-image1:{{ BUILDRUNNER_BUILD_DOCKER_TAG }} CMD /do-something-else platforms: - linux/amd64 - linux/arm64/v8 push: test-image2 ``` -------------------------------- ### BuildRunner YAML: Build multi-stage Dockerfile targets Source: https://github.com/adobe/buildrunner/blob/main/docs/common-issues.rst Defines two build steps that use the multi-stage Dockerfile above. The first builds target stage1 and pushes test-image1, the second builds target stage2 and pushes test-image2. Both steps use the same build path and platforms. ```yaml steps: build-base: build: path: . platforms: - linux/amd64 - linux/arm64/v8 target: stage1 push: test-image1 build-from-base: build: path: . platforms: - linux/amd64 - linux/arm64/v8 target: stage2 push: test-image2 ``` -------------------------------- ### Steps dependencies with depends key (YAML) Source: https://github.com/adobe/buildrunner/blob/main/README.rst Defines step dependencies using the 'depends' key, requiring configuration version 2.0 or higher. Steps run in configuration order unless dependencies are specified; the graphlib library generates a directed acyclic graph, and non-dependent steps have no guaranteed order. Circular dependencies cause an exception and halt execution. ```yaml version: 2.0 steps: step1: run: image: {{ DOCKER_REGISTRY }}/ubuntu:latest cmd: echo "Hello from step1" step2: depends: - step1 - step3 run: image: {{ DOCKER_REGISTRY }}/ubuntu:latest cmd: echo "Hello from step 2" step3: run: image: {{ DOCKER_REGISTRY }}/ubuntu:latest cmd: echo "Hello from step 3." step4: run: image: {{ DOCKER_REGISTRY }}/ubuntu:latest cmd: echo "Hello from step 4." ``` -------------------------------- ### Run buildrunner_cleanup command Source: https://github.com/adobe/buildrunner/blob/main/README.rst Stand-alone command that cleans up the cache. Takes no parameters. ```bash buildrunner_cleanup ``` -------------------------------- ### Service container configuration options Source: https://github.com/adobe/buildrunner/blob/main/README.rst YAML configuration for a service container in a buildrunner step, including file injection, volumes, ports, pull behavior, systemd, cleanup containers, port waiting, and SSH agent injection. The 'files' map uses aliases from the global 'local-files' config or relative build directory paths; 'volumes_from' requires referenced containers to be defined earlier; 'wait_for' times out after 10 minutes or a configured timeout; 'inject-ssh-agent' defaults to false. ```yaml # Optional buildrunner configuration syntax version # A map specifying files that should be injected into the container. # The map key is the alias referencing a given file (as configured in # the "local-files" section of the global configuration file) or a # relative path to a file/directory in the build directory. The value # is the path the given file should be mounted at within the container. files: namespaced.file.alias1: "/path/to/readonly/file/or/dir" namespaced.file.alias2: "/path/to/readwrite/file/or/dir:rw" build/dir/file: "/path/to/build/dir/file" # A list specifying other service containers whose exposed volumes # should be mapped into this service container's file system. Any # service containers in this list must be defined before this # container is. # An exposed volume is one created by the volume Dockerfile command. # See https://docs.docker.com/engine/reference/builder/#volume for more # details regarding the volume Dockerfile command. volumes_from: - my-service-container # A map specifying ports to expose and link within other containers # within the step. ports: : # Whether or not to pull the image from upstream prior to running # the step. This is almost always desirable, as it ensures the # most up to date source image. There are situations, however, when # this can be set to false as an optimization. For example, if a # container is built at the beginning of a buildrunner file and then # used repeatedly. In this case, it is clear that the cached version # is appropriate and we don't need to check upstream for changes. pull: true/false (defaults to true) # See above systemd: true/false # A list of container names or labels created within any run container # that buildrunner should clean up. (Use if you call # 'docker run --name ' or 'docker run --label