From 3787d2634a905e7676bdef074ea74029abd08e46 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Thu, 4 Jan 2024 12:34:17 -0600 Subject: [PATCH] hack: add docker-compose file for development This adds a simple docker compose file for development. The development version of buildkit will build with the dockerfile, set debug to true, use a tcp address to be compatible with the remote driver, and enable the debug image through delve to allow for remote debugging. It also configures additional services for help with development. At the moment, this only includes jaeger for collecting traces but can also include additional services in the future for things like metrics collection. Signed-off-by: Jonathan A. Sternberg --- hack/compose | 40 ++++++++++++++++++++++++++++++++ hack/composefiles/.gitignore | 8 +++++++ hack/composefiles/buildkitd.toml | 5 ++++ hack/composefiles/compose.yaml | 35 ++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100755 hack/compose create mode 100644 hack/composefiles/.gitignore create mode 100644 hack/composefiles/buildkitd.toml create mode 100644 hack/composefiles/compose.yaml diff --git a/hack/compose b/hack/compose new file mode 100755 index 000000000000..a65c2c2dddc1 --- /dev/null +++ b/hack/compose @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Use to set up a dev environment for buildkit. +# Not meant for production deployments. +# Use the same way you would use docker compose. +# +# $ hack/compose up -d --build +# +# Can be extended for local development by adding +# a compose.override.yaml file to the same directory. +# +# Additional config files for extra services can +# also be placed in the same folder and they will +# be automatically ignored by git. +# +# To access the newly created development buildkit, +# use either: +# +# $ buildctl --addr tcp://127.0.0.1:1234 ... +# +# or alternatively configure a new builder with buildx. +# +# $ docker buildx create \ +# --bootstrap \ +# --name dev \ +# --driver remote \ +# tcp://127.0.0.1:1234 +# $ docker buildx --builder dev ... + +. $(dirname $0)/util +set -eu -o pipefail + +filesDir=$(dirname $0)/composefiles + +args=(compose '-f' "$filesDir/compose.yaml") +if [ -f "$filesDir/compose.override.yaml" ]; then + args+=('-f' "$filesDir/compose.override.yaml") +fi + +dockerCmd "${args[@]}" "$@" diff --git a/hack/composefiles/.gitignore b/hack/composefiles/.gitignore new file mode 100644 index 000000000000..ff805297024f --- /dev/null +++ b/hack/composefiles/.gitignore @@ -0,0 +1,8 @@ +# Exclude everything to allow this folder to be used for other service +# configurations. +* + +# Specifically allow certain configuration files. +!.gitignore +!buildkitd.toml +!compose.yaml diff --git a/hack/composefiles/buildkitd.toml b/hack/composefiles/buildkitd.toml new file mode 100644 index 000000000000..f32cc92ce194 --- /dev/null +++ b/hack/composefiles/buildkitd.toml @@ -0,0 +1,5 @@ +debug = true + +[grpc] + address = [ "tcp://0.0.0.0:1234" ] + debugAddress = "0.0.0.0:6060" diff --git a/hack/composefiles/compose.yaml b/hack/composefiles/compose.yaml new file mode 100644 index 000000000000..59686d03b44f --- /dev/null +++ b/hack/composefiles/compose.yaml @@ -0,0 +1,35 @@ +name: buildkit +services: + buildkit: + container_name: buildkit-dev + build: + context: ../.. + args: + BUILDKIT_DEBUG: 1 + image: moby/buildkit:local + ports: + - 127.0.0.1:1234:1234 + - 127.0.0.1:5000:5000 + - 127.0.0.1:6060:6060 + restart: always + privileged: true + environment: + DELVE_PORT: 5000 + OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: http://jaeger:4317 + configs: + - source: buildkit_config + target: /etc/buildkit/buildkitd.toml + volumes: + - buildkit:/var/lib/buildkit + + jaeger: + image: jaegertracing/all-in-one:latest + ports: + - 127.0.0.1:16686:16686 + +volumes: + buildkit: + +configs: + buildkit_config: + file: ./buildkitd.toml