Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
344 Lượt xem

I want to containerize Odoo on my server by building a custom Docker image directly from the GitHub repository instead of using the official Odoo Docker image. Has anyone done this before? I need guidance on:

  1. Best practices for creating a Dockerfile that clones and sets up Odoo from source.
  2. Handling dependencies (PostgreSQL, Python packages, etc.) properly.
  3. Managing custom addons and configurations in a self-built image.
  4. Any known issues or optimizations for production use.

If you’ve worked on similar projects or know good reference repos (like Doodba, odoocker, or others), please share your approach. Thanks!

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thank you so much for your guidance! I followed your instructions and was able to successfully deploy my custom Odoo Docker setup on my server. Really appreciate your help, it worked perfectly for me!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Subin

Yeah, I’ve done this a few times — building a custom Docker image for Odoo from source is totally doable and actually gives you more control, especially if you’re integrating custom modules or want to avoid the limitations of the official image.

Here’s a breakdown of best practices from real-world use:

Base Image and Dockerfile Setup:

Start with a slim base (like python:3.10-slim) to keep the image clean and efficient. Clone directly from the Odoo GitHub repo:

FROM python:3.10-slim


ENV LANG C.UTF-8


# System deps

RUN apt-get update && apt-get install -y \

    git build-essential libpq-dev libxml2-dev libxslt1-dev \

    libldap2-dev libsasl2-dev libjpeg-dev zlib1g-dev \

    libjpeg-dev libpng-dev liblcms2-dev libblas-dev libatlas-base-dev \

    libffi-dev libssl-dev libevent-dev \

    && apt-get clean


# Create odoo user

RUN useradd -ms /bin/bash odoo


# Clone Odoo

RUN git clone --depth 1 --branch 18.0 https://github.com/odoo/odoo.git /opt/odoo


WORKDIR /opt/odoo


# Install Python dependencies

COPY requirements.txt /opt/odoo/

RUN pip install -r requirements.txt


# Set permissions

RUN chown -R odoo:odoo /opt/odoo

USER odoo


CMD ["python3", "odoo-bin", "-c", "/etc/odoo/odoo.conf"]

Handle Dependencies

  • Use requirements.txt from the Odoo repo or generate it from setup/.
  • Keep PostgreSQL outside the container — either use Docker Compose or an external DB server. Make sure it’s tuned for Odoo (see previous PostgreSQL answer).
  • For wkhtmltopdf, use the static build (especially in production). Install it manually into the image.

Custom Addons & Config

Best practice is to mount custom addons via a volume or include them in the build:

COPY ./custom-addons /mnt/custom-addons

And make sure addons_path in odoo.conf includes:

addons_path = /opt/odoo/addons,/mnt/custom-addons

You can also use ARGs or ENV vars to toggle between dev/prod config files.

Known Gotchas & Optimizations

  • Don’t install too much into your image. Use multistage builds if needed.
  • Always pin the Git branch/tag to avoid weird surprises after future pushes.
  • Use healthchecks in Docker Compose to restart on failures.
  • Consider using PIP caching or building wheels for faster builds in CI/CD.
  • For production, run behind a reverse proxy (like Nginx) and isolate PostgreSQL.

Great Repos to Explore

  • Doodba (by Tecnativa) – very advanced, for serious DevOps. Uses Docker + git submodules + Makefiles + pre-commit hooks.
  • Odoocker (by yelizariev) – simple and clean, especially good for learning the build process.
  • OCA’s docker-odoo-project – community-driven, focused on modular development.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
10151
1
thg 11 22
3471
1
thg 11 20
5592
6
thg 6 20
21757
2
thg 12 24
4171