Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make SDM image rootless #147

Merged
merged 7 commits into from
Dec 9, 2024
Merged

chore: make SDM image rootless #147

merged 7 commits into from
Dec 9, 2024

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented Dec 6, 2024

Summary by CodeRabbit

  • New Features

    • Upgraded the base image to enhance performance and security.
    • Implemented a command to improve directory ownership for better security.
  • Bug Fixes

    • Adjusted user permissions to ensure the application runs with least privilege.

@github-actions github-actions bot added the chore label Dec 6, 2024
Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The Dockerfile has been updated to use a newer base image, transitioning from airbyte/python-connector-base:2.0.0 to airbyte/python-connector-base:3.0.0. This change includes a new command to set ownership of the /airbyte directory to the airbyte user and introduces a directive to run the container as this user. The overall structure of the Dockerfile remains mostly unchanged, with existing commands for setting the working directory, copying files, installing dependencies, and executing the main script retained.

Changes

File Change Summary
Dockerfile - Updated base image from 2.0.0 to 3.0.0
- Added command to change ownership of /airbyte to airbyte user
- Added directive to run as airbyte user

Possibly related PRs

Suggested reviewers

  • ChristoGrab
  • aaronsteers

Wdyt about reaching out to these reviewers for their insights?


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9865f58 and 0b96763.

📒 Files selected for processing (1)
  • Dockerfile (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Dockerfile

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
Dockerfile (1)

26-28: Great security improvements! 🛡️ A couple of suggestions...

Love the rootless container setup! Would you consider these additional improvements? wdyt?

  1. Using numeric UID for better compatibility across platforms:
-RUN chown -R airbyte /airbyte
+RUN chown -R 1000:1000 /airbyte
-USER airbyte
+USER 1000
  1. Moving WORKDIR after USER to ensure all directory accesses are non-root:
 RUN chown -R airbyte /airbyte
+USER airbyte
+WORKDIR /airbyte/integration_code
 
 ENV AIRBYTE_ENTRYPOINT="python /airbyte/integration_code/main.py"
 ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
-USER airbyte

Also applies to: 32-32

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 59505ff and 48bfb51.

📒 Files selected for processing (1)
  • Dockerfile (2 hunks)
🔇 Additional comments (2)
Dockerfile (2)

Line range hint 1-32: Overall implementation looks solid! 🚀

The changes effectively achieve the goal of making the SDM image rootless while maintaining proper security practices. Nice work on implementing this security improvement!


1-1: Verify compatibility with base image v3.0.0

The major version bump from 2.0.0 to 3.0.0 could introduce breaking changes. Great job including the SHA256 digest for immutability! 🔒

Let's check the changelog and any breaking changes:

@alafanechere
Copy link
Contributor Author

@ChristoGrab published a pre-release of the image and successfully tested source-pokeapi built from it.

Dockerfile Outdated Show resolved Hide resolved
Copy link
Contributor

@aaronsteers aaronsteers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! And grateful to you both (@alafanechere and @ChristoGrab) for the extra step of manually pre-testing in Cloud.

One inline comment for clarification and I think this is ready to go! 🚀

@aaronsteers
Copy link
Contributor

@alafanechere and @ChristoGrab - Will one of you be able to monitor after deploying? Specifically:

  1. Check that Cloud (prod) has received the new version of the image?
  2. Check that after new version is deployed, that execution is still running?

(This would be helpful to add to our RELEASES.md file - I'm not 100% sure how to do it myself and I understand it differs slightly from that standard process of deploying/checking connectors post-release.)

@aaronsteers
Copy link
Contributor

aaronsteers commented Dec 6, 2024

Also (fyi) after this merges, we can release in the normal way - by publishing the draft release (https://github.com/airbytehq/airbyte-python-cdk/releases). It should automatically rebuild and republish with this Dockerfile definition. 🚀

Copy link
Contributor

@aaronsteers aaronsteers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like manual testing is not 100% green as of now.

Requesting pause on auto-merge until we are sure (especially ahead of the weekend).

cc @alafanechere and @ChristoGrab

@aaronsteers
Copy link
Contributor

@alafanechere - I don't remember us overriding how the image is built during --use-local-cdk. I believe we only inject the python package into an existing SDM image (maybe "latest"?). So, in that case, I don't know if we can rely on CI to catch issues in the Dockerfile generation - or more specifically, with how our test connectors would interact with the different base image.

Can you confirm if that is your understanding as well?

@alafanechere
Copy link
Contributor Author

@alafanechere - I don't remember us overriding how the image is built during --use-local-cdk. I believe we only inject the python package into an existing SDM image (maybe "latest"?). So, in that case, I don't know if we can rely on CI to catch issues in the Dockerfile generation - or more specifically, with how our test connectors would interact with the different base image.

Can you confirm if that is your understanding as well?

@aaronsteers your understanding is correct. The automated connector testing on CDK change in this repo does not use the "dev" image. Which image is used by a connector is defined in its metadata.yaml which we're not editing at test time via --use-local-cdk.
I manually tested source-pokeapi built from a pre-release of SDM from this branch.
I confirm the tests are passing and a basic Airbyte Cloud sync works with it.

Copy link
Contributor

@aaronsteers aaronsteers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. 👍

@alafanechere alafanechere merged commit a712441 into main Dec 9, 2024
23 checks passed
@alafanechere alafanechere deleted the augustin/sdm-rootless branch December 9, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants