From 6cd50993b7dca9511367790ae6bb2e6c4f3bdede Mon Sep 17 00:00:00 2001 From: zaitrarrio Date: Sat, 29 Jul 2023 00:32:01 -0500 Subject: [PATCH 1/3] feat: add Docker compose example --- .gitignore | 3 +++ docker-compose.yml | 42 +++++++++++++++++++++++++++++++++++++++++ example/.bazelrc | 5 +++++ example/Dockerfile | 20 ++++++++++++++++++++ example/entrypoint.sh | 11 +++++++++++ registry/auth/.htpasswd | 2 ++ worker/Dockerfile | 3 +++ 7 files changed, 86 insertions(+) create mode 100644 .gitignore create mode 100644 docker-compose.yml create mode 100644 example/.bazelrc create mode 100644 example/Dockerfile create mode 100644 example/entrypoint.sh create mode 100644 registry/auth/.htpasswd create mode 100644 worker/Dockerfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d32f52 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + +# IDE files +.idea/ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5bd927d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,42 @@ +version: "3" +services: + + engflow: + image: ghcr.io/engflow/free:2.8.0 + container_name: engflow + environment: + - DATA_DIR=/tmp/engflow_data + ports: + - "8080:8080" + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + - "/tmp/engflow_data:/tmp/engflow_data" + + registry: + network_mode: host + image: registry:2 + environment: + REGISTRY_HTTP_ADDR: 0.0.0.0:5443 + REGISTRY_AUTH: htpasswd + REGISTRY_AUTH_HTPASSWD_REALM: Registry + REGISTRY_AUTH_HTPASSWD_PATH: /auth/.htpasswd + volumes: + - ./registry/certs:/certs + - ./registry/auth:/auth + + example: + network_mode: host + build: + context: . + dockerfile: ./example/Dockerfile + + depends_on: + - registry + - engflow + volumes: + - ./example/etc/docker/certs.d:/etc/docker/certs.d + - ./registry/certs:/certs + - /var/run/docker.sock:/var/run/docker.sock + +networks: + engflow: {} \ No newline at end of file diff --git a/example/.bazelrc b/example/.bazelrc new file mode 100644 index 0000000..4d645e7 --- /dev/null +++ b/example/.bazelrc @@ -0,0 +1,5 @@ +build:engflow --remote_executor=grpc://localhost:8080 +build:engflow --remote_cache=grpc://localhost:8080 +build:engflow --bes_backend=grpc://localhost:8080 +build:engflow --bes_results_url=http://localhost:8080/invocation/ +build:engflow --remote_default_exec_properties=container-image=localhost:5443/engflow/worker diff --git a/example/Dockerfile b/example/Dockerfile new file mode 100644 index 0000000..d4bbf1b --- /dev/null +++ b/example/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:latest + +WORKDIR /home/engflow + +RUN <<-EOF + apt-get update + apt-get install -y build-essential python3 default-jdk git curl node.js npm + curl -sSL https://get.docker.com/ | sh +EOF + +RUN npm install -g @bazel/bazelisk + +RUN git clone https://github.com/EngFlow/example.git + +COPY ./example/.bazelrc ./example/engflow.bazelrc +COPY ./example/entrypoint.sh ./example/entrypoint.sh +COPY ./worker/Dockerfile ./worker/Dockerfile + +ENTRYPOINT chmod +x ./example/entrypoint.sh && ./example/entrypoint.sh + diff --git a/example/entrypoint.sh b/example/entrypoint.sh new file mode 100644 index 0000000..084ab50 --- /dev/null +++ b/example/entrypoint.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +sleep 5 +docker login -u=engflow -p=engflow localhost:5443 +docker build ./worker -t localhost:5443/engflow/worker:latest +docker push localhost:5443/engflow/worker + +# echo curl -v -u engflow:engflow https://host.docker.internal:5043/v2/ + +pushd /home/engflow/example || exit 1 +bazel --bazelrc=engflow.bazelrc build //cpp/... --config=engflow \ No newline at end of file diff --git a/registry/auth/.htpasswd b/registry/auth/.htpasswd new file mode 100644 index 0000000..a91710f --- /dev/null +++ b/registry/auth/.htpasswd @@ -0,0 +1,2 @@ +engflow:$2y$05$LeRPdCm7WTNdRdWG/xd22Oli2kN.bfTyufEwEyhh1A/LFrx0d.oFe + diff --git a/worker/Dockerfile b/worker/Dockerfile new file mode 100644 index 0000000..4b4ed6e --- /dev/null +++ b/worker/Dockerfile @@ -0,0 +1,3 @@ +FROM ubuntu:latest + +RUN apt-get update && apt-get install -y build-essential python3 default-jdk From 1c54815d7c9f055aa8b3fabe48600b431bf760df Mon Sep 17 00:00:00 2001 From: zaitrarrio Date: Sat, 29 Jul 2023 00:53:27 -0500 Subject: [PATCH 2/3] docs: add brief note about running through Docker Compose --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ca5dae..35ce0dd 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ protocol clients such as [Bazel](https://bazel.build). EngFlow Free Tier may be used a remote cache and UI for any Bazel build. It can also execute remote actions in a Linux Docker container. -## Getting started +## Getting Started EngFlow Free Tier is distributed as a Docker image for x86_64 Linux. The images are hosted by the [GitHub container @@ -43,6 +43,23 @@ flag. For instance, `--remote_default_exec_properties=container-image=docker://docker.io/ubuntu:focal-20210827` to run remote actions in a recent Ubuntu container. +## Getting Started w/ Docker Compose + +EngFlow Free Tier may be started as a service through Docker Compose. A sample configuration of EngFlow +deployed as a service is demonstrated in the ```docker-compose.yml``` file included in this repository. +The example demonstrates the configuration of the EngFlow remote execution service to use containers for +both local execution and remote runtime workers. + +To start the EngFlow Free Tier and run build targets from the EngFlow example project, simply execute the +following command from the top-level directory of this repository: + +```commandline +docker-compose up +``` + +EngFlow Free Tier can be deployed easily to various cloud providers through Docker Compose or directly as a container +through Kubernetes, Amazon ECS, Azure Container Apps, Google Cloud Run and any other OCI-compatible container platform. + ## Configuration EngFlow stores its caches and logs in the location pointed to by the `$DATA_DIR` From 8ee81b8be78eb46d66f884b5a21079b43e2f121e Mon Sep 17 00:00:00 2001 From: zaitrarrio Date: Sun, 30 Jul 2023 23:34:24 -0500 Subject: [PATCH 3/3] chore: add clean to ensure remote execution for testing and validation --- example/entrypoint.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/example/entrypoint.sh b/example/entrypoint.sh index 084ab50..5980b4a 100644 --- a/example/entrypoint.sh +++ b/example/entrypoint.sh @@ -5,7 +5,6 @@ docker login -u=engflow -p=engflow localhost:5443 docker build ./worker -t localhost:5443/engflow/worker:latest docker push localhost:5443/engflow/worker -# echo curl -v -u engflow:engflow https://host.docker.internal:5043/v2/ - pushd /home/engflow/example || exit 1 +bazel clean bazel --bazelrc=engflow.bazelrc build //cpp/... --config=engflow \ No newline at end of file