Skip to content

feat: update all postgres image references to 16.8 Debian-based #3035

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cyyynthia
Copy link
Contributor

@cyyynthia cyyynthia commented Apr 10, 2025

See #3033

Summary by CodeRabbit

  • Chores
    • Upgraded the PostgreSQL database environment to version 16.8 across all deployment configurations for consistent and improved operations.

@cyyynthia cyyynthia added the enhancement New feature or request label Apr 10, 2025
Copy link

coderabbitai bot commented Apr 10, 2025

Walkthrough

The changes update the PostgreSQL Docker image version across the codebase and configuration files. The PostgresDockerRunner.kt now uses postgres:16.8 instead of postgres:16.3, while the Gradle task for starting the PostgreSQL container has been updated from postgres:13 to postgres:16.8. Additionally, Docker-related files including the Dockerfile and docker-compose templates have been modified to use the postgres:16.8 image, with no changes to publicly exported APIs.

Changes

File(s) Change Summary
backend/.../PostgresDockerRunner.kt
build.gradle
Updated PostgreSQL image version: changed from postgres:16.3 and postgres:13 to postgres:16.8 for the Docker runner and DB container startup command.
docker/app/Dockerfile
docker/docker-compose.template.yml
docker/docker-compose.yml
Upgraded the Postgres image versions used in Docker configurations: updated base image from postgres:13.20-alpine3.21 and service images from postgres:11 to postgres:16.8.

Sequence Diagram(s)

Poem

I'm Bunny, hopping with glee,
Spying upgrades in the Docker sea.
Postgres now shines at 16.8 so bright,
Leaping from old tags into the light.
With twitching ears, I celebrate this code delight!

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@cyyynthia
Copy link
Contributor Author

Well well well, after a bit of digging, it seems like that PR accidentally found some bugs... 🙃

There was issues with sorting because using Alpine (like in the distributed image..!) means using musl libc, which has very limited support for fancy locales stuff and was only doing bytewise comparisons.

Thankfully, since PostgreSQL 15 we can rely on ICU instead, which appears to solve the issues. Tests still fail, but after glancing at the results it seems the tests are the problem this time, but I didn't investigate further.

@cyyynthia cyyynthia force-pushed the cynthia/update-postgres branch 2 times, most recently from 724ebc1 to befd300 Compare April 10, 2025 22:04
Copy link

@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

🧹 Nitpick comments (1)
backend/misc/src/main/kotlin/io/tolgee/misc/dockerRunner/DockerContainerRunner.kt (1)

129-135: Improved command string processing to handle escaped spaces correctly.

The updated implementation uses a more sophisticated regex pattern with a negative lookbehind assertion ((?<!\\)\\s+) to ensure that escaped spaces in command arguments are preserved during splitting. This is followed by a mapping operation that converts these escaped spaces to regular spaces.

This enhancement is important for correctly processing Docker commands that might include arguments with spaces, such as container names or paths with spaces, which need to be escaped in the command line.

Consider adding a brief comment explaining the purpose of this regex and transformation for future maintainability:

  private fun String.startProcess(
    workingDir: File,
    timeoutAmount: Long,
    timeoutUnit: TimeUnit,
  ): Process {
+   // Split command by whitespace but preserve escaped spaces, then convert escaped spaces to regular spaces
    val transformed = "(?<!\\\\)\\s+"
      .toRegex()
      .split(this.trim())
      .map { it.replace("\\ ", " ") }

    return ProcessBuilder(transformed)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f34749 and befd300.

📒 Files selected for processing (6)
  • backend/app/src/main/kotlin/io/tolgee/postgresRunners/PostgresDockerRunner.kt (2 hunks)
  • backend/misc/src/main/kotlin/io/tolgee/misc/dockerRunner/DockerContainerRunner.kt (1 hunks)
  • build.gradle (1 hunks)
  • docker/app/Dockerfile (1 hunks)
  • docker/docker-compose.template.yml (1 hunks)
  • docker/docker-compose.yml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • backend/app/src/main/kotlin/io/tolgee/postgresRunners/PostgresDockerRunner.kt
  • build.gradle
  • docker/app/Dockerfile
  • docker/docker-compose.template.yml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build backend 🏗️
🔇 Additional comments (3)
docker/docker-compose.yml (3)

3-3: Update DB Service Image Version

The db service now uses postgres:16.8-alpine3.21, which aligns with the PR objective to update PostgreSQL image references. This change is properly applied.


7-8: Introduce POSTGRES_INITDB_ARGS for ICU Locale Support

Adding the POSTGRES_INITDB_ARGS environment variable with the arguments --locale-provider=icu --icu-locale=und-u-kn-true is a critical enhancement. This change leverages ICU for proper locale handling and better sorting behavior. Please ensure that the initialization arguments are tested in your test environment so that they produce the expected locale settings.


19-19: Clarify SMTP Service Image Change

The SMTP service image on line 19 is updated to namshi/smtp. Since the primary PR objective focuses on updating PostgreSQL image references, please confirm whether this change was intentional. If it is part of a broader update, it would be helpful to include additional context in the PR description.

musl libc's reduced feature-set causes unexpected issues with ordering
existing workarounds seem to surface more unexpected issues as well
let's go for the easy solution first
@cyyynthia cyyynthia force-pushed the cynthia/update-postgres branch from befd300 to 92bb8f9 Compare April 11, 2025 07:47
@cyyynthia
Copy link
Contributor Author

Well, given the amount of issues surfaced by trying Alpine images, I think it's best for now to stick to Debian-based images, and experiment with Alpine images more thoroughly later.

I am unsure if the configuration I tried to use with Alpine (--locale-provider=icu --icu-locale=und-u-kn-true) yielded the expected behavior, but I can definitely say that this config was making sort operations behave using natural string ordering (1, 2, 10 instead of 1, 10, 2). Whether the remaining issues were from the sort behavior exhibited by PostgreSQL or the tests being incorrect is unclear.

@cyyynthia cyyynthia changed the title feat: update all postgres image references to 16.8-alpine3.21 feat: update all postgres image references to 16.8 Debian-based Apr 11, 2025
Copy link

@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

🧹 Nitpick comments (1)
docker/app/Dockerfile (1)

5-10: APT Installation and Cleanup Block

The heredoc RUN block correctly:

  • Enables strict mode with set -eux
  • Updates the apt cache quietly
  • Installs temurin-21-jdk and libxml2 in a single layer
  • Cleans up the apt lists to reduce image size

As an optional improvement, consider setting the environment variable DEBIAN_FRONTEND=noninteractive to suppress any interactive prompts during package installation. Here’s a diff suggestion:

-FROM postgres:16.8
+FROM postgres:16.8
+ENV DEBIAN_FRONTEND=noninteractive

This change can help ensure that the build stays non-interactive even if future package changes introduce prompts.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92bb8f9 and 8ba3cfd.

📒 Files selected for processing (1)
  • docker/app/Dockerfile (1 hunks)
🔇 Additional comments (1)
docker/app/Dockerfile (1)

1-1: Base Image Update Verification

The base image has been updated to postgres:16.8, consistent with the PR objective to move to a Debian-based PostgreSQL image. Please verify that the default variant for postgres:16.8 is indeed Debian-based as expected.

@cyyynthia cyyynthia force-pushed the cynthia/update-postgres branch from 8ba3cfd to 182b46a Compare April 11, 2025 08:30
@cyyynthia cyyynthia force-pushed the cynthia/update-postgres branch from 182b46a to ac497e9 Compare April 11, 2025 08:55
Copy link

@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

🧹 Nitpick comments (1)
docker/app/Dockerfile (1)

5-15: Streamlined RUN Block with Apt Commands

The multi-line RUN block is well-structured. It updates the package lists, installs wget to fetch the Adoptium GPG key, configures the Adoptium repository, installs temurin-21-jdk and libxml2, and then cleans up by removing wget and clearing cached package lists. This helps keep the Docker image size lean.

One optional enhancement is to ensure noninteractive installation by setting the DEBIAN_FRONTEND environment variable. This can help prevent any unforeseen interactive prompts during package installation. You can either add it as a global environment variable or prepend it to the RUN command. For instance:

+ENV DEBIAN_FRONTEND=noninteractive

Or modify the RUN command as follows:

-RUN <<EOF
+RUN export DEBIAN_FRONTEND=noninteractive && <<EOF

This change is optional but can improve reliability in automated builds.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 182b46a and ac497e9.

📒 Files selected for processing (1)
  • docker/app/Dockerfile (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Frontend static check 🪲
  • GitHub Check: Build backend 🏗️
  • GitHub Check: Build frontend 🏗️
🔇 Additional comments (1)
docker/app/Dockerfile (1)

1-1: Base Image Update Verification

The base image has been correctly updated to postgres:16.8, which aligns with the PR objective of moving to a Debian-based image with the latest PostgreSQL version. Please confirm that all dependent tools and configurations in the project are compatible with this image.

@@ -1,9 +1,18 @@
FROM postgres:13.20-alpine3.21
FROM postgres:16.8
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change, since now we embed postgres 13. So for all the users running the current image, this make their containers fail to start.

It would be great if you wrote an migration guide for this, so the users know how to migrate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a fair point. I myself never dealt with migrating embedded databases (I always use compose with a volume mount); so I'm not sure what the best procedure would be to ensure smooth migration w/o losing data 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Me neither. That's the thing... 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking a bit more about it, the update procedure should be mostly the same as for any Tolgee release (the container image changes regardless of whether the base changed or not). The only additional consideration is upgrading PostgreSQL, which is a fairly straightforward process documented here: https://www.postgresql.org/docs/17/upgrading.html

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know! Anyway, if we are going to release this, we need to do it with breaking change (new major version) and with some migration guide in our docs. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should point out my conclusion isn't really based on anything concrete, given that I'm not even quite sure how one's supposed to upgrade Tolgee when using the monolithic image to begin with 😬

Not sure it falls under the breaking change umbrella; sure the data needs to be migrated but that's a deployment concern that I wouldn't necessarily tie to the version 🤔 but that's up to you. If this ends up released as a new major version, I recon there are a bunch of things pending removal in the source code too 😅

I don't think the monolithic docker image is best practice, it would probably be best to move towards Docker compose. Perhaps support for H2 (or SQLite perhaps) could be introduced back, disabling/degrading features that require PostgreSQL capabilities. SonarQube's images do this, IIRC (and nags the admin about the embedded database not being suited for any serious deployment).

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, removing the embedded DB would make sense.

Anyway, we cannot introduce other DBs, because we already use too much Postgres specific features.

@JanCizmar
Copy link
Contributor

Thanks a lot for the PR anyway! ❤️ Btw. What prevent us from upgrading to Postgres 17?

@cyyynthia
Copy link
Contributor Author

What prevent us from upgrading to Postgres 17?

Probably nothing tbh. I just stayed on 16 since that's what was used in all the tests 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants