Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use odoo:17 image in devcontainer? #508

Open
mojmirdurik opened this issue Jul 3, 2024 · 4 comments
Open

How to use odoo:17 image in devcontainer? #508

mojmirdurik opened this issue Jul 3, 2024 · 4 comments

Comments

@mojmirdurik
Copy link

mojmirdurik commented Jul 3, 2024

I am trying to create a devcontainer for the development of custom Odoo modules. This devcontainer is based on the official odoo:17 image. You can see the current state of my devcontainer in my-odoo-project.zip. I would like to ask the following questions:

  • It took me a few days of effort to discover that I needed to add a new user with UID/GID 1000 in the odoo:17 image to make the devcontainer work with this image. See the creation of the developer user in .devcontainer/Dockerfile.fajnodoo17 and the "remoteUser" in .devcontainer/devcontainer.json. Here are my questions:

    • Is creating a user with UID/GID 1000 the only solution, or is there a more straightforward alternative?
    • If user creation is the correct approach, is it possible to pre-create such a devcontainer-friendly user in the Docker image to make it easily usable for a devcontainer creation? Or at least, is it possible to add a section "How to use this image in a devcontainer" in the odoo:17 image overview describing how to extend the image by user creation?
  • How can I map the installed Odoo modules (applications) to my devcontainer? Where are they located in the odoo:17 image?

  • How can I run odoo-bin command in the devcontainer (or Docker container)?

  • Do you have any other recommendations on how to correctly use the odoo:17 image in a devcontainer for development? Would it be possible to include these recommendations in the odoo:17 image overview?

@teguhteja
Copy link

@mojmirdurik I have made a tutorial about this.
https://teguhteja.id/debug-odoo-17-in-docker-using-vscode/

Hopefully this can help your problem
If you feel this is enough then we can close this issue

@mojmirdurik
Copy link
Author

@teguhteja Thank you for the tutorial. To make it functional out of the box, I have made the following changes:

  • I have added [options] at the beginning of the odoo.conf file.
  • I have corrected the POSTGRES_USER and POSTGRES_PASSWORD in docker-compose.yaml to match the values provided in odoo.conf. Additionally, I have added the HOST, USE, and PASSWORD environment variables to the odoo service (see Odoo Docker Hub page > "Docker Compose examples").
    • You might want to change (or remove) the ports mapping - '5432:5432' in the db service to avoid conflicts with a local installation of Postgres.

Your tutorial allows developing Odoo custom modules without installing Odoo locally. However, the proposed approach differs from the devcontainer approach because the IDE (VS Code) does not see the Odoo environment. This means that if I have not installed Python locally or if I want to use some Python packages installed by requirements.txt inside the odoodev:17.0 image, the IDE will show errors for unknown packages. Am I wrong? I am new to Python & Odoo, so please correct me if I am mistaken.

What I need is for the IDE to run inside the Odoo Docker container. That is exactly what devcontainers are designed for.

How do you share the same Odoo development environment among all team members?

@teguhteja
Copy link

teguhteja commented Jul 25, 2024

Hi @mojmirdurik

I am happy with the advice you give to me. I'll change that on my github. I will try some of the things above
I am going answer your question :

  1. the IDE (VS Code) does not see the Odoo environment

yes this correct

  1. This means that if I have not installed Python locally or if I want to use some Python packages installed by requirements.txt inside the odoodev:17.0 image, the IDE will show errors for unknown packages. Am I wrong? I am new to Python & Odoo, so please correct me if I am mistaken.

Yes, you are right. there will likely be errors. but why do you need python or python packages?

  1. What I need is for the IDE to run inside the Odoo Docker container. That is exactly what devcontainers are designed for.

In the past, I created an Ubuntu container containing odoo and postgresql (this is bad practice) and this could run the devcontainer. but this takes up a lot of resources and a large container size. I'll try to research it with the existing vscode devcontainer tutorial + docker odoo tutorial. Hopefully you can run devcontainer with the approach you need.

  1. How do you share the same Odoo development environment among all team members?

My previous company used VMware + Ubuntu inside Odoo because the standard OS was Windows and shared virtual disks. I tried to give docker advice but this approach requires a long learning time. Currently I am working alone and holding many versions of the Odoo project in use, so the approach in this tutorial is quite easy for me to work with.

  1. How can I run odoo-bin command in the devcontainer (or Docker container)?

you can run odoo and check odoo --version

@teguhteja
Copy link

Hi @mojmirdurik

it seems like this devcontainer method is quite specialized and not many people use it for odoo + devcontainer.

i tried to find some tutorials but instead found some of these repos. maybe you can ask your question there.

and thank you for your explanation. i learned a lot from there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants