Giter Site home page Giter Site logo

odoocker / odoocker Goto Github PK

View Code? Open in Web Editor NEW
56.0 6.0 22.0 144 KB

A game-changer in the world of Odoo Development and Deployment.

Dockerfile 19.99% Python 10.55% Shell 69.46%
docker odoo acme-companion keydb minio nginx nginx-proxy pgadmin4 redis s3

odoocker's Introduction

Odoocker: The Ultimate Odoo Docker Framework

Welcome to Odoocker, a game-changer in the world of Odoo Development and Deployment. This tool is meticulously crafted to revolutionize your experience with Odoo, ensuring simplicity, efficiency, and a top-tier development journey. And while it’s rooted in the principles of the Official Odoo Docker setup, it goes several steps beyond.

Whether you're using the Community or Enterprise edition, this Docker solution is tailored just for you.

Best part of this? You don't need any prior knowledge of Docker, Odoo or any technology that involves this Framework. We stick to Docker philosophy: Use it, then learn about it.

Feel free to post a Pull Request to continue enhancing this project.

Why Odoocker Stands Out:

  1. 🌐 Universal: Suitable for both Odoo Community and Enterprise editions.
  2. 📦 Easy Setup: Clone, configure .env file, and you're ready to deploy.
  3. 🔒 Secure: Automatic SSL certificate renewal to keep your data safe (for production only).

In essence, Odoocker isn't just another tool, it's a philosophy. So, whether you’re a seasoned Odoo veteran or just starting your journey, Odoocker is here to make your journey easier.

Contents

Quick Setup Guide:

  1. Clone and Configure:
git clone [email protected]:odoocker/odoocker.git
cp .env.example .env && cp docker-compose.override.local.yml docker-compose.override.yml
  1. Hosts & Domains: To ensure everything runs smoothly, remember to add the necessary domains to your hosts file.

For Unix:

echo '127.0.0.1 erp.odoocker.test' | sudo tee -a /etc/hosts
echo '127.0.0.1 pgadmin.odoocker.test' | sudo tee -a /etc/hosts

For Windows, manually add these lines to C:\Windows\System32\drivers\etc\hosts:

127.0.0.1 erp.odoocker.test
127.0.0.1 pgadmin.odoocker.test

The .env File

The environment variables located in .env provide dynamic configurations to Odoo and the project in general. The odoo.conf file is generated by the odoorc.sh script based on the environment variables.
This file is divided in sections, you most likely are going to focus on the Main Configuration section. This provides quick access to project and odoo.conf variables. The rest of section are container specific variables for different container. (Note: you may find repeated variables like SUPPORT_EMAIL=${SUPPORT_EMAIL} which interacts with different containers. This is to explicitly denote in the .env file that this variable is being shared through those containers.

Sample .env file:

# Odoo
APP_ENV=debug
INIT=
UPDATE=my_custom_addon
LOAD=base,web
WORKERS=2
DEV_MODE=reload,qweb
DOMAIN=erp.odoocker.test

# Enterprise (GitHub User with access to Odoo Enterprise [https://github.com/odoo/enterprise] Repo)
# If not present, Odoo Community will be brought up.
GITHUB_USER=odoocker
GITHUB_ACCESS_TOKEN=ghp_token

# Database
ADMIN_PASSWD=odoo
DB_HOST=postgres (container or external host)
DB_PORT=5432
DB_NAME=my-odoo-db
DB_USER=odoo
DB_PASSWORD=odoo
LOAD_LANGUAGE=es_MX
...

Environment-based actions:

odoo/entrypoint.sh file is the gateway for our Odoo container. Depending on the APP_ENV and the rest of the environment variables, it determines how to start the Odoo service (like local, testing, production, etc.) with different configurations.
In all environments, odoo.conf follows the .env file variables. Some environments may have command-line parameter to overwrite certain configurations.

To bring up all the environments run:

docker-compose up -d --build && docker-compose logs odoo

Restart adding down:

docker-compose down && docker-compose up -d --build && docker-compose logs odoo

1. Fresh or Restore

These environments (APP_ENV=fresh or APP_ENV=restore) will have no database created. Are perfect for setting up a fresh database instance or restoring a production database.

2. Local:

This environment (APP_ENV=local) will strictly follow the .env variables with no command-line overwrites. You'll most likely be using this regularly. Use DEV_MODE=reload,qweb to activate hot reload when changing python and xml files.
If you prefer to update the packages everytime you restart Odoo container, you can set UPDATE=module1,module2,module3.

3. Debug:

This environment (APP_ENV=debug) works same way as local, but it starts Odoo using the debugpy library. Thanks to our .vscode/launch.json, if you are using Visual Studio Code, you can start a Debugger session so the container is aware of your breakpoints and stop wherever you need. This is my favorite environment to work since I use the debugger a lot while developing.

4. Testing:

This environment (APP_ENV=testing) is specific for running tests (and will be included in a CI/CD pipeline in a future version). It help us test the modules we are developing to ensure a safe deployment.
A test_DB_NAME database is automagically created. The ADDONS_TO_TEST=addon_1 are installed in that fresh DB. Use TEST_TAGS=test_tag_1 to filter your tests.

NOTE: Avoid running tests without tags; otherwise, it will trigger tests in all installed addons and we don't want this. For now, let's assume Odoo Community & Enterprise tests passed and only focus on the things you need to test.

5. Full:

This environment (APP_ENV=full) will install the INIT modules in a new or existing DB_NAME. It allows us to have a fresh production database replica.

6. Staging:

This environment (APP_ENV=staging) sets UPDATE=all; it allows us to update all installed addons at once.
It also allows to install new packages before the upgrade through INIT.
It's highly recommended to use this command to run this environment

docker-compose down && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo

This will pull the latest Odoo Community, Enterprise, Extra and Custom addons, basically, it upgrades the whole Odoo instance to the newest. Additionally, it will also pull the latest images of the other containers in this project. This environment is perfect for deployments.

NOTE: Do not bring down & up again, unless you want to perform a whole upgrade again.

7. Production:

This environment (APP_ENV=production) ensures no demo data is loaded, debugging and dev_mode are turned off. It also brings up the Let's Encrypt container, so you won't worry about SSL Certificates anymore! Some .env variables are overwritten in this setup.

  • Take down previous setup of containers
docker-compose down
  • Replace the docker-compose.override.yml with docker-compose.override.production.yml to bring Let's Encrypt container.
cp docker-compose.override.production.yml docker-compose.override.yml
  • Make sure the DNS record of your DOMAIN is pointing to your server.
  • Rebuild the containers
docker-compose up -d --build && docker-compose logs odoo

Pro(d) Tips

The following tips will enhance your developing and production experience.

1. Search through all Addons at once:

If you are using Visual Studio Code & the Docker Extension is installed, you can open the Odoo Container in the ROOT_PATH. There you will find all Odoo Community Addons, Enterprise Addons, Extra Addons and Custom Addons in the same folder level.
Using the Search Panel will allow you to look at every single reference of what you are looking for in the whole Odoo Instance and not just in your addons.

2. Define the following aliases:

alias odoo='cd odoocker'

alias hard-deploy='docker-compose down && git pull && docker-compose pull && docker-compose build --no-cache && docker-compose up -d && docker-compose logs -f odoo'

alias deploy='docker-compose down && git pull && docker-compose up -d --build && docker-compose logs -f --tail 2000 odoo'

alias logs='docker-compose logs -f --tail 2000 odoo'

3. NEVER run docker-compose down -v in Production

...without having a tested backed up database
Have in mind that dropping volumes will destroy DB data, Odoo Conf & Filestore, Let's Encrypt certificates, and more! If you execute this command several times in prod in a short period of time, you may reach the `Let's Encrypt certificates limit`` and Odoocker won't be able to generate new ones after several hours.

4. Odoo Shell

  1. Log into the odoo container
docker-compose exec odoo bash
  1. Start Odoo shell running:
odoo shell --http-port=8071

5. Odoo Scaffold

  1. Log into the odoo container
docker-compose exec -u root odoo
  1. Navigate to custom addons folder inside the container
cd /usr/lib/python3/dist-packages/odoo/custom-addons
  1. Create new addons running:
odoo scaffold <addon_name>
  • The new addon will be available in the odoo/custom_addons folder in this project.

6. Colorize your branches

Add the following to ~/.bashrc

# Color git branches
function parse_git_branch () {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

if [ "$color_prompt" = yes ]; then
    #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    # Color git branches
    PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \[\033[01;31m\]\$(parse_git_branch)\[\033[00m\]\$ "
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

DB Connection

  • Any other Postgres Database Manager can connect to the DB using the .env credentials.

PgAdmin

  • This project comes with a PgAdmin container which is loaded only in docker-compose.override.pgadmin.yml. In order to manage DB we provide a pgAdmin container. In order to bring this up, simply run:
docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.pgadmin.yml up -d --build

And to turn down

docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.pgadmin.yml down

If your instance has pgAdmin, make sure you adapt your aliases to this configuration.

Deployment Process

Note: the deployment process is easier & faster with aliases.

  1. Backup the production Databases from /web/database/manager.
  2. Run
sudo apt update && sudo apt upgrade -y
  • If packages are kept, install them
sudo apt install <kept packages>
  1. Restart the server
sudo reboot
  • Make sure there are no more upgrades or possible kept packages
sudo apt update && sudo apt upgrade -y
  1. Go to the project folder in /home/ubuntu or (~)
cd ~/odoocker

or with alias:

odoo
  1. Pull the latest main branch changes.
git pull origin main
  1. Set Staging environment
  2. Set Production environment

Footnote

This project is based on the Official Odoo Docker image. We've strived to ensure a seamless integration with the original Docker setup while making necessary customizations to suit our requirements. We encourage contributors and users to frequently refer to the official documentation for foundational concepts and updates. Thank you for your continued support and trust in our project.

odoocker's People

Contributors

codeagencybe avatar yhaelopez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

odoocker's Issues

Couple suggestions

I wrote down a couple of things that can be changed/mentioned. These are just suggestions:

  • I'm a big fan of pinning dependencies in requirements.txt. It's a ticking timebomb if they are defined without any version. The downside is of course updating them later.
  • In the readme, you can shorted the shell execution into 1 line: docker-compose exec odoo sh -c "odoo shell --http-port=8071"
  • It might make sense to set the environment ODOO_STAGE too. This is the variable that odoo.sh uses to determine if the environment is dev/test, staging or production. If we are developing a module that uses this locally, it would be good to already have that set.

[ODOO17] Couldn't bind the websocket. Is the connection opened on the evented port (8072)?

I'm trying to make this work with Odoo 17 but I'm getting this error:

odoo_1         | Traceback (most recent call last):
odoo_1         |   File "/usr/lib/python3/dist-packages/odoo/addons/bus/websocket.py", line 837, in open_connection
odoo_1         |     socket = request.httprequest.environ['socket']
odoo_1         | KeyError: 'socket'
odoo_1         | 
odoo_1         | The above exception was the direct cause of the following exception:
odoo_1         | 
odoo_1         | Traceback (most recent call last):
odoo_1         |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 2157, in __call__
odoo_1         |     response = request._serve_db()
odoo_1         |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 1732, in _serve_db
odoo_1         |     return service_model.retrying(self._serve_ir_http, self.env)
odoo_1         |   File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 133, in retrying
odoo_1         |     result = func()
odoo_1         |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 1759, in _serve_ir_http
odoo_1         |     response = self.dispatcher.dispatch(rule.endpoint, args)
odoo_1         |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 1873, in dispatch
odoo_1         |     return self.request.registry['ir.http']._dispatch(endpoint)
odoo_1         |   File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 207, in _dispatch
odoo_1         |     result = endpoint(**request.params)
odoo_1         |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 722, in route_wrapper
odoo_1         |     result = endpoint(self, *args, **params_ok)
odoo_1         |   File "/usr/lib/python3/dist-packages/odoo/addons/bus/controllers/websocket.py", line 23, in websocket
odoo_1         |     return WebsocketConnectionHandler.open_connection(request)
odoo_1         |   File "/usr/lib/python3/dist-packages/odoo/addons/bus/websocket.py", line 849, in open_connection
odoo_1         |     raise RuntimeError(
odoo_1         | RuntimeError: Couldn't bind the websocket. Is the connection opened on the evented port (8072)?

I tried a few tweaks here and there in the nginx configuration, but nothing is working so far.

Anyone there, who managed to fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.