tolgee-platform icon indicating copy to clipboard operation
tolgee-platform copied to clipboard

feat: Optimize Dockerfile

Open transparentChange opened this issue 4 months ago • 8 comments

Changes the Dockerfile to use a base image without postgresql. Instead, the external postgres is used when running with docker-compose. This change significantly reduces build size and performance.

docker images local output: image

Summary by CodeRabbit

  • New Features

    • Added Docker Compose setup including app, database, and SMTP services.
    • Introduced a lightweight application image with built-in health checks and a persistent data volume.
    • Enabled local image builds via Docker Compose instead of pulling a prebuilt image.
  • Chores

    • Added an environment variable to control Postgres autostart (disabled by default).
    • Standardized the app startup script to use sh for broader compatibility.

transparentChange avatar Aug 07 '25 22:08 transparentChange

[!WARNING]

Rate limit exceeded

@transparentChange has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 35 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 248b7fcc721e68d89d28394b27edb37291ba5344 and dfe02341fc7c5350d8786da149789860ed70b6a3.

📒 Files selected for processing (2)
  • docker/app/Dockerfile.lite (1 hunks)
  • docker/docker-compose.yml (1 hunks)

Walkthrough

Adds a new lightweight app Dockerfile, introduces/updates docker-compose configurations to build the app locally and define db/smtp services, adds a healthcheck in the Docker image, updates an env file with a new variable, and changes a script shebang from bash to sh.

Changes

Cohort / File(s) Summary
Docker Compose configs
docker-compose.yml, docker/docker-compose.yml
New root docker-compose defines db/app/smtp services; app builds from local Dockerfile. Existing docker/docker-compose.yml switches app from registry image to local build (context ../build/docker, Dockerfile).
App Docker image (lite)
docker/app/Dockerfile.lite
New Dockerfile based on eclipse-temurin:21-alpine; installs deps, copies app artifacts, sets entrypoint to /app/cmd.sh, exposes 8080, defines /data volume, sets env vars, and adds HTTP healthcheck.
Environment configuration
docker/.env
Adds TOLGEE_POSTGRES_AUTOSTART_ENABLED=false.
Startup script
docker/app/cmd.sh
Shebang changed from bash to sh; no logic changes.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paws on docker’s shore,
New compose sails, we build once more.
A healthcheck nibble, ports aligned,
Env seeds planted, neatly defined.
Bash to sh—hop light, hop bright—
Ship the app; all greens tonight! 🐇🛳️

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: Optimize Dockerfile" is concise and directly related to the changes in this PR, which introduce a lighter Dockerfile and alter the Docker setup to avoid bundling PostgreSQL in order to reduce image size and improve performance, so it accurately summarizes the primary intent.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Aug 07 '25 22:08 coderabbitai[bot]

@JanCizmar @Anty0 Requesting your review

transparentChange avatar Aug 10 '25 21:08 transparentChange

@transparentChange Hi! Thanks for the PR!

We discussed the possibility of a similar change internally. Unfortunately, removing the bundled Postgres instance wouldn't be straightforward, as users already rely on it. Implementing this change would require some manual migration steps for them.

One idea would be to create a separate Docker image without the bundled Postgres, while keeping the existing one with the bundled Postgres. New self-hosters could then use the new image, and we could keep the old one for existing deployments.

Anty0 avatar Aug 11 '25 15:08 Anty0

@transparentChange However, we can create separate "lite" image without postgres. But I would not change the default tolgee/tolgee.

JanCizmar avatar Aug 11 '25 16:08 JanCizmar

This PR is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Sep 12 '25 02:09 github-actions[bot]

@JanCizmar Thank you for the review. Like you suggested I added the new Dockerfile.lite file and a comment for how it can be hooked up to the docker-compose.

transparentChange avatar Sep 23 '25 22:09 transparentChange

@Anty0 can you look into this when you have some time? It stays in my backlog for a long time already and I don't want to ghost @transparentChange

JanCizmar avatar Oct 16 '25 06:10 JanCizmar

This PR is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Nov 30 '25 02:11 github-actions[bot]