|
| 1 | +# airbyte-connectors-base-images |
| 2 | + |
| 3 | +This python package contains the base images used by Airbyte connectors. |
| 4 | +It is intended to be used as a python library. |
| 5 | +Our connector build pipeline ([`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md#L1)) **will** use this library to build the connector images. |
| 6 | +Our base images are declared in code, using the [Dagger Python SDK](https://dagger-io.readthedocs.io/en/sdk-python-v0.6.4/). |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +## Where are the Dockerfiles? |
| 11 | +Our base images are not declared using Dockerfiles. |
| 12 | +They are declared in code using the [Dagger Python SDK](https://dagger-io.readthedocs.io/en/sdk-python-v0.6.4/). |
| 13 | +We prefer this approach because it allows us to interact with base images container as code: we can use python to declare the base images and use the full power of the language to build and test them. |
| 14 | +However, we do artificially generate Dockerfiles for debugging and documentation purposes. |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +### Example for `airbyte/python-connector-base`: |
| 19 | +```dockerfile |
| 20 | +FROM docker.io/python:3.9.18-slim-bookworm@sha256:44b7f161ed03f85e96d423b9916cdc8cb0509fb970fd643bdbc9896d49e1cad0 |
| 21 | +RUN ln -snf /usr/share/zoneinfo/Etc/UTC /etc/localtime |
| 22 | +RUN pip install --upgrade pip==23.2.1 |
| 23 | +ENV POETRY_VIRTUALENVS_CREATE=false |
| 24 | +ENV POETRY_VIRTUALENVS_IN_PROJECT=false |
| 25 | +ENV POETRY_NO_INTERACTION=1 |
| 26 | +RUN pip install poetry==1.6.1 |
| 27 | +``` |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +## Base images |
| 32 | + |
| 33 | + |
| 34 | +### `airbyte/python-connector-base` |
| 35 | + |
| 36 | +| Version | Published | Docker Image Address | Changelog | |
| 37 | +|---------|-----------|--------------|-----------| |
| 38 | +| 1.0.0 | ✅| docker.io/airbyte/python-connector-base:1.0.0@sha256:dd17e347fbda94f7c3abff539be298a65af2d7fc27a307d89297df1081a45c27 | Initial release: based on Python 3.9.18, on slim-bookworm system, with pip==23.2.1 and poetry==1.6.1 | |
| 39 | + |
| 40 | + |
| 41 | +## How to release a new base image version (example for Python) |
| 42 | + |
| 43 | +### Requirements |
| 44 | +* [Docker](https://docs.docker.com/get-docker/) |
| 45 | +* [Poetry](https://python-poetry.org/docs/#installation) |
| 46 | +* Dockerhub logins |
| 47 | + |
| 48 | +### Steps |
| 49 | +1. `poetry install` |
| 50 | +2. Open `base_images/python/bases.py`. |
| 51 | +3. Make changes to the `AirbytePythonConnectorBaseImage`, you're likely going to change the `get_container` method to change the base image. |
| 52 | +4. Implement the `container` property which must return a `dagger.Container` object. |
| 53 | +5. **Recommended**: Add new sanity checks to `run_sanity_check` to confirm that the new version is working as expected. |
| 54 | +6. Cut a new base image version by running `poetry run generate-release`. You'll need your DockerHub credentials. |
| 55 | + |
| 56 | +It will: |
| 57 | + - Prompt you to pick which base image you'd like to publish. |
| 58 | + - Prompt you for a major/minor/patch/pre-release version bump. |
| 59 | + - Prompt you for a changelog message. |
| 60 | + - Run the sanity checks on the new version. |
| 61 | + - Optional: Publish the new version to DockerHub. |
| 62 | + - Regenerate the docs and the registry json file. |
| 63 | +7. Commit and push your changes. |
| 64 | +8. Create a PR and ask for a review from the Connector Operations team. |
| 65 | + |
| 66 | +**Please note that if you don't publish your image while cutting the new version you can publish it later with `poetry run publish <repository> <version>`.** |
| 67 | +No connector will use the new base image version until its metadata is updated to use it. |
| 68 | +If you're not fully confident with the new base image version please: |
| 69 | + - please publish it as a pre-release version |
| 70 | + - try out the new version on a couple of connectors |
| 71 | + - cut a new version with a major/minor/patch bump and publish it |
| 72 | + - This steps can happen in different PRs. |
| 73 | + |
| 74 | + |
| 75 | +## Running tests locally |
| 76 | +```bash |
| 77 | +poetry run pytest |
| 78 | +# Static typing checks |
| 79 | +poetry run mypy base_images --check-untyped-defs |
| 80 | +``` |
0 commit comments