Skip to content

Commit

Permalink
set airbyte user on java connectors build
Browse files Browse the repository at this point in the history
  • Loading branch information
alafanechere committed Mar 28, 2024
1 parent f67c6e0 commit b4b3a6e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/actions/run-airbyte-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ inputs:
airbyte_ci_binary_url:
description: "URL to airbyte-ci binary"
required: false
default: https://connectors.airbyte.com/airbyte-ci/releases/ubuntu/latest/airbyte-ci
#TODO: revert before merging
default: https://storage.googleapis.com/dev-airbyte-cloud-connector-metadata-service/airbyte-ci/releases/ubuntu/51c9dc8/airbyte-ci
python_registry_token:
description: "Python registry API token to publish python package"
required: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from typing import Any

from base_images.bases import AirbyteConnectorBaseImage
from base_images.bases import AirbyteConnectorBaseImage # type: ignore
from dagger import Container, Platform
from pipelines.airbyte_ci.connectors.build_image.steps import build_customization
from pipelines.airbyte_ci.connectors.build_image.steps.common import BuildConnectorImagesBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import TYPE_CHECKING

from anyio import Path
from base_images.bases import AirbyteConnectorBaseImage
from dagger import Secret
from pipelines.helpers.utils import get_file_contents, get_secret_host_variable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ def with_integration_base(context: PipelineContext, build_platform: Platform) ->


def with_integration_base_java(context: PipelineContext, build_platform: Platform) -> Container:
user, user_id, group_id = "airbyte", 1000, 1000

integration_base = with_integration_base(context, build_platform)
yum_packages_to_install = [
"tar", # required to untar java connector binary distributions.
"openssl", # required because we need to ssh and scp sometimes.
"findutils", # required for xargs, which is shipped as part of findutils.
"/usr/sbin/adduser", # required to create a user.
]
return (
context.dagger_client.container(platform=build_platform)
Expand All @@ -47,9 +50,13 @@ def with_integration_base_java(context: PipelineContext, build_platform: Platfor
]
)
)
.with_exec(
["adduser", "--uid", str(user_id), "--gid", str(group_id), "--system", "--user-group", "--no-create-home", user],
skip_entrypoint=True,
)
# Add what files we need to the /airbyte directory.
# Copy base.sh from the airbyte/integration-base image.
.with_directory("/airbyte", integration_base.directory("/airbyte"))
.with_directory("/airbyte", integration_base.directory("/airbyte"), owner=user)
.with_workdir("/airbyte")
# Download a utility jar from the internet.
.with_file("dd-java-agent.jar", context.dagger_client.http("https://dtdg.co/latest-java-tracer"))
Expand Down Expand Up @@ -137,7 +144,7 @@ def with_integration_base_java_and_normalization(context: ConnectorContext, buil

async def with_airbyte_java_connector(context: ConnectorContext, connector_java_tar_file: File, build_platform: Platform) -> Container:
application = context.connector.technical_name

user = "airbyte"
build_stage = (
with_integration_base_java(context, build_platform)
.with_workdir("/airbyte")
Expand All @@ -146,6 +153,7 @@ async def with_airbyte_java_connector(context: ConnectorContext, connector_java_
.with_exec(
sh_dash_c(
[
"chown -R airbyte:airbyte .",
f"tar xf {application}.tar --strip-components=1",
f"rm -rf {application}.tar",
]
Expand All @@ -172,4 +180,10 @@ async def with_airbyte_java_connector(context: ConnectorContext, connector_java_
.with_label("io.airbyte.name", context.metadata["dockerRepository"])
.with_entrypoint(entrypoint)
)
return await finalize_build(context, connector_container)
connector_container = await finalize_build(context, connector_container)
connector_container = (
connector_container.with_exec(["chown", "-R", user, "/airbyte"], skip_entrypoint=True)
.with_exec(["chmod", "777", "/tmp"], skip_entrypoint=True)
.with_user(user)
)
return connector_container

0 comments on commit b4b3a6e

Please sign in to comment.