Skip to content

Commit 51301d4

Browse files
committed
remove java image option
1 parent f323849 commit 51301d4

File tree

2 files changed

+47
-11
lines changed

2 files changed

+47
-11
lines changed

airbyte_cdk/utils/docker.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from airbyte_cdk.models.connector_metadata import MetadataFile
1515
from airbyte_cdk.utils.docker_image_templates import (
1616
DOCKERIGNORE_TEMPLATE,
17+
MANIFEST_ONLY_DOCKERFILE_TEMPLATE,
1718
PYTHON_CONNECTOR_DOCKERFILE_TEMPLATE,
1819
)
1920

@@ -120,7 +121,7 @@ def build_connector_image(
120121

121122
base_image = metadata.data.connectorBuildOptions.baseImage
122123

123-
dockerfile_path.write_text(PYTHON_CONNECTOR_DOCKERFILE_TEMPLATE)
124+
dockerfile_path.write_text(get_dockerfile_template(metadata))
124125
dockerignore_path.write_text(DOCKERIGNORE_TEMPLATE)
125126

126127
build_args: dict[str, str | None] = {
@@ -165,6 +166,36 @@ def build_connector_image(
165166
sys.exit(0)
166167

167168

169+
def get_dockerfile_template(
170+
metadata: MetadataFile,
171+
) -> str:
172+
"""Get the Dockerfile template for the connector.
173+
174+
Args:
175+
metadata: The metadata of the connector.
176+
connector_name: The name of the connector.
177+
178+
Returns:
179+
The Dockerfile template as a string.
180+
"""
181+
if metadata.data.language == "python":
182+
return PYTHON_CONNECTOR_DOCKERFILE_TEMPLATE
183+
184+
if metadata.data.language == "manifest-only":
185+
return MANIFEST_ONLY_DOCKERFILE_TEMPLATE
186+
187+
if metadata.data.language == "java":
188+
raise ValueError(
189+
f"Java and Kotlin connectors are not yet supported. "
190+
"Please use airbyte-ci or gradle to build your image."
191+
)
192+
193+
raise ValueError(
194+
f"Unsupported connector language: {metadata.data.language}. "
195+
"Please check the connector's metadata file."
196+
)
197+
198+
168199
def run_docker_command(
169200
cmd: list[str],
170201
*,

airbyte_cdk/utils/docker_image_templates.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
These templates are used to generate connector images.
88
"""
99

10+
##############################
11+
## GLOBAL DOCKERIGNORE FILE ##
12+
##############################
13+
1014
DOCKERIGNORE_TEMPLATE: str = "\n".join(
1115
[
1216
"# This file is auto-generated. Do not edit.",
@@ -28,6 +32,10 @@
2832
]
2933
)
3034

35+
###########################
36+
# PYTHON CONNECTOR IMAGE ##
37+
###########################
38+
3139
PYTHON_CONNECTOR_DOCKERFILE_TEMPLATE = """
3240
# syntax=docker/dockerfile:1
3341
# check=skip=all
@@ -42,7 +50,6 @@
4250
WORKDIR /airbyte/integration_code
4351
4452
COPY . ./
45-
COPY ${CONNECTOR_SNAKE_NAME} ./${CONNECTOR_SNAKE_NAME}
4653
4754
# Conditionally copy and execute the extra build script if provided
4855
RUN if [ -n "${EXTRA_PREREQS_SCRIPT}" ]; then \
@@ -74,23 +81,21 @@
7481
ENTRYPOINT ["/entrypoint.sh"]
7582
"""
7683

84+
##################################
85+
# MANIFEST-ONLY CONNECTOR IMAGE ##
86+
##################################
87+
7788
MANIFEST_ONLY_DOCKERFILE_TEMPLATE = """
7889
ARG BASE_IMAGE
7990
ARG CONNECTOR_SNAKE_NAME
8091
ARG CONNECTOR_KEBAB_NAME
8192
82-
FROM ${BASE_IMAGE} AS builder
93+
FROM ${BASE_IMAGE}
8394
8495
WORKDIR /airbyte/integration_code
8596
8697
COPY . ./
87-
COPY --chmod=755 <<EOT /entrypoint.sh
88-
#!/usr/bin/env bash
89-
set -e
90-
91-
${CONNECTOR_KEBAB_NAME} "$@"
92-
EOT
9398
94-
ENV AIRBYTE_ENTRYPOINT="/entrypoint.sh"
95-
ENTRYPOINT ["/entrypoint.sh"]
99+
ENV AIRBYTE_ENTRYPOINT="python ./main.py"
100+
ENTRYPOINT ["python", "./main.py"]
96101
"""

0 commit comments

Comments
 (0)