Skip to content

Dev #2

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 19 commits into
base: main
Choose a base branch
from
Open

Dev #2

wants to merge 19 commits into from

Conversation

pjabie
Copy link
Collaborator

@pjabie pjabie commented Apr 23, 2025

Pasamos todo a Main

Summary by CodeRabbit

  • New Features

    • Added scripts for automating repository cloning, backup/restore, and database cleanup.
    • Introduced a Docker Compose setup for Odoo and PostgreSQL services.
    • Provided an environment variable example file for configuration guidance.
    • Added requirements files for Aeroo Reports integration.
  • Improvements

    • Simplified and updated Odoo configuration and Dockerfile for better maintainability and compatibility.
    • Enhanced requirements with new dependencies and removed unused ones.
  • Style

    • Improved formatting and reduced comments in configuration files for clarity.
  • Chores

    • Expanded .gitignore to cover more files and directories.

Copy link

coderabbitai bot commented Apr 23, 2025

Walkthrough

This update introduces a comprehensive set of scripts and configuration files to automate and manage an Odoo deployment using Docker. Key additions include Docker Compose and Dockerfile modifications for service orchestration and image building, Bash scripts for repository cloning, backup/restore, and database cleaning, as well as environment and requirements files for configuration and dependency management. The Odoo entrypoint and configuration files have been streamlined, with several new files added to support Aeroo Reports integration and other dependencies. The .gitignore was expanded to cover more files and directories.

Changes

File(s) Change Summary
.gitignore Expanded to ignore additional environment files, directories, and a module list file.
clone_repos.sh, backup_restore.sh, clean_db.sh, entrypoint.sh New Bash scripts for cloning repositories, backup/restore automation, database cleaning, and Odoo container entrypoint logic.
docker-compose.yml New file defining multi-service Docker setup for PostgreSQL and Odoo, with configuration for volumes, environment, and dependencies.
env.example New environment variable template file for Odoo and PostgreSQL deployment configuration.
versions/16.0/Dockerfile Dockerfile updated for environment variable syntax corrections, package adjustments, maintainer change, permissions, and removal of some system packages and user switching.
versions/16.0/entrypoint.sh, versions/16.0/wait-for-psql.py, versions/16.0/requirements/odoo-argentina.txt Minor changes: newline added at end of file or extra comment character; no functional changes.
versions/16.0/make.sh Docker image tag updated and exit code variable corrected.
versions/16.0/odoo.conf Configuration file simplified, with reduced comments and minimal active settings.
versions/16.0/requirements/adhoc-aeroo_reports.txt New requirements file for Aeroo Reports integration with specific dependencies and references to forks.
versions/16.0/requirements/requirements.txt Dependencies updated: some removed, new ones added (Mercadolibre SDK, unrar, openpyxl, xlrd).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant clone_repos.sh
    participant .env
    participant modulos.txt
    participant GitRepo
    participant CUSTOM_ADDONS

    User->>clone_repos.sh: Run script
    clone_repos.sh->>.env: Load environment variables
    clone_repos.sh->>modulos.txt: Read repository list
    loop For each repo in modulos.txt
        clone_repos.sh->>GitRepo: Clone repo (with branch or default)
        GitRepo-->>clone_repos.sh: Repo cloned
        clone_repos.sh->>CUSTOM_ADDONS: Place repo in target dir
    end
    clone_repos.sh-->>User: Done
Loading
sequenceDiagram
    participant entrypoint.sh
    participant .env
    participant PostgreSQL
    participant Odoo
    participant /mnt/extra-addons

    entrypoint.sh->>.env: Load environment variables
    entrypoint.sh->>PostgreSQL: Wait for DB availability
    entrypoint.sh->>/mnt/extra-addons: Scan for addons
    entrypoint.sh->>Odoo: Update config with addons path
    entrypoint.sh->>PostgreSQL: Check if MAIN_MODULE installed
    alt Module installed
        entrypoint.sh->>Odoo: Start Odoo normally
    else Not installed
        entrypoint.sh->>Odoo: Start Odoo with -i MAIN_MODULE
    end
Loading
sequenceDiagram
    participant backup_restore.sh
    participant .env
    participant PROD_URL
    participant LocalOdoo

    backup_restore.sh->>.env: Load environment variables
    backup_restore.sh->>PROD_URL: Verify connection
    backup_restore.sh->>PROD_URL: Request backup (curl)
    PROD_URL-->>backup_restore.sh: Send backup zip
    backup_restore.sh->>LocalOdoo: Drop local DB (curl)
    backup_restore.sh->>LocalOdoo: Restore local DB (curl with zip)
    backup_restore.sh-->>User: Done
Loading

Poem

🐰
New scripts and configs, a warren well-made,
Compose up the services, let Odoo invade!
Backups and restores, clean databases too,
Requirements updated, dependencies new.
With a hop and a skip, the rabbit deploys—
Automation and order, in containers it enjoys!
🐇✨


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
🪧 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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

@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: 6

🧹 Nitpick comments (22)
modulos.txt.example (2)

1-6: Spelling and accent improvements in comments: To enhance readability in Spanish, consider adding proper accents and fixing typos. For example:

  • “Estandar” → “Estándar”
  • “clonaran” → “clonarán”

32-32: Remove trailing whitespace: Line 32 ends with a space after the URL. This trailing whitespace may be interpreted as part of the path. Please trim it.

versions/16.0/requirements/adhoc-aeroo_reports.txt (1)

1-1: Refine comment punctuation: In the first line, change “for eg” to the standard abbreviation “e.g.” and consider splitting the sentence for clarity:

# Use this Genshi version to fix argument-passing errors (see https://genshi.edgewall.org/ticket/600).
env.example (4)

1-5: Add descriptive comments for Odoo variables: It would be helpful to include inline descriptions or example values for:

  • ODOO_IMAGE
  • ODOO_VERSION
  • ODOO_CONTAINER_NAME
  • ODOO_PORT

This guidance will reduce setup friction.


9-17: Provide examples or defaults for PostgreSQL settings: Consider adding comments or sample values for PG_IMAGE, PG_DB, PG_USER, PG_PASSWORD, etc., to guide users in correctly populating these fields.


18-23: Document custom path variables: Variables like CUSTOM_ADDONS, CONF_PATH, DATA_PATH, and LOG_PATH would benefit from descriptions of their intended directories. Also, clarify when and why to uncomment #ENTRYPOINT.


25-29: Clean up or document commented-out sections: The commented BASE_DIR_PROD and BASE_DIR_STAGING entries are unused. Either remove them or add instructions on when to enable and configure them.

versions/16.0/requirements/odoo-argentina.txt (1)

4-4: Consider pinning openupgradelib to a specific commit instead of using @master

Using @master in a dependency reference can lead to unpredictable behavior if the upstream repository changes unexpectedly. For better reproducibility and stability, consider pinning to a specific commit hash.

-git+https://github.com/OCA/openupgradelib/@master
+git+https://github.com/OCA/openupgradelib/@{specific-commit-hash}
versions/16.0/requirements/requirements.txt (1)

15-19: Add version constraints to newly added dependencies

Several new dependencies have been added, but unrar and openpyxl lack version constraints. For better reproducibility and stability, consider pinning these to specific versions.

meli @ git+https://github.com/mercadolibre/python-sdk.git@09406bd544b974b379fea4818bd1040c7f147a40

-unrar
-openpyxl
+unrar==3.0.3
+openpyxl==3.1.2
xlrd==2.0.1

Good practice pinning the Mercadolibre SDK to a specific commit and xlrd to a specific version.

docker-compose.yml (4)

3-13: Ensure environment and volume configuration for Postgres
Consider adding a healthcheck for the postgres service to ensure readiness before Odoo attempts to connect. Also verify that the PG_PATH host directory is correctly set and has the proper permissions for the container to read/write the data at /var/lib/postgresql/data.

You can add for example:

  postgres:
    # ...
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${PG_USER} -d ${PG_DB}"]
      interval: 10s
      timeout: 5s
      retries: 5

15-23: Remove or enable commented odoo_scripts section
This commented block clutters the compose file. If the odoo_scripts service is not needed, consider removing it entirely; otherwise, uncomment and configure it properly.


25-34: Clarify Odoo build vs image usage
You specify both a build context and have commented out the image key. Confirm whether you want to always build locally (recommended for active development) or pull a versioned image. If building, remove the unused image line to keep the configuration clean.


47-55: Consolidate database environment variables prefix
Instead of HOST, POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD, consider using a consistent prefix like DB_HOST, DB_NAME, DB_USER, DB_PASSWORD for clarity and to avoid ambiguity in multi-service contexts.

clone_repos.sh (3)

34-41: Skip empty or commented lines in modules file
Currently the script processes every line, including blanks or comments. Add logic to ignore lines starting with # or empty lines to avoid parsing errors.


55-60: Avoid exposing credentials in command arguments
Injecting GITLAB_USER and GITLAB_PASSWORD into the URL can expose credentials in process listings and logs. Consider using a Git credential helper or mounting a .netrc file for authentication instead of embedding credentials directly in the clone URL.


63-72: Handle cloning failures more robustly
The fallback clone prints an error but does not exit or log which repository failed in a summary. Consider accumulating failures and exiting with a non-zero code if any critical clones fail, or at least summarizing failures at the end of the script.

versions/16.0/odoo.conf (1)

5-38: Consider enabling essential database and HTTP settings
Most options are commented out, including dbfilter, list_db, and HTTP settings. If you rely on database filtering or public listing, uncomment and configure these options. Otherwise, maintain a minimal config but document defaults for future maintainers.

entrypoint.sh (3)

5-9: Use set -u for undefined variable checks
You rely on Bash’s :? expansion to validate required vars, but adding set -u at the top would catch any undefined variables early and prevent subtle bugs.


17-24: Parameterize PostgreSQL port
The readiness check uses a hardcoded port 5432. Consider using an environment variable (e.g., POSTGRES_PORT) so that the script adapts if the database port changes.


88-96: Trim whitespace when parsing installed modules
The pipeline stripping and splitting may leave empty or malformed entries. Consider using psql -A -t and then an awk or grep -Fx loop to parse module names more reliably.

versions/16.0/Dockerfile (2)

146-146: Avoid overly permissive permissions
Using chmod -R 777 on the pyafipws package directory is insecure. Restrict permissions to what’s necessary (e.g., chmod -R 755 or adjust group ownership).


150-150: Weakened OpenSSL security
Patching openssl.cnf to lower SECLEVEL from 2 to 1 reduces cryptographic strength. Document this change clearly or consider alternative solutions (e.g., updating the client library) to avoid security downgrades.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5119061 and a1662ee.

📒 Files selected for processing (14)
  • .gitignore (1 hunks)
  • clone_repos.sh (1 hunks)
  • docker-compose.yml (1 hunks)
  • entrypoint.sh (1 hunks)
  • env.example (1 hunks)
  • modulos.txt.example (1 hunks)
  • versions/16.0/Dockerfile (5 hunks)
  • versions/16.0/entrypoint.sh (1 hunks)
  • versions/16.0/make.sh (1 hunks)
  • versions/16.0/odoo.conf (1 hunks)
  • versions/16.0/requirements/adhoc-aeroo_reports.txt (1 hunks)
  • versions/16.0/requirements/odoo-argentina.txt (1 hunks)
  • versions/16.0/requirements/requirements.txt (1 hunks)
  • versions/16.0/wait-for-psql.py (2 hunks)
🔇 Additional comments (14)
versions/16.0/requirements/adhoc-aeroo_reports.txt (1)

3-4: Verify upstream PR status: The aeroolib dependency is currently commented out pending PR #12. Ensure that the upstream PR is merged or update the requirement when the fix is available to avoid installation errors.

env.example (1)

6-8: Clarify scripting and module variables: The roles of ODOO_SCRIPTS_CONTAINER_NAME and MAIN_MODULE aren’t immediately clear. Please verify these names reflect the service definitions in docker-compose.yml and the expectations of entrypoint.sh.

.gitignore (1)

2-10: Verified ignore patterns for new artifacts: The entries for .env, addons/, config/, datadir/, log/, scripts/, postgresql/, filestore/, and modulos.txt correctly exclude environment-specific files and cloned modules directories.

versions/16.0/entrypoint.sh (1)

50-50: Non-functional newline addition: A trailing newline was added after exit 1. This aligns with POSIX text-file conventions and has no functional impact.

versions/16.0/wait-for-psql.py (1)

41-41: Adding an extra comment character is unnecessary

The line was already commented out, so adding an additional # character is redundant but harmless. This script correctly waits for PostgreSQL availability with proper timeout handling.

versions/16.0/make.sh (2)

5-5: Docker image name updated consistently

The Docker image name has been correctly updated to match the build command on line 2.


9-9: Fixed variable reference for exit code

Good fix. This now correctly uses the $result variable defined on line 3 instead of what was likely an undefined $return_code variable.

versions/16.0/requirements/requirements.txt (1)

13-14: Verify dependencies removed will not impact functionality

According to the AI summary, three dependencies were removed: gevent, greenlet, and websockets. Ensure that no Odoo modules depend on these libraries for asynchronous operations.

Also, consider adding a version constraint to the markdown dependency to prevent potential compatibility issues with future releases.

-markdown
+markdown==3.4.3
docker-compose.yml (1)

37-45: Verify host-to-container volume mounts
Ensure that the host paths (e.g., ./entrypoint.sh, ./modulos.txt, ${SCRIPT_PATH}) exist at runtime and are correctly referenced. The relative mount for entrypoint.sh should match the Docker build context path or use an absolute path.

versions/16.0/odoo.conf (1)

2-3: Verify active paths match container mounts
The addons_path is set to /mnt/extra-addons and data_dir to /var/lib/odoo. Ensure these align with the volume mounts in docker-compose.yml (${CUSTOM_ADDONS}:/mnt/extra-addons and ${FILE_PATH}:/var/lib/odoo). Any mismatch will cause Odoo to use empty directories.

entrypoint.sh (1)

12-15: Confirm configuration file paths
ORIGINAL_CONFIG is set to /etc/odoo/odoo.conf and MODIFIED_CONFIG to /var/lib/odoo/odoo.conf. Verify that your Dockerfile and compose mounts place the config at /etc/odoo/odoo.conf so this script reads the correct source file.

versions/16.0/Dockerfile (3)

69-73: Environment variable syntax is correct
Using ENV ODOO_VERSION=16.0 and ARG ODOO_RELEASE=20250204 updates the build to a specific, reproducible release. This aligns with best practices for deterministic builds.


94-94: Ensure ODOO_RC matches config file location
ENV ODOO_RC=/etc/odoo/odoo.conf must point to the copied config in the first stage. Confirm that the COPY ./odoo.conf /etc/odoo/ command places the file in that exact path.


139-140: Remove or sync commented requirement file
The adhoc-aeroo_reports.txt install is commented out but the file still exists under versions/16.0/requirements. Remove the unused file or uncomment the install to keep requirements in sync.

@@ -0,0 +1,6 @@
# use this genshi version to fix error when, for eg, you send arguments like "date=True" check this https://genshi.edgewall.org/ticket/600
git+https://github.com/edgewall/genshi@stable/0.7.x
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Pin dependencies to immutable references: Referencing branches like stable/0.7.x or master-fix-ods can lead to non‑reproducible builds as those branches evolve. Please pin each git+https://... URL to a specific commit SHA or release tag.

Also applies to: 5-6

@@ -1,9 +1,9 @@
#!/usr/bin/env bash
sd build --rm=true -t gauchocode/odoo-gc:16.0 ./
sd build --rm=true -t jobiols/odoo-jeo:16.0 ./
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify that the 'sd' command is available in all environments

The Docker image name has been updated from what was likely 'gauchocode/odoo-gc:16.0' to 'jobiols/odoo-jeo:16.0'. Note that this script uses a non-standard 'sd' command which appears to be an alias for Docker commands. Ensure this command is properly defined in all environments where this script will run.


🏁 Script executed:

#!/bin/bash
# Check if 'sd' command exists and what it resolves to
if command -v sd &> /dev/null; then
    echo "sd command found"
    type sd
else
    echo "sd command NOT found - this script will fail"
fi

Length of output: 114


Use standard Docker CLI instead of non‑standard ‘sd’ alias
Our CI and dev environments don’t have an sd command defined, so this script will fail. Please update the build invocation or ensure the alias/binary is installed everywhere.

• File: versions/16.0/make.sh, line 2
• Replace the non‑existent sd call with docker (or install/configure sd globally):

- sd build --rm=true -t jobiols/odoo-jeo:16.0 ./
+ docker build --rm=true -t jobiols/odoo-jeo:16.0 ./

If you prefer to keep sd, add documentation or a bootstrap step to install/define it in all target environments.

Comment on lines +11 to +13
MODULES_FILE="modulos.txt"
ADDONS_DIR=$CUSTOM_ADDONS

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Validate CUSTOM_ADDONS before use
The script uses ADDONS_DIR=$CUSTOM_ADDONS but never checks if CUSTOM_ADDONS is set. If it's undefined or empty, mkdir -p will target the wrong directory. Add a guard to exit if CUSTOM_ADDONS is not defined.

Comment on lines +67 to +71
NEW_ADDONS_PATH="$ADDONS_PATH,$(IFS=,; echo "${EXTRA_PATHS[*]}")"

# Reemplazar en el archivo copiado o existente
sed -i "s|^addons_path\s*=.*|addons_path = $NEW_ADDONS_PATH|" "$MODIFIED_CONFIG"

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Escape paths when updating addons_path
Using unescaped $NEW_ADDONS_PATH in sed may break if any path contains / or special characters. Quote and escape the variable properly to avoid sed syntax errors.

Comment on lines +109 to 112
LABEL maintainer="Jorge Obiols <jorge.obiols@gmail.com>"

USER root

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add non-root user context in second stage
The second stage switches to USER root but never reverts to a non-root user before shipping the final image. To follow the principle of least privilege, add USER odoo at the end of the second stage.

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: 5

🧹 Nitpick comments (9)
clean_db.sh (4)

13-17: Validate required environment variables
Lines 13–17 simply reassign each variable to itself. Instead, check that each is non-empty and error out if missing:

: "${PG_DB:?Need to set PG_DB in .env}"
: "${PG_USER:?Need to set PG_USER in .env}"
: "${PG_CONTAINER_NAME:?Need to set PG_CONTAINER_NAME in .env}"
: "${ODOO_CONTAINER_NAME:?Need to set ODOO_CONTAINER_NAME in .env}"
: "${PG_PASSWORD:?Need to set PG_PASSWORD in .env}"

23-36: Fail on first SQL error in psql
By default psql continues on error. Add -v ON_ERROR_STOP=1 so the script aborts if any SQL statement fails:

-docker exec -i "$PG_CONTAINER_NAME" psql -U "$PG_USER" -d "$PG_DB" -c "$SQL" 
+docker exec -i "$PG_CONTAINER_NAME" psql -v ON_ERROR_STOP=1 -U "$PG_USER" -d "$PG_DB" -c "$SQL"

41-42: Quote the SQL string to preserve formatting
Enclose the -c argument in single quotes to ensure the multi-line $SQL is passed intact:

-docker exec -i "$PG_CONTAINER_NAME" psql -U "$PG_USER" -d "$PG_DB" -c "$SQL"
+docker exec -i "$PG_CONTAINER_NAME" psql -U "$PG_USER" -d "$PG_DB" -c "$SQL"

Make sure the variable expansion is quoted in the calling context (e.g., bash -c "psql ... -c \"$SQL\"").


44-49: Simplify exit code check
Rather than invoking docker exec then testing $?, wrap the command directly in the if statement:

-if [ $? -eq 0 ]; then
-    echo "✅ Cambios aplicados exitosamente en '$PG_DB'"
-else
-    echo "❌ Error al aplicar los cambios en la base de datos."
-    exit 1
-fi
+if docker exec -i "$PG_CONTAINER_NAME" psql -v ON_ERROR_STOP=1 -U "$PG_USER" -d "$PG_DB" -c "$SQL"; then
+    echo "✅ Cambios aplicados exitosamente en '$PG_DB'"
+else
+    echo "❌ Error al aplicar los cambios en la base de datos."
+    exit 1
+fi
backup_restore.sh (5)

13-20: Validate critical environment variables
Lines 13–20 assign values to variables but do not check for emptiness. Add guard clauses:

: "${PROD_URL:?Need to set PROD_URL in .env}"
: "${PROD_MASTER_KEY:?Need to set PROD_MASTER_KEY in .env}"
: "${PG_DB:?Need to set PG_DB in .env}"
ODOO_PORT="${ODOO_PORT:-8069}"

This ensures the script fails fast if a required variable is missing.


24-33: Simplify and harden connectivity check
Use curl --fail to avoid grep and directly detect non-2xx status:

-if curl -k -L -s --head --request GET "$URL/web/database/manager" | grep "200 OK" > /dev/null; then
+if curl --fail -k -L -s "$URL/web/database/manager" > /dev/null; then
     echo "✅ Conexión exitosa a $URL"
 else

This avoids dependencies on response text and fails on any HTTP error.


38-53: Quote curl payload values and add --fail
Wrap -d and -F values in quotes to prevent word splitting, and add --fail to catch HTTP errors:

-curl -k -L -X POST "https://$PROD_URL/web/database/backup" \
+curl --fail -k -L -X POST "https://$PROD_URL/web/database/backup" \
     -d "master_pwd=$PROD_MASTER_KEY" \
     -d "name=$PG_DB" \
     -d "backup_format=zip" \
     --output "$BACKUP_FILE"

58-65: Quote and --fail for drop operation
Apply the same pattern to the drop request:

-curl -k -L -X POST "$LOCAL_URL/web/database/drop" \
+curl --fail -k -L -X POST "$LOCAL_URL/web/database/drop" \
     -d "master_pwd=$PROD_MASTER_KEY" \
     -d "name=$PG_DB" \
     -d "drop=true"

70-85: Quote and --fail for restore operation
Ensure proper quoting and add --fail:

-curl -k -L -X POST "$LOCAL_URL/web/database/restore" \
+curl --fail -k -L -X POST "$LOCAL_URL/web/database/restore" \
     -F "master_pwd=$PROD_MASTER_KEY" \
     -F "name=$PG_DB" \
     -F "backup_file=@$BACKUP_FILE" \
     -F "copy=true"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a1662ee and 1bfa229.

📒 Files selected for processing (3)
  • backup_restore.sh (1 hunks)
  • clean_db.sh (1 hunks)
  • env.example (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • env.example
🧰 Additional context used
🪛 Shellcheck (0.10.0)
clean_db.sh

[warning] 7-7: Quote this to prevent word splitting.

(SC2046)

backup_restore.sh

[warning] 7-7: Quote this to prevent word splitting.

(SC2046)

Comment on lines +1 to +2
#!/bin/bash

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enable strict shell error handling
Add set -euo pipefail after the shebang to fail fast on errors, undefined variables, and pipeline issues:

 #!/bin/bash
+set -euo pipefail
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/bash
#!/bin/bash
set -euo pipefail

Comment on lines +6 to +11
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
else
echo "❌ Archivo .env no encontrado."
exit 1
fi
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Load .env more safely
Using export $(grep … | xargs) can break on spaces or special characters (SC2046). Instead, turn on automatic export and source the file:

-if [ -f .env ]; then
-    export $(grep -v '^#' .env | xargs)
-else
-    echo "❌ Archivo .env no encontrado."
-    exit 1
-fi
+if [ ! -f .env ]; then
+    echo "❌ Archivo .env no encontrado."
+    exit 1
+fi
+set -o allexport
+source .env
+set +o allexport
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
else
echo "❌ Archivo .env no encontrado."
exit 1
fi
if [ ! -f .env ]; then
echo "❌ Archivo .env no encontrado."
exit 1
fi
set -o allexport
source .env
set +o allexport
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 7-7: Quote this to prevent word splitting.

(SC2046)

Comment on lines +1 to +2
#!/bin/bash

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enable strict shell error handling
Add set -euo pipefail immediately after the shebang to catch errors early:

 #!/bin/bash
+set -euo pipefail

Comment on lines +6 to +11
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
else
echo "❌ Archivo .env no encontrado."
exit 1
fi
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Load .env robustly
Replace export $(grep … | xargs) with set -o allexport and source to avoid word-splitting issues:

-if [ -f .env ]; then
-    export $(grep -v '^#' .env | xargs)
-else
-    echo "❌ Archivo .env no encontrado."
-    exit 1
-fi
+if [ ! -f .env ]; then
+    echo "❌ Archivo .env no encontrado."
+    exit 1
+fi
+set -o allexport
+source .env
+set +o allexport
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
else
echo "❌ Archivo .env no encontrado."
exit 1
fi
if [ ! -f .env ]; then
echo "❌ Archivo .env no encontrado."
exit 1
fi
set -o allexport
source .env
set +o allexport
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 7-7: Quote this to prevent word splitting.

(SC2046)

Comment on lines +96 to +102
# ========================
# EJECUCIÓN COMPLETA
# ========================
limpiar_backup
backup_odoo
drop_local_db
restore_local
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Move cleanup to end of workflow
Currently limpiar_backup runs before backup, leaving the ZIP after restore. Swap its invocation to after restore_local:

-# EJECUCIÓN COMPLETA
-limpiar_backup
-backup_odoo
-drop_local_db
-restore_local
+# EJECUCIÓN COMPLETA
+backup_odoo
+drop_local_db
+restore_local
+limpiar_backup

This ensures temporary files are removed only after successful restore.

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: 1

🧹 Nitpick comments (2)
docker-compose.yml (2)

1-3: Remove trailing whitespace and enhance network config
Line 3 contains trailing spaces flagged by YAML lint. Additionally, consider specifying a network driver (e.g., bridge) or other settings to make the odoo network explicit and self-documenting.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 3-3: trailing spaces

(trailing-spaces)


31-40: Consider named volumes for stateful data and logs
Binding host paths directly (${DATA_PATH}, ${LOG_PATH}, etc.) can introduce portability and permission issues. Defining named volumes under a top-level volumes: block (e.g., odoo-data:/opt/odoo/data) or using Docker managed volumes can simplify management and avoid host-level permission mismatches.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1bfa229 and bc6955e.

📒 Files selected for processing (2)
  • docker-compose.yml (1 hunks)
  • env.example (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • env.example
🧰 Additional context used
🪛 YAMLlint (1.35.1)
docker-compose.yml

[error] 3-3: trailing spaces

(trailing-spaces)

🔇 Additional comments (2)
docker-compose.yml (2)

21-30: Verify build context and entrypoint script availability
The build: versions/16.0/. path and entrypoint: ["/scripts/entrypoint.sh"] rely on the host’s directory structure. Ensure that:

  • versions/16.0/ exists relative to this compose file.
  • ./entrypoint.sh is present and executable.
    A missing or mislocated file will cause the service to fail at startup.

41-49: Align environment variables with Odoo’s expectations
Double-check that the environment variable names (HOST, CUSTOM_ADDONS, MAIN_MODULE, POSTGRES_*) match what your entrypoint.sh and Odoo actually use. For instance, the official Odoo image expects DB_HOST, DB_USER, and DB_PASSWORD. Misalignment could lead to silent failures or fallback to defaults.

Comment on lines +5 to +19
postgres:
#container_name: ${PG_CONTAINER_NAME}
image: ${PG_IMAGE}:${PG_VERSION}
user: root
environment:
- POSTGRES_DB=${PG_DB}
- POSTGRES_USER=${PG_USER}
- POSTGRES_PASSWORD=${PG_PASSWORD}
- PGDATA=/var/lib/postgresql/data/pgdata
ports:
- ${PG_PORT}:5432
volumes:
- ${PG_PATH}:/var/lib/postgresql/data
networks:
- odoo
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid running PostgreSQL container as root
Running the database service with user: root elevates privileges unnecessarily and can be a security risk. Unless there is a strong reason, drop the user: root line to use the container’s default postgres user.
Also, the image: ${PG_IMAGE}:${PG_VERSION} entry will fail if those environment variables are unset. Consider adding default values in an .env file or using Compose’s env_file directive to guarantee required variables.

🤖 Prompt for AI Agents (early access)
In docker-compose.yml lines 5 to 19, remove the line setting `user: root` to avoid running the PostgreSQL container with elevated privileges and rely on the default postgres user for security. Additionally, ensure that the environment variables used in the image tag (`${PG_IMAGE}` and `${PG_VERSION}`) have default values by adding them to an `.env` file or by using the `env_file` directive in the Compose configuration to prevent failures when these variables are unset.

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