-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: main
Are you sure you want to change the base?
Conversation
…emplo de modulos.txt
Script para instalar los modulos declarados en el modulos.txt y un ej…
…adir sus rutas al ADDONS_PATH de odoo
…stalados y los a instalar
…a herramienta para armar ambientes
WalkthroughThis 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 Changes
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
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
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
Poem
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 forPG_IMAGE
,PG_DB
,PG_USER
,PG_PASSWORD
, etc., to guide users in correctly populating these fields.
18-23
: Document custom path variables: Variables likeCUSTOM_ADDONS
,CONF_PATH
,DATA_PATH
, andLOG_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 commentedBASE_DIR_PROD
andBASE_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 @masterUsing
@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 dependenciesSeveral new dependencies have been added, but
unrar
andopenpyxl
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.1Good 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 thepostgres
service to ensure readiness before Odoo attempts to connect. Also verify that thePG_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 commentedodoo_scripts
section
This commented block clutters the compose file. If theodoo_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 abuild
context and have commented out theimage
key. Confirm whether you want to always build locally (recommended for active development) or pull a versioned image. If building, remove the unusedimage
line to keep the configuration clean.
47-55
: Consolidate database environment variables prefix
Instead ofHOST
,POSTGRES_DB
,POSTGRES_USER
,POSTGRES_PASSWORD
, consider using a consistent prefix likeDB_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
InjectingGITLAB_USER
andGITLAB_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, includingdbfilter
,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
: Useset -u
for undefined variable checks
You rely on Bash’s:?
expansion to validate required vars, but addingset -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 port5432
. 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 usingpsql -A -t
and then anawk
orgrep -Fx
loop to parse module names more reliably.versions/16.0/Dockerfile (2)
146-146
: Avoid overly permissive permissions
Usingchmod -R 777
on thepyafipws
package directory is insecure. Restrict permissions to what’s necessary (e.g.,chmod -R 755
or adjust group ownership).
150-150
: Weakened OpenSSL security
Patchingopenssl.cnf
to lowerSECLEVEL
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
📒 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: Theaeroolib
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 ofODOO_SCRIPTS_CONTAINER_NAME
andMAIN_MODULE
aren’t immediately clear. Please verify these names reflect the service definitions indocker-compose.yml
and the expectations ofentrypoint.sh
..gitignore (1)
2-10
: Verified ignore patterns for new artifacts: The entries for.env
,addons/
,config/
,datadir/
,log/
,scripts/
,postgresql/
,filestore/
, andmodulos.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 afterexit 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 unnecessaryThe 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 consistentlyThe Docker image name has been correctly updated to match the build command on line 2.
9-9
: Fixed variable reference for exit codeGood 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 functionalityAccording to the AI summary, three dependencies were removed:
gevent
,greenlet
, andwebsockets
. 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.3docker-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 forentrypoint.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
Theaddons_path
is set to/mnt/extra-addons
anddata_dir
to/var/lib/odoo
. Ensure these align with the volume mounts indocker-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
andMODIFIED_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
UsingENV ODOO_VERSION=16.0
andARG ODOO_RELEASE=20250204
updates the build to a specific, reproducible release. This aligns with best practices for deterministic builds.
94-94
: EnsureODOO_RC
matches config file location
ENV ODOO_RC=/etc/odoo/odoo.conf
must point to the copied config in the first stage. Confirm that theCOPY ./odoo.conf /etc/odoo/
command places the file in that exact path.
139-140
: Remove or sync commented requirement file
Theadhoc-aeroo_reports.txt
install is commented out but the file still exists underversions/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 |
There was a problem hiding this comment.
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 ./ |
There was a problem hiding this comment.
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.
MODULES_FILE="modulos.txt" | ||
ADDONS_DIR=$CUSTOM_ADDONS | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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" | ||
|
There was a problem hiding this comment.
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.
LABEL maintainer="Jorge Obiols <jorge.obiols@gmail.com>" | ||
|
||
USER root | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this 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 defaultpsql
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 invokingdocker exec
then testing$?
, wrap the command directly in theif
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 +fibackup_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
Usecurl --fail
to avoidgrep
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" elseThis 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
📒 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)
#!/bin/bash | ||
|
There was a problem hiding this comment.
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.
#!/bin/bash | |
#!/bin/bash | |
set -euo pipefail |
if [ -f .env ]; then | ||
export $(grep -v '^#' .env | xargs) | ||
else | ||
echo "❌ Archivo .env no encontrado." | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
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.
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)
#!/bin/bash | ||
|
There was a problem hiding this comment.
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
if [ -f .env ]; then | ||
export $(grep -v '^#' .env | xargs) | ||
else | ||
echo "❌ Archivo .env no encontrado." | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
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.
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)
# ======================== | ||
# EJECUCIÓN COMPLETA | ||
# ======================== | ||
limpiar_backup | ||
backup_odoo | ||
drop_local_db | ||
restore_local |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this 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 theodoo
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-levelvolumes:
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
📒 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
Thebuild: versions/16.0/.
path andentrypoint: ["/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 yourentrypoint.sh
and Odoo actually use. For instance, the official Odoo image expectsDB_HOST
,DB_USER
, andDB_PASSWORD
. Misalignment could lead to silent failures or fallback to defaults.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Pasamos todo a Main
Summary by CodeRabbit
New Features
Improvements
Style
Chores
.gitignore
to cover more files and directories.