Skip to content

Commit d8e2cf4

Browse files
committed
Add before-migrate-entrypoint.d
Allow to run script before the migration is run
1 parent 82908cb commit d8e2cf4

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

10.0/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ RUN curl https://github.com/jwilder/dockerize/releases/download/v0.4.0/dockerize
6666
COPY ./src_requirements.txt ./
6767
COPY ./bin bin
6868
COPY ./etc etc
69+
COPY ./before-migrate-entrypoint.d before-migrate-entrypoint.d
6970
COPY ./start-entrypoint.d start-entrypoint.d
7071
COPY ./MANIFEST.in ./
7172

9.0/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ COPY ./src_requirements.txt ./
6767
COPY ./bin bin
6868
COPY ./bin_compat bin_compat
6969
COPY ./etc etc
70+
COPY ./before-migrate-entrypoint.d before-migrate-entrypoint.d
7071
COPY ./start-entrypoint.d start-entrypoint.d
7172
COPY ./MANIFEST.in ./
7273

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ build:
1616
cp -r $(VERSION) $(TMP)
1717
cp -r bin/ $(TMP)
1818
cp -r start-entrypoint.d/ $(TMP)
19+
cp -r before-migrate-entrypoint.d/ $(TMP)
1920
docker build --no-cache -t $(IMAGE_LATEST) $(TMP)
2021
rm -rf $(TMP)
2122

README.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,17 @@ Odoo namespaces (`openerp.addons`/`odoo.addons`) when running the tests.
147147
## Start entrypoint
148148

149149
Any script in any language placed in `/opt/odoo/start-entrypoint.d` will be
150-
executed just between the migration and the start of Odoo. The order of
151-
execution of the files is determined by the `run-parts` 's rules.
150+
executed just between the migration and the start of Odoo.
151+
Similarly, scripts placed in `/opt/odoo/before-migrate-entrypoint.d` will be
152+
executed just before the migration.
152153

153-
The database is guaranteed to exist at this point so you can run queries on it.
154-
The scripts are run only if the command is `odoo`/`odoo.py`.
154+
The order of execution of the files is determined by the `run-parts` 's rules.
155+
You can add your own scripts in those directories. They must be named
156+
something like `010_abc` (`^[a-zA-Z0-9_-]+$`) and must have no extension (or
157+
it would not be picked up by `run-parts`).
158+
159+
Important: The database is guaranteed to exist when `start-entrypoint` are
160+
run, but, it might not exist when `before-migrate-entrypoint` scripts are run,
161+
so you must take that in account when writing them.
155162

156-
You can add your own scripts in this directory. They must be named something
157-
like `010_abc` (`^[a-zA-Z0-9_-]+$`) and must have no extension (or it would not
158-
be picked up by `run-parts`).
163+
The scripts are run only if the command is `odoo`/`odoo.py`.

before-migrate-entrypoint.d/.gitkeep

Whitespace-only changes.

bin/docker-entrypoint.sh

+5
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ fi
103103
BASE_CMD=$(basename $1)
104104
if [ "$BASE_CMD" = "odoo" ] || [ "$BASE_CMD" = "odoo.py" ] ; then
105105

106+
BEFORE_MIGRATE_ENTRYPOINT_DIR=/opt/odoo/before-migrate-entrypoint.d
107+
if [ -d "$BEFORE_MIGRATE_ENTRYPOINT_DIR" ]; then
108+
/bin/run-parts --verbose "$BEFORE_MIGRATE_ENTRYPOINT_DIR"
109+
fi
110+
106111
if [ -z "$MIGRATE" -o "$MIGRATE" = True ]; then
107112
gosu odoo migrate
108113
fi

0 commit comments

Comments
 (0)