Skip to content

CAMPAIGN-54: migrate to tw-base-python base image#154

Open
caiocsgomes wants to merge 2 commits into
masterfrom
CAMPAIGN-54-migrate-tw-base-python
Open

CAMPAIGN-54: migrate to tw-base-python base image#154
caiocsgomes wants to merge 2 commits into
masterfrom
CAMPAIGN-54-migrate-tw-base-python

Conversation

@caiocsgomes

Copy link
Copy Markdown
Member

Context

Part of CAMPAIGN-54. All Python services must use the standard tw-base-python base image so the platform can apply consistent security patching, the com.transferwise.language label, and SLSA tooling uniformly. Please review and make sure the changes are safe.

This service was on the official python:3.12-slim image. This PR migrates it to tw-base-python:3.12.

Changes

  • Swapped FROM python:3.12-slim for FROM tw-base-python.arti.tw.ee/tw-base-python:3.12 (same Python version).
  • tw-base-python runs as the non-root user UID 65534 (unlike python:slim which runs as root), so pip install . (which writes into system site-packages) is wrapped with USER 0.
  • Added chown -R 65534 /app so the runtime user can read the app directory.
  • Added USER 65534 before the ENTRYPOINT so the container runs as non-root.

Test plan

  • docker build succeeds against tw-base-python.arti.tw.ee/tw-base-python:3.12.
  • Container starts and cfexpose export runs as UID 65534.
  • /metrics on port 5000 responds as before.

Switch the base image from the official python:3.12-slim to Wise's
standard tw-base-python:3.12 so the platform can apply consistent
security patching, the com.transferwise.language label, and SLSA
tooling uniformly.

tw-base-python runs as the non-root user UID 65534, unlike python:slim
which runs as root. To keep the build working:
- USER 0 before `pip install .` so the install can write into system
  site-packages.
- chown -R 65534 /app so the runtime user can read the app directory.
- USER 65534 before the ENTRYPOINT so the container runs as non-root.
Copilot AI review requested due to automatic review settings July 9, 2026 13:39
@caiocsgomes caiocsgomes requested a review from a team as a code owner July 9, 2026 13:39
@platon-github-app-production

Copy link
Copy Markdown

Comment /request-review to automatically request reviews from the following teams:

You can also request review from a specific team by commenting /request-review team-name, or you can add a description with --notes "<message>"

💡 If you see something that doesn't look right, check the configuration guide.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Changes: Maintenance (1)

This PR migrates the service container from the upstream python:3.12-slim image to the internal tw-base-python:3.12 base image, adjusting user privileges so the container runs as non-root at runtime while still allowing installation steps that need elevated permissions.

Changes:

  • Switch Docker base image to tw-base-python.arti.tw.ee/tw-base-python:3.12.
  • Temporarily escalate to root for pip install ., then drop back to UID 65534 for runtime.
  • Adjust ownership of /app to support running as the non-root user.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Dockerfile Outdated
Address review feedback: chown both UID and GID (65534:65534) so group
ownership no longer stays root, and combine the pip install and chown
into a single RUN to avoid an extra image layer.
@caiocsgomes

Copy link
Copy Markdown
Member Author

/request-review

@platon-github-app-production

Copy link
Copy Markdown

Success 🎉 The review request was sent to the following:

If you see something that doesn't look right, follow this doc to improve our slack channel mapping. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants