generated from y-scope/public-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 6
feat(docker-images): Extrapolate image build flow from benchmark runs; Move configuration files into project sources. #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Bill-hbrhbr
wants to merge
32
commits into
y-scope:main
Choose a base branch
from
Bill-hbrhbr:task-manage-docker-images
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
dda5e24
relocate docker files
Bill-hbrhbr ac9e110
Task version of managing docker images
Bill-hbrhbr be23651
yaml lint fix
Bill-hbrhbr 49f6e5b
restructure
Bill-hbrhbr fc148bc
lint fix and others
Bill-hbrhbr 7fa26c0
Variable refactoring
Bill-hbrhbr e9faabe
Update README
Bill-hbrhbr a28735d
address review comment
Bill-hbrhbr 52064cf
Apply suggestions from code review
Bill-hbrhbr 629264e
Split docker build into two scripts. External for arg checking and pr…
Bill-hbrhbr bd218fb
third person tense
Bill-hbrhbr e1405af
Address 2nd-pass review comments
Bill-hbrhbr 0196c8e
Address review comments
Bill-hbrhbr d86c14a
Move helper funciton
Bill-hbrhbr a976ae3
Leverage docker buildx build
Bill-hbrhbr 119e62d
Revert "Leverage docker buildx build"
Bill-hbrhbr c0aa216
Fix docker inspect checksum system
Bill-hbrhbr 7080d4a
Trim last tag time from image digest for convinience of up-to-date im…
Bill-hbrhbr 553a971
address coderabbitai comments
Bill-hbrhbr 4a7c224
Various bug fixes. Directly checksum the output json instead of putti…
Bill-hbrhbr f23386e
Use a more general sources section
Bill-hbrhbr 008b8cc
Add task docstrings
Bill-hbrhbr 803daa7
Replace --trim with --id-only
Bill-hbrhbr 384982c
Move dockerfiles back to their folders
Bill-hbrhbr e037c10
Move docker image includes to respective folders as well
Bill-hbrhbr ed18773
Rename dockerfiles to plain dockerfile names
Bill-hbrhbr 5d805f6
remove checksum mechanism and rename engine to service
Bill-hbrhbr a72a9f1
Update Readme
Bill-hbrhbr 5e4dab0
Fix docstring return/raise
Bill-hbrhbr 9a3ddf3
Add docstrings for docker image tasks and minor renamings
Bill-hbrhbr f324788
Polisth readme
Bill-hbrhbr f0e5170
Update src/log_archival_bench/scripts/docker_images/__init__.py
Bill-hbrhbr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ dev = [ | |
| ] | ||
|
|
||
| [tool.mypy] | ||
| explicit_package_bases = true | ||
| mypy_path = ["src"] | ||
|
Comment on lines
+27
to
+28
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are needed for mypy linting to work in its current form. |
||
| strict = true | ||
|
|
||
| # Additional output | ||
|
|
||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Scripts for docker-container-related tasks.""" | ||
Bill-hbrhbr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/usr/bin/env python3 | ||
| """Build a Docker image and optionally dump its configuration as JSON.""" | ||
Bill-hbrhbr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| import argparse | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| from log_archival_bench.scripts.docker_images.utils import get_image_name | ||
| from log_archival_bench.utils.path_utils import ( | ||
| get_config_dir, | ||
| get_package_root, | ||
| which, | ||
| ) | ||
|
|
||
|
|
||
| def main(argv: list[str]) -> int: | ||
| """ | ||
| Build a Docker image and optionally dump its configuration as JSON. | ||
Bill-hbrhbr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| :param argv: | ||
| :return: 0 on success, non-zero error code on failure. | ||
| """ | ||
| args_parser = argparse.ArgumentParser() | ||
| args_parser.add_argument( | ||
| "--engine-name", required=True, help="The engine to be installed inside the Docker image." | ||
| ) | ||
| args_parser.add_argument( | ||
| "--dump-config-path", help="Path to the file to dump the Docker image JSON metadata." | ||
| ) | ||
|
|
||
| parsed_args = args_parser.parse_args(argv[1:]) | ||
| engine_name = parsed_args.engine_name | ||
| dump_config_path = parsed_args.dump_config_path | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| image_name = get_image_name(engine_name) | ||
|
|
||
| docker_file_path = get_config_dir() / "docker-images" / engine_name / "Dockerfile" | ||
| if not docker_file_path.is_file(): | ||
| err_msg = f"Dockerfile for `{engine_name}` does not exist." | ||
| raise RuntimeError(err_msg) | ||
|
|
||
| docker_bin = which("docker") | ||
| # fmt: off | ||
| build_cmds = [ | ||
| docker_bin, | ||
| "build", | ||
| "--tag", image_name, | ||
| str(get_package_root()), | ||
| "--file", str(docker_file_path), | ||
| ] | ||
| # fmt: on | ||
| subprocess.run(build_cmds, check=True) | ||
|
|
||
| if dump_config_path is not None: | ||
| output_path = Path(dump_config_path) | ||
| output_path.parent.mkdir(parents=True, exist_ok=True) | ||
| with output_path.open("w", encoding="utf-8") as f: | ||
| dump_cmds = [ | ||
| docker_bin, | ||
| "inspect", | ||
| "--type=image", | ||
| image_name, | ||
| ] | ||
| subprocess.run(dump_cmds, check=True, stdout=f) | ||
|
|
||
| return 0 | ||
|
|
||
|
|
||
| if "__main__" == __name__: | ||
| sys.exit(main(sys.argv)) | ||
Bill-hbrhbr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| """Shared helpers for Docker image scripts.""" | ||
|
|
||
| import os | ||
|
|
||
|
|
||
| def get_image_name(engine_name: str) -> str: | ||
| """ | ||
| :param engine_name: The service engine inside the Docker image. | ||
| :return: The Docker image name. | ||
| """ | ||
| user = os.getenv("USER", "clp-user") | ||
| return f"log-archival-bench-{engine_name}-ubuntu-jammy:dev-{user}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Scripts providing general python utilities for the project.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| """Helpers for gettings paths and determining package layouts.""" | ||
Bill-hbrhbr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| import shutil | ||
| from pathlib import Path | ||
|
|
||
| import log_archival_bench | ||
|
|
||
| _PACKAGE_ROOT = Path(log_archival_bench.__file__).parent | ||
|
|
||
| _BUILD_DIR = _PACKAGE_ROOT / "build" | ||
| _CONFIG_DIR = _PACKAGE_ROOT / "config" | ||
|
|
||
|
|
||
| def get_package_root() -> Path: | ||
| """:return: The path to the project root.""" | ||
| return _PACKAGE_ROOT | ||
|
|
||
|
|
||
| def get_build_dir() -> Path: | ||
| """:return: The path to the build output directory.""" | ||
| return _BUILD_DIR | ||
|
|
||
|
|
||
| def get_config_dir() -> Path: | ||
| """:return: The path to the project config directory.""" | ||
| return _CONFIG_DIR | ||
|
|
||
|
|
||
Bill-hbrhbr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def which(binary_name: str) -> str: | ||
| """ | ||
| Locate the full path of an executable. | ||
Bill-hbrhbr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| :param binary_name: Name of the binary to search for. | ||
| :return: Full path to the executable as a string. | ||
| :raises RuntimeError: If the binary is not found in PATH. | ||
| """ | ||
| bin_path = shutil.which(binary_name) | ||
| if bin_path is None: | ||
| err_msg = f"Executable for {binary_name} is not found." | ||
| raise RuntimeError(err_msg) | ||
| return bin_path | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| version: "3" | ||
|
|
||
| includes: | ||
| utils: | ||
| internal: true | ||
| taskfile: "../../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml" | ||
|
|
||
| vars: | ||
| G_DOCKER_IMAGE_CHECKSUMS_DIR: "{{.G_OUTPUT_DIR}}/docker-images/checksums" | ||
| G_DOCKER_IMAGE_SCRIPT_DIR: "{{.G_PROJECT_SRC_DIR}}/scripts/docker_images" | ||
|
|
||
| G_DOCKER_IMAGE_ENGINES: | ||
| - "clickhouse" | ||
| - "clp" | ||
| - "elasticsearch" | ||
| #- "presto_clp" | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #- "presto_parquet" | ||
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - "sparksql" | ||
| - "zstandard" | ||
|
|
||
| tasks: | ||
| build: | ||
| deps: | ||
| - task: ":init" | ||
| - task: "init" | ||
| cmds: | ||
| - task: "build-all-parallel" | ||
|
|
||
| init: | ||
| internal: true | ||
| silent: true | ||
| run: "once" | ||
| cmds: | ||
| - "mkdir -p '{{.G_DOCKER_IMAGE_CHECKSUMS_DIR}}'" | ||
|
|
||
| build-all-parallel: | ||
| internal: true | ||
| run: "once" | ||
| deps: | ||
| - for: | ||
| var: "G_DOCKER_IMAGE_ENGINES" | ||
| task: "build-single-image" | ||
| vars: | ||
| ENGINE_NAME: "{{.ITEM}}" | ||
|
|
||
| build-single-image: | ||
| internal: true | ||
| label: "{{.TASK}}:{{.ENGINE_NAME}}" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.G_DOCKER_IMAGE_CHECKSUMS_DIR}}/{{.ENGINE_NAME}}.md5" | ||
| OUTPUT_DIR: "{{.G_DOCKER_IMAGE_CHECKSUMS_DIR}}/{{.ENGINE_NAME}}" | ||
| requires: | ||
| vars: ["ENGINE_NAME"] | ||
| sources: | ||
| - "{{.TASKFILE}}" | ||
| - "{{.G_PROJECT_SRC_DIR}}/config/docker-images/{{.ENGINE_NAME}}/Dockerfile" | ||
| - "{{.G_PROJECT_SRC_DIR}}/scripts/docker_images/build.py" | ||
| - "{{.G_PROJECT_SRC_DIR}}/scripts/docker_images/utils.py" | ||
hoophalab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - task: "utils:checksum:validate" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"] | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cmds: | ||
| - |- | ||
| mkdir -p {{.OUTPUT_DIR}} | ||
| uv run {{.G_DOCKER_IMAGE_SCRIPT_DIR}}/build.py \ | ||
| --engine-name {{.ENGINE_NAME}} \ | ||
| --dump-config-path "{{.OUTPUT_DIR}}/docker_inspect.json" | ||
|
|
||
| # This command must be last | ||
| - task: "utils:checksum:compute" | ||
| vars: | ||
| CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" | ||
| INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.