-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
base-images: declare a base image for our java connectors
- Loading branch information
1 parent
24f95a9
commit 6bd024b
Showing
10 changed files
with
200 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
3 changes: 3 additions & 0 deletions
3
airbyte-ci/connectors/base_images/base_images/java/__init__.py
This file contains 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,3 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# |
102 changes: 102 additions & 0 deletions
102
airbyte-ci/connectors/base_images/base_images/java/bases.py
This file contains 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,102 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
from __future__ import annotations | ||
|
||
from typing import Callable, Final | ||
|
||
import dagger | ||
from base_images import bases, published_image | ||
from base_images import sanity_checks as base_sanity_checks | ||
from base_images.python import sanity_checks as python_sanity_checks | ||
from base_images.root_images import AMAZON_CORRETTO_21_AL_2023 | ||
from base_images.utils.dagger import sh_dash_c | ||
|
||
|
||
class AirbyteJavaConnectorBaseImage(bases.AirbyteConnectorBaseImage): | ||
# TODO: remove this once we want to build the base image with the airbyte user. | ||
USER: Final[str] = "root" | ||
|
||
root_image: Final[published_image.PublishedImage] = AMAZON_CORRETTO_21_AL_2023 | ||
repository: Final[str] = "airbyte/java-connector-base" | ||
|
||
DD_AGENT_JAR_URL: Final[str] = "https://dtdg.co/latest-java-tracer" | ||
BASE_SCRIPT_URL = "https://raw.githubusercontent.com/airbytehq/airbyte/6d8a3a2bc4f4ca79f10164447a90fdce5c9ad6f9/airbyte-integrations/bases/base/base.sh" | ||
JAVA_BASE_SCRIPT_URL: Final[ | ||
str | ||
] = "https://raw.githubusercontent.com/airbytehq/airbyte/6d8a3a2bc4f4ca79f10164447a90fdce5c9ad6f9/airbyte-integrations/bases/base-java/javabase.sh" | ||
|
||
def get_container(self, platform: dagger.Platform) -> dagger.Container: | ||
"""Returns the container used to build the base image for java connectors | ||
We currently use the Amazon coretto image as a base. | ||
We install some packages required to build java connectors. | ||
We also download the datadog java agent jar and the javabase.sh script. | ||
We set some env variables used by the javabase.sh script. | ||
Args: | ||
platform (dagger.Platform): The platform this container should be built for. | ||
Returns: | ||
dagger.Container: The container used to build the base image. | ||
""" | ||
|
||
return ( | ||
# TODO: Call this when we want to build the base image with the airbyte user | ||
# self.get_base_container(platform) | ||
self.dagger_client.container(platform=platform) | ||
.from_(self.root_image.address) | ||
# Bundle RUN commands together to reduce the number of layers. | ||
.with_exec( | ||
sh_dash_c( | ||
[ | ||
# Update first, but in the same .with_exec step as the package installation. | ||
# Otherwise, we risk caching stale package URLs. | ||
"yum update -y --security", | ||
# tar is equired to untar java connector binary distributions. | ||
# openssl is required because we need to ssh and scp sometimes. | ||
# findutils is required for xargs, which is shipped as part of findutils. | ||
f"yum install -y tar openssl findutils", | ||
# Remove any dangly bits. | ||
"yum clean all", | ||
] | ||
) | ||
) | ||
.with_workdir("/airbyte") | ||
# Copy the datadog java agent jar from the internet. | ||
.with_file("dd-java-agent.jar", self.dagger_client.http(self.DD_AGENT_JAR_URL)) | ||
# Copy base.sh from the git repo. | ||
.with_file("base.sh", self.dagger_client.http(self.BASE_SCRIPT_URL)) | ||
# Copy javabase.sh from the git repo. | ||
.with_file("javabase.sh", self.dagger_client.http(self.JAVA_BASE_SCRIPT_URL)) | ||
# Set a bunch of env variables used by base.sh. | ||
.with_env_variable("AIRBYTE_SPEC_CMD", "/airbyte/javabase.sh --spec") | ||
.with_env_variable("AIRBYTE_CHECK_CMD", "/airbyte/javabase.sh --check") | ||
.with_env_variable("AIRBYTE_DISCOVER_CMD", "/airbyte/javabase.sh --discover") | ||
.with_env_variable("AIRBYTE_READ_CMD", "/airbyte/javabase.sh --read") | ||
.with_env_variable("AIRBYTE_WRITE_CMD", "/airbyte/javabase.sh --write") | ||
.with_env_variable("AIRBYTE_ENTRYPOINT", "/airbyte/base.sh") | ||
.with_entrypoint(["/airbyte/base.sh"]) | ||
) | ||
|
||
async def run_sanity_checks(self, platform: dagger.Platform): | ||
"""Runs sanity checks on the base image container. | ||
This method is called before image publication. | ||
Consider it like a pre-flight check before take-off to the remote registry. | ||
Args: | ||
platform (dagger.Platform): The platform on which the sanity checks should run. | ||
""" | ||
container = self.get_container(platform) | ||
await base_sanity_checks.check_user_can_read_dir(container, self.USER, self.AIRBYTE_DIR_PATH) | ||
await base_sanity_checks.check_user_can_write_dir(container, self.USER, self.AIRBYTE_DIR_PATH) | ||
await base_sanity_checks.check_file_exists(container, "/airbyte/dd-java-agent.jar") | ||
await base_sanity_checks.check_file_exists(container, "/airbyte/base.sh") | ||
await base_sanity_checks.check_file_exists(container, "/airbyte/javabase.sh") | ||
await base_sanity_checks.check_env_var_with_printenv(container, "AIRBYTE_SPEC_CMD", "/airbyte/javabase.sh --spec") | ||
await base_sanity_checks.check_env_var_with_printenv(container, "AIRBYTE_CHECK_CMD", "/airbyte/javabase.sh --check") | ||
await base_sanity_checks.check_env_var_with_printenv(container, "AIRBYTE_DISCOVER_CMD", "/airbyte/javabase.sh --discover") | ||
await base_sanity_checks.check_env_var_with_printenv(container, "AIRBYTE_READ_CMD", "/airbyte/javabase.sh --read") | ||
await base_sanity_checks.check_env_var_with_printenv(container, "AIRBYTE_WRITE_CMD", "/airbyte/javabase.sh --write") | ||
await base_sanity_checks.check_env_var_with_printenv(container, "AIRBYTE_ENTRYPOINT", "/airbyte/base.sh") | ||
await base_sanity_checks.check_a_command_is_available_using_version_option(container, "tar") | ||
await base_sanity_checks.check_a_command_is_available_using_version_option(container, "openssl", "version") |
This file contains 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 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 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
6 changes: 6 additions & 0 deletions
6
airbyte-ci/connectors/base_images/base_images/utils/dagger.py
This file contains 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,6 @@ | ||
# Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
|
||
|
||
def sh_dash_c(lines: list[str]) -> list[str]: | ||
"""Wrap sequence of commands in shell for safe usage of dagger Container's with_exec method.""" | ||
return ["sh", "-c", " && ".join(["set -o xtrace"] + lines)] |
This file contains 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
17 changes: 17 additions & 0 deletions
17
airbyte-ci/connectors/base_images/generated/changelogs/airbyte_java_connector_base.json
This file contains 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,17 @@ | ||
[ | ||
{ | ||
"version": "1.0.0-rc.4", | ||
"changelog_entry": "Bundle yum calls in a single RUN", | ||
"dockerfile_example": "FROM docker.io/amazoncorretto:21-al2023@sha256:5454cb606e803fce56861fdbc9eab365eaa2ab4f357ceb8c1d56f4f8c8a7bc33\nRUN sh -c set -o xtrace && yum update -y --security && yum install -y tar openssl findutils && yum clean all\nENV AIRBYTE_SPEC_CMD=/airbyte/javabase.sh --spec\nENV AIRBYTE_CHECK_CMD=/airbyte/javabase.sh --check\nENV AIRBYTE_DISCOVER_CMD=/airbyte/javabase.sh --discover\nENV AIRBYTE_READ_CMD=/airbyte/javabase.sh --read\nENV AIRBYTE_WRITE_CMD=/airbyte/javabase.sh --write\nENV AIRBYTE_ENTRYPOINT=/airbyte/base.sh" | ||
}, | ||
{ | ||
"version": "1.0.0-rc.2", | ||
"changelog_entry": "Set entrypoint to base.sh", | ||
"dockerfile_example": "FROM docker.io/amazoncorretto:21-al2023@sha256:5454cb606e803fce56861fdbc9eab365eaa2ab4f357ceb8c1d56f4f8c8a7bc33\nRUN yum update -y --security\nRUN yum install -y tar openssl findutils\nENV AIRBYTE_SPEC_CMD=/airbyte/javabase.sh --spec\nENV AIRBYTE_CHECK_CMD=/airbyte/javabase.sh --check\nENV AIRBYTE_DISCOVER_CMD=/airbyte/javabase.sh --discover\nENV AIRBYTE_READ_CMD=/airbyte/javabase.sh --read\nENV AIRBYTE_WRITE_CMD=/airbyte/javabase.sh --write\nENV AIRBYTE_ENTRYPOINT=/airbyte/base.sh" | ||
}, | ||
{ | ||
"version": "1.0.0-rc.1", | ||
"changelog_entry": "Create a base image for our java connectors.", | ||
"dockerfile_example": "FROM docker.io/amazoncorretto:21-al2023@sha256:5454cb606e803fce56861fdbc9eab365eaa2ab4f357ceb8c1d56f4f8c8a7bc33\nRUN yum update -y --security\nRUN yum install -y tar openssl findutils\nENV AIRBYTE_SPEC_CMD=/airbyte/javabase.sh --spec\nENV AIRBYTE_CHECK_CMD=/airbyte/javabase.sh --check\nENV AIRBYTE_DISCOVER_CMD=/airbyte/javabase.sh --discover\nENV AIRBYTE_READ_CMD=/airbyte/javabase.sh --read\nENV AIRBYTE_WRITE_CMD=/airbyte/javabase.sh --write\nENV AIRBYTE_ENTRYPOINT=/airbyte/base.sh" | ||
} | ||
] |
This file contains 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "airbyte-connectors-base-images" | ||
version = "1.3.1" | ||
version = "1.4.0" | ||
description = "This package is used to generate and publish the base images for Airbyte Connectors." | ||
authors = ["Augustin Lafanechere <[email protected]>"] | ||
readme = "README.md" | ||
|