Skip to content

Commit 5de8b7d

Browse files
committed
refactor gradle step
1 parent 8e23162 commit 5de8b7d

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

airbyte_cdk/utils/docker.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,6 @@ def _build_image(
6363
6464
Raises: ConnectorImageBuildError if the build fails.
6565
"""
66-
connector_name = metadata.data.dockerRepository.split("/")[-1]
67-
if metadata.data.language == ConnectorLanguage.JAVA:
68-
# For Java connectors, the context directory is the repo root.
69-
context_dir = context_dir.parent.parent.parent
70-
# For Java connectors, we need to build the connector tar file first.
71-
response: subprocess.CompletedProcess[str] = subprocess.run(
72-
[
73-
"./gradlew",
74-
f":airbyte-integrations:connectors:{connector_name}:distTar",
75-
],
76-
cwd=context_dir,
77-
text=True,
78-
check=True,
79-
)
80-
8166
docker_args: list[str] = [
8267
"docker",
8368
"build",
@@ -213,6 +198,22 @@ def build_connector_image(
213198

214199
base_tag = f"{metadata.data.dockerRepository}:{tag}"
215200
arch_images: list[str] = []
201+
202+
if metadata.data.language == ConnectorLanguage.JAVA:
203+
# This assumes that the repo root ('airbyte') is three levels above the
204+
# connector directory (airbyte/airbyte-integrations/connectors/source-foo).
205+
repo_root = connector_directory.parent.parent.parent
206+
# For Java connectors, we need to build the connector tar file first.
207+
subprocess.run(
208+
[
209+
"./gradlew",
210+
f":airbyte-integrations:connectors:{connector_name}:distTar",
211+
],
212+
cwd=repo_root,
213+
text=True,
214+
check=True,
215+
)
216+
216217
for arch in [ArchEnum.AMD64, ArchEnum.ARM64]:
217218
docker_tag = f"{base_tag}-{arch.value}"
218219
docker_tag_parts = docker_tag.split("/")

airbyte_cdk/utils/docker_image_templates.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
DOCKERIGNORE_TEMPLATE: str = "\n".join(
1515
[
1616
"# This file is auto-generated. Do not edit.",
17-
# "*,"
17+
"*," # Ignore everything not explicitly allowed below
1818
"build/",
19+
"!build/distributions/*.tar",
1920
".venv/",
2021
"secrets/",
2122
"!setup.py",
@@ -162,7 +163,7 @@
162163
ENV APPLICATION="${CONNECTOR_KEBAB_NAME}"
163164
164165
# Add the connector TAR file and extract it
165-
COPY airbyte-integrations/connectors/${CONNECTOR_KEBAB_NAME}/build/distributions/${CONNECTOR_KEBAB_NAME}.tar /tmp/${CONNECTOR_KEBAB_NAME}.tar
166+
COPY ./build/distributions/${CONNECTOR_KEBAB_NAME}.tar /tmp/${CONNECTOR_KEBAB_NAME}.tar
166167
RUN tar xf /tmp/${CONNECTOR_KEBAB_NAME}.tar --strip-components=1 -C /airbyte && \
167168
rm -rf /tmp/${CONNECTOR_KEBAB_NAME}.tar && \
168169
chown -R airbyte:airbyte /airbyte

0 commit comments

Comments
 (0)