Skip to content

Commit

Permalink
Make odoo build separate action
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusAhlfors committed Oct 17, 2023
1 parent 55c4418 commit c78e9c4
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 5 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/Odoo16ArmBuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ name: Odoo16ArmBuild

#
# Since Odoo doesnt' provide an Arm build we need to do one ourselves
#
# NOTE! This is triggered with odoo-v0.0.1 style tag so we don't always
# do this

on:
push:
#tags:
# - 'odoo*'
tags:
- 'odoo-*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: diploi/odoo16-arm

jobs:
build:
runs-on: ubuntu-latest
runs-on: buildjet-8vcpu-ubuntu-2204-arm
permissions:
contents: read
packages: write
Expand Down
49 changes: 49 additions & 0 deletions Odoo16Docker/entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

set -e

if [ -v PASSWORD_FILE ]; then
PASSWORD="$(< $PASSWORD_FILE)"
fi

# set the postgres database host, port, user and password according to the environment
# and pass them as arguments to the odoo process if not present in the config file
: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}}
: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}}
: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}}
: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}}

DB_ARGS=()
function check_config() {
param="$1"
value="$2"
if grep -q -E "^\s*\b${param}\b\s*=" "$ODOO_RC" ; then
value=$(grep -E "^\s*\b${param}\b\s*=" "$ODOO_RC" |cut -d " " -f3|sed 's/["\n\r]//g')
fi;
DB_ARGS+=("--${param}")
DB_ARGS+=("${value}")
}
check_config "db_host" "$HOST"
check_config "db_port" "$PORT"
check_config "db_user" "$USER"
check_config "db_password" "$PASSWORD"

case "$1" in
-- | odoo)
shift
if [[ "$1" == "scaffold" ]] ; then
exec odoo "$@"
else
wait-for-psql.py ${DB_ARGS[@]} --timeout=30
exec odoo "$@" "${DB_ARGS[@]}"
fi
;;
-*)
wait-for-psql.py ${DB_ARGS[@]} --timeout=30
exec odoo "$@" "${DB_ARGS[@]}"
;;
*)
exec "$@"
esac

exit 1
37 changes: 37 additions & 0 deletions Odoo16Docker/odoo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[options]
addons_path = /mnt/extra-addons
data_dir = /var/lib/odoo
; admin_passwd = admin
; csv_internal_sep = ,
; db_maxconn = 64
; db_name = False
; db_template = template1
; dbfilter = .*
; debug_mode = False
; email_from = False
; limit_memory_hard = 2684354560
; limit_memory_soft = 2147483648
; limit_request = 8192
; limit_time_cpu = 60
; limit_time_real = 120
; list_db = True
; log_db = False
; log_handler = [':INFO']
; log_level = info
; logfile = None
; longpolling_port = 8072
; max_cron_threads = 2
; osv_memory_age_limit = 1.0
; osv_memory_count_limit = False
; smtp_password = False
; smtp_port = 25
; smtp_server = localhost
; smtp_ssl = False
; smtp_user = False
; workers = 0
; xmlrpc = True
; xmlrpc_interface =
; xmlrpc_port = 8069
; xmlrpcs = True
; xmlrpcs_interface =
; xmlrpcs_port = 8071
33 changes: 32 additions & 1 deletion Odoo16Docker/wait-for-psql.py
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
p
#!/usr/bin/env python3
import argparse
import psycopg2
import sys
import time


if __name__ == '__main__':
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--db_host', required=True)
arg_parser.add_argument('--db_port', required=True)
arg_parser.add_argument('--db_user', required=True)
arg_parser.add_argument('--db_password', required=True)
arg_parser.add_argument('--timeout', type=int, default=5)

args = arg_parser.parse_args()

start_time = time.time()
while (time.time() - start_time) < args.timeout:
try:
conn = psycopg2.connect(user=args.db_user, host=args.db_host, port=args.db_port, password=args.db_password, dbname='postgres')
error = ''
break
except psycopg2.OperationalError as e:
error = e
else:
conn.close()
time.sleep(1)

if error:
print("Database connection failure: %s" % error, file=sys.stderr)
sys.exit(1)

0 comments on commit c78e9c4

Please sign in to comment.