Skip to content

Commit ff38f9f

Browse files
authored
[ADD] installscript: docker test suite & improvements on scripts
Improve Odoo 19 installer and add Docker test environment
2 parents c3846be + 714461b commit ff38f9f

File tree

4 files changed

+108
-12
lines changed

4 files changed

+108
-12
lines changed

odoo_install.sh

100644100755
Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ LONGPOLLING_PORT="8072"
4444
ENABLE_SSL="True"
4545
# Provide Email to register ssl certificate
4646
ADMIN_EMAIL="[email protected]"
47+
48+
# Helper: pip install with optional --break-system-packages (Ubuntu 24.04 / PEP 668)
49+
pip_install() {
50+
if pip3 help install 2>/dev/null | grep -q -- '--break-system-packages'; then
51+
sudo -H pip3 install --break-system-packages "$@"
52+
else
53+
sudo -H pip3 install "$@"
54+
fi
55+
}
4756
##
4857
### WKHTMLTOPDF download links
4958
## === Ubuntu Trusty x64 & x32 === (for other distributions please replace these two links,
@@ -70,20 +79,32 @@ echo -e "\n---- Update Server ----"
7079
# sudo add-apt-repository universe
7180
# libpng12-0 dependency for wkhtmltopdf for older Ubuntu versions
7281
# sudo add-apt-repository "deb http://mirrors.kernel.org/ubuntu/ xenial main"
73-
sudo apt-get update
82+
sudo apt-get update -y
7483
sudo apt-get upgrade -y
75-
sudo apt-get install libpq-dev
84+
sudo apt-get install -y libpq-dev
7685

7786
#--------------------------------------------------
7887
# Install PostgreSQL Server
7988
#--------------------------------------------------
8089
echo -e "\n---- Install PostgreSQL Server ----"
81-
if [ $$INSTALL_POSTGRESQL_SIXTEEN = "True" ]; then
90+
if [ "$INSTALL_POSTGRESQL_SIXTEEN" = "True" ]; then
8291
echo -e "\n---- Installing postgreSQL V16 due to the user it's choise ----"
8392
sudo curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
8493
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
85-
sudo apt-get update
86-
sudo apt-get install postgresql-16
94+
sudo apt-get update -y
95+
sudo apt-get install -y postgresql-16
96+
if [ "$IS_ENTERPRISE" = "True" ]; then
97+
# Ensure PostgreSQL is running before pgvector setup (Ubuntu 24.04 uses systemd)
98+
sudo systemctl start postgresql || true
99+
# pgvector is only needed for Enterprise AI features
100+
sudo apt-get install -y postgresql-16-pgvector
101+
# Wait for PostgreSQL to become available
102+
until sudo -u postgres pg_isready >/dev/null 2>&1; do sleep 1; done
103+
# Create vector extension using a heredoc to avoid any quoting issues
104+
sudo -u postgres psql -v ON_ERROR_STOP=1 -d template1 <<'SQL'
105+
CREATE EXTENSION IF NOT EXISTS vector;
106+
SQL
107+
fi
87108
else
88109
echo -e "\n---- Installing the default postgreSQL version based on Linux version ----"
89110
sudo apt-get install postgresql postgresql-server-dev-all -y
@@ -97,11 +118,14 @@ sudo su - postgres -c "createuser -s $OE_USER" 2> /dev/null || true
97118
# Install Dependencies
98119
#--------------------------------------------------
99120
echo -e "\n--- Installing Python 3 + pip3 --"
100-
sudo apt-get install python3 python3-pip
121+
sudo apt-get install -y python3 python3-pip
101122
sudo apt-get install git python3-cffi build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less libpng-dev libjpeg-dev gdebi -y
102123

103124
echo -e "\n---- Install python packages/requirements ----"
104-
sudo -H pip3 install -r https://github.com/odoo/odoo/raw/${OE_VERSION}/requirements.txt --break-system-packages
125+
pip_install -r https://github.com/odoo/odoo/raw/${OE_VERSION}/requirements.txt
126+
127+
# Extra: ensure phonenumbers is installed
128+
pip_install phonenumbers
105129

106130
echo -e "\n---- Installing nodeJS NPM and rtlcss for LTR support ----"
107131
sudo apt-get install nodejs npm -y
@@ -110,7 +134,7 @@ sudo npm install -g rtlcss
110134
#--------------------------------------------------
111135
# Install Wkhtmltopdf if needed
112136
#--------------------------------------------------
113-
if [ $INSTALL_WKHTMLTOPDF = "True" ]; then
137+
if [ "$INSTALL_WKHTMLTOPDF" = "True" ]; then
114138
echo -e "\n---- Install wkhtml and place shortcuts on correct place for ODOO 13 ----"
115139
#pick up correct one from x64 & x32 versions:
116140
if [ "`getconf LONG_BIT`" == "64" ];then
@@ -152,7 +176,7 @@ sudo git clone --depth 1 --branch $OE_VERSION https://www.github.com/odoo/odoo $
152176

