@@ -258,6 +258,13 @@ def build_from_base_image(
258258) -> str :
259259 """Build a Docker image for the connector using a base image.
260260
261+ This implementation follows a similar approach to airbyte-ci:
262+ 1. Creates a builder stage to install dependencies
263+ 2. Copies only necessary build files first
264+ 3. Installs dependencies
265+ 4. Copies the connector code
266+ 5. Sets up the entrypoint
267+
261268 Args:
262269 connector_dir: Path to the connector directory.
263270 metadata: The connector metadata.
@@ -292,14 +299,35 @@ def build_from_base_image(
292299 except subprocess .CalledProcessError :
293300 logger .warning ("Pre-install hook failed, continuing with build" )
294301
302+ build_files = [
303+ "setup.py" ,
304+ "pyproject.toml" ,
305+ "poetry.lock" ,
306+ "poetry.toml" ,
307+ "requirements.txt" ,
308+ "README.md" ,
309+ "build_customization.py"
310+ ]
311+
312+ connector_package_name = connector_dir .name .replace ("-" , "_" )
313+
295314 dockerfile_content = f"""
315+ FROM { base_image } as builder
316+
317+ WORKDIR /airbyte/integration_code
318+
319+ COPY setup.py pyproject.toml poetry.lock poetry.toml requirements.txt README.md build_customization.py ./
320+ COPY { connector_package_name } ./{ connector_package_name }
321+
322+ RUN pip install --no-cache-dir .
323+
296324FROM { base_image }
297325
298326WORKDIR /airbyte/integration_code
299327
300- COPY . .
328+ COPY --from=builder /usr/local /usr/local
301329
302- RUN pip install .
330+ COPY . .
303331
304332ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/{ get_main_file_name (connector_dir )} "
305333ENTRYPOINT ["python", "/airbyte/integration_code/{ get_main_file_name (connector_dir )} "]
@@ -310,6 +338,7 @@ def build_from_base_image(
310338
311339 dockerignore_content = """
312340*
341+
313342!setup.py
314343!pyproject.toml
315344!poetry.lock
0 commit comments