-
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 10dc398
Showing
9 changed files
with
176 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. | ||
# |
90 changes: 90 additions & 0 deletions
90
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,90 @@ | ||
# | ||
# 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 | ||
|
||
|
||
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/master/airbyte-integrations/bases/base/base.sh" | ||
JAVA_BASE_SCRIPT_URL: Final[ | ||
str | ||
] = "https://raw.githubusercontent.com/airbytehq/airbyte/master/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) | ||
.with_exec(["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. | ||
.with_exec(["yum", "install", "-y", "tar", "openssl", "findutils"]) | ||
.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
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
12 changes: 12 additions & 0 deletions
12
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,12 @@ | ||
[ | ||
{ | ||
"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" | ||
|