Preserve odoo-venv for faster startup

This commit is contained in:
Stéphane Bidoul 2021-11-12 00:21:43 +01:00
parent 36f37639b0
commit 7b6ce4f1bd
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92
8 changed files with 31 additions and 17 deletions

View file

@ -23,8 +23,8 @@ spec:
volumeMounts:
- name: runboat-scripts
mountPath: /runboat
- name: odoo-data
mountPath: /opt/odoo-data
- name: data
mountPath: /mnt/data
envFrom:
- secretRef:
name: odoosecretenv
@ -47,6 +47,6 @@ spec:
- name: runboat-scripts
configMap:
name: runboat-scripts
- name: odoo-data
- name: data
persistentVolumeClaim:
claimName: odoo-data
claimName: data

View file

@ -16,8 +16,8 @@ spec:
volumeMounts:
- name: runboat-scripts
mountPath: /runboat
- name: odoo-data
mountPath: /opt/odoo-data
- name: data
mountPath: /mnt/data
envFrom:
- secretRef:
name: odoosecretenv
@ -35,9 +35,9 @@ spec:
- name: runboat-scripts
configMap:
name: runboat-scripts
- name: odoo-data
- name: data
persistentVolumeClaim:
claimName: odoo-data
claimName: data
restartPolicy: Never
backoffLimit: 0
activeDeadlineSeconds: 1200

View file

@ -40,7 +40,7 @@ configMapGenerator:
- name: odooenv
literals:
- PGDATABASE={{ build_name }}
- ADDONS_DIR=/build
- ADDONS_DIR=/mnt/data/odoo-data-dir
- RUNBOAT_GIT_REPO=https://github.com/{{ repo }}
- RUNBOAT_GIT_REF={{ git_commit }}
{%- for key, value in build_env.items() %}
@ -59,7 +59,7 @@ generatorOptions:
patches:
- target:
kind: PersistentVolumeClaim
name: odoo-data
name: data
patch: |-
- op: replace
path: /spec/storageClassName

View file

@ -1,12 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: odoo-data
name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi
storage: 200Mi
limits:
storage: 100Mi
storage: 250Mi

View file

@ -2,6 +2,15 @@
set -ex
DEBIAN_FRONTEND=noninteractive apt-get -yq install rsync
# If it exists, copy the previously initialized venv.
if [ -f /mnt/data/initialized ] ; then
rsync -a --delete /mnt/data/odoo-venv/ /opt/odoo-venv
pip list
exit 0
fi
#
# Clone an addons repository at git reference in $ADDONS_DIR.
# Run oca_install_addons on it.
@ -13,3 +22,8 @@ git fetch origin $RUNBOAT_GIT_REF:build
git checkout build
oca_install_addons
# Keep a copy of the venv that we can re-use for shorter startup time.
rsync -a /opt/odoo-venv/ /mnt/data/odoo-venv
touch /mnt/data/initialized

View file

@ -16,7 +16,7 @@ dropdb --if-exists $PGDATABASE
ADDONS=$(addons --addons-dir ${ADDONS_DIR} --include "${INCLUDE}" --exclude "${EXCLUDE}" list)
unbuffer $(which odoo || which openerp-server) \
--data-dir=/opt/odoo-data \
--data-dir=/mnt/data/odoo-data-dir \
-d ${PGDATABASE} \
-i ${ADDONS:-base} \
--stop-after-init

View file

@ -11,6 +11,6 @@ bash /runboat/runboat-clone-and-install.sh
oca_wait_for_postgres
unbuffer $(which odoo || which openerp-server) \
--data-dir=/opt/odoo-data \
--data-dir=/mnt/data/odoo-data-dir \
--no-database-list \
-d ${PGDATABASE}

View file

@ -34,7 +34,7 @@ configMapGenerator:
- name: odooenv
literals:
- PGDATABASE=build-name
- ADDONS_DIR=/build
- ADDONS_DIR=/mnt/data/odoo-data-dir
- RUNBOAT_GIT_REPO=https://github.com/oca/mis-builder
- RUNBOAT_GIT_REF=abcdef123456789
- name: runboat-scripts
@ -50,7 +50,7 @@ generatorOptions:
patches:
- target:
kind: PersistentVolumeClaim
name: odoo-data
name: data
patch: |-
- op: replace
path: /spec/storageClassName