153177
if [ $IS_ENTERPRISE = "True" ]; then
154178
# Odoo Enterprise install!
155-
sudo pip3 install psycopg2-binary pdfminer.six --break-system-packages
179+
pip_install psycopg2-binary pdfminer.six
156180
sudo su $OE_USER -c "mkdir $OE_HOME/enterprise"
157181
sudo su $OE_USER -c "mkdir $OE_HOME/enterprise/addons"
158182

@@ -169,7 +193,7 @@ if [ $IS_ENTERPRISE = "True" ]; then
169193

170194
echo -e "\n---- Added Enterprise code under $OE_HOME/enterprise/addons ----"
171195
echo -e "\n---- Installing Enterprise specific libraries ----"
172-
sudo -H pip3 install num2words ofxparse dbfread ebaysdk firebase_admin pyOpenSSL --break-system-packages
196+
pip_install num2words ofxparse dbfread ebaysdk firebase_admin pyOpenSSL
173197
sudo npm install -g less
174198
sudo npm install -g less-plugin-clean-css
175199
fi
@@ -296,7 +320,7 @@ sudo update-rc.d $OE_CONFIG defaults
296320
#--------------------------------------------------
297321
if [ $INSTALL_NGINX = "True" ]; then
298322
echo -e "\n---- Installing and setting up Nginx ----"
299-
sudo apt install nginx -y
323+
sudo apt-get install -y nginx
300324
cat <<EOF > ~/odoo
301325
server {
302326
listen 80;
@@ -388,7 +412,7 @@ fi
388412

389413
if [ $INSTALL_NGINX = "True" ] && [ $ENABLE_SSL = "True" ] && [ $ADMIN_EMAIL != "[email protected]" ] && [ $WEBSITE_NAME != "_" ];then
390414
sudo apt-get update -y
391-
sudo apt install snapd -y
415+
sudo apt-get install -y snapd
392416
sudo snap install core; snap refresh core
393417
sudo snap install --classic certbot
394418
sudo apt-get install python3-certbot-nginx -y

test_install/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM ubuntu:24.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
# Install base tools needed by the installer script.
6+
RUN set -eux; \
7+
timezone=$(cat /etc/timezone 2>/dev/null || echo Etc/UTC); \
8+
export TZ="${timezone}"; \
9+
apt-get update; \
10+
apt-get install -y --no-install-recommends \
11+
sudo ca-certificates curl wget gnupg lsb-release locales apt-utils tzdata; \
12+
ln -snf "/usr/share/zoneinfo/${timezone}" /etc/localtime; \
13+
echo "${timezone}" > /etc/timezone; \
14+
sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen; \
15+
locale-gen en_US.UTF-8; \
16+
update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8; \
17+
rm -rf /var/lib/apt/lists/*
18+
19+
# Minimal base; you will run the Odoo script manually inside.
20+
CMD ["sleep", "infinity"]

test_install/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Odoo 19 Installer Test Environment
2+
3+
This folder provides a minimal Docker setup to exercise the `odoo_install.sh` script in a clean Ubuntu 24.04 container.
4+
5+
## Prerequisites
6+
- Docker 24+
7+
- Docker Compose plugin (`docker compose` CLI)
8+
9+
## Build the Image
10+
```bash
11+
docker compose build
12+
```
13+
14+
## Start the Test Container
15+
Run the container detached so it stays online for manual testing:
16+
```bash
17+
docker compose up -d
18+
```
19+
20+
## Run the Installer Script Inside the Container
21+
1. Attach to the container shell:
22+
```bash
23+
docker compose exec odoo19 bash
24+
```
25+
2. Make the script executable (first run only):
26+
```bash
27+
chmod +x /opt/odoo-install/odoo_install.sh
28+
```
29+
3. Execute the installer:
30+
```bash
31+
/opt/odoo-install/odoo_install.sh
32+
```
33+
34+
The script runs as root inside the container, so the bundled `sudo` calls succeed without additional configuration. The Docker image already sets locale and timezone data to avoid interactive prompts from `tzdata`.
35+
36+
## Reset the Environment
37+
To destroy the test container and start fresh:
38+
```bash
39+
docker compose down -v
40+
```
41+
42+
Re-run the **Build** and **Start** steps to begin another test cycle.

test_install/docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
odoo19:
3+
build: .
4+
container_name: odoo19
5+
restart: unless-stopped
6+
command: ["sleep", "infinity"]
7+
tty: true
8+
stdin_open: true
9+
volumes:
10+
- ../odoo_install.sh:/opt/odoo-install/odoo_install.sh:ro

0 commit comments

Comments
 (0)