diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..b095016bf --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git +__pycache__ +*.pyc +*.pyo +*.pyd +*.db +*.sqlite3 +*.egg-info +dist +build +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..d0fcf5471 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM odoo:17 + +USER root + +WORKDIR /opt/odoo + +COPY requirements.txt /tmp/requirements.txt +RUN pip3 install --no-cache-dir -r /tmp/requirements.txt + +COPY . /opt/odoo/runbot +COPY runbot_builder /opt/odoo/runbot_builder +COPY scripts /opt/odoo/scripts + +ENV ADDONS_PATH=/usr/lib/python3/dist-packages/odoo/addons,/opt/odoo/runbot + +RUN mkdir -p /var/log/odoo && \ + chmod +x /opt/odoo/scripts/*.sh + +USER odoo + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["odoo"] diff --git a/README.md b/README.md index 11da0dda0..c0eb218bd 100644 --- a/README.md +++ b/README.md @@ -315,3 +315,17 @@ Or by providing a plain Dockerfile in the template. Once the Dockerfile is created and the `to_build` field is checked, the Dockerfile will be built (pay attention that no other operations will occur during the build). A version or a bundle can be assigned a specific Dockerfile. + +## Docker Compose + +For a quick local setup the project can be started using Docker. If the +image is not built yet, run `docker compose build` first and then start +the services with: + +```bash +docker compose up +``` + +This command will start PostgreSQL together with the Runbot, builder and +leader services. Once the initialization is complete the Runbot interface +will be reachable on [http://localhost:8069](http://localhost:8069). diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..47b4d6b06 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,65 @@ +version: '3.8' +services: + db: + image: postgres:15 + environment: + POSTGRES_DB: runbot + POSTGRES_USER: odoo + POSTGRES_PASSWORD: odoo + volumes: + - pgdata:/var/lib/postgresql/data + healthcheck: + test: ["CMD", "pg_isready", "-U", "odoo"] + interval: 5s + timeout: 5s + retries: 5 + restart: unless-stopped + + runbot: + build: . + command: ["/opt/odoo/scripts/runbot.sh"] + depends_on: + db: + condition: service_healthy + ports: + - "8069:8069" + environment: + DB_HOST: db + DB_USER: odoo + DB_PASSWORD: odoo + DB_NAME: runbot + ADDONS_PATH: "/usr/lib/python3/dist-packages/odoo/addons,/opt/odoo/runbot" + restart: unless-stopped + + builder: + build: . + command: ["/opt/odoo/scripts/builder.sh"] + depends_on: + db: + condition: service_healthy + environment: + DB_HOST: db + DB_USER: odoo + DB_PASSWORD: odoo + DB_NAME: runbot + ADDONS_PATH: "/usr/lib/python3/dist-packages/odoo/addons,/opt/odoo/runbot" + FORCED_HOST_NAME: builder + restart: unless-stopped + + leader: + build: . + command: ["/opt/odoo/scripts/leader.sh"] + depends_on: + db: + condition: service_healthy + environment: + DB_HOST: db + DB_USER: odoo + DB_PASSWORD: odoo + DB_NAME: runbot + ADDONS_PATH: "/usr/lib/python3/dist-packages/odoo/addons,/opt/odoo/runbot" + FORCED_HOST_NAME: leader + restart: unless-stopped + +volumes: + pgdata: diff --git a/scripts/builder.sh b/scripts/builder.sh new file mode 100755 index 000000000..7f5dd67ec --- /dev/null +++ b/scripts/builder.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +exec python3 /opt/odoo/runbot_builder/builder.py \ + --odoo-path=/usr/lib/python3/dist-packages/odoo \ + --addons-path=${ADDONS_PATH} \ + -d ${DB_NAME:-runbot} \ + --db_host=${DB_HOST:-db} \ + --db_port=${DB_PORT:-5432} \ + --db_user=${DB_USER:-odoo} \ + --db_password=${DB_PASSWORD:-odoo} \ + --forced-host-name=${FORCED_HOST_NAME:-builder} diff --git a/scripts/leader.sh b/scripts/leader.sh new file mode 100755 index 000000000..e1e1591f2 --- /dev/null +++ b/scripts/leader.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +exec python3 /opt/odoo/runbot_builder/leader.py \ + --odoo-path=/usr/lib/python3/dist-packages/odoo \ + --addons-path=${ADDONS_PATH} \ + -d ${DB_NAME:-runbot} \ + --db_host=${DB_HOST:-db} \ + --db_port=${DB_PORT:-5432} \ + --db_user=${DB_USER:-odoo} \ + --db_password=${DB_PASSWORD:-odoo} \ + --forced-host-name=${FORCED_HOST_NAME:-leader} diff --git a/scripts/runbot.sh b/scripts/runbot.sh new file mode 100755 index 000000000..7eaf735cd --- /dev/null +++ b/scripts/runbot.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e +exec odoo --workers=2 --without-demo=1 --max-cron-threads=1 \ + --addons-path=${ADDONS_PATH} \ + -d ${DB_NAME:-runbot} \ + --db_host=${DB_HOST:-db} \ + --db_port=${DB_PORT:-5432} \ + --db_user=${DB_USER:-odoo} \ + --db_password=${DB_PASSWORD:-odoo}