Skip to content

Commit

Permalink
Update README and configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
kmagusiak committed Jul 7, 2024
1 parent f9a9bda commit 5e7a8ce
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 137 deletions.
25 changes: 14 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,37 @@
"customizations": {
"vscode": {
"settings": {
"editor.insertSpaces": false,
"editor.rulers": [79, 100, 116],
"editor.rulers": [80, 100, 116],
"files.eol": "\n",
"search.followSymlinks": true,
"search.useIgnoreFiles": true,
"terminal.integrated.defaultProfile.linux": "bash",
"python.defaultInterpreterPath": "/usr/bin/python3",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.insertSpaces": true,
"editor.tabSize": 4
},
"black-formatter.args": [
"--skip-string-normalization",
"--line-length",
"100"
],
"python.terminal.activateEnvInCurrentTerminal": true,
// inherited
"python.autoComplete.extraPaths": [
"/opt/odoo/addons",
"/opt/odoo",
"/opt/odoo/odoo/addons",
"/opt/odoo-addons",
"/mnt/extra-addons"
"/odoo-workspace/addons/*"
],
"[javascript]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"files.exclude": {
"**/*__pycache__": true,
"**/.git": true
}
},
"foam.files.ignore": [
"addons/**/*",
"enterprise/**/*",
"**/doc/cla/**/*"
]
},

"extensions": [
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Generate config
run: bash ./scripts/generate.sh compose
run: bash ./scripts/setup.py compose

- name: Login to GitHub Packages
uses: docker/login-action@v3
Expand Down
10 changes: 2 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
{
"editor.insertSpaces": false,
"editor.rulers": [78, 100, 116],
"editor.rulers": [80, 100, 116],
"files.eol": "\n",
"search.useIgnoreFiles": false,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.insertSpaces": true,
"editor.tabSize": 4
},
"[javascript]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"black-formatter.args": [
"--skip-string-normalization",
"--line-length",
"100"
],
"python.analysis.extraPaths": [
"../odoo",
"../odoo-addons",
Expand Down
81 changes: 31 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
# Odoo in docker

Dockerized version of Odoo for development and debugging.
You will need `docker-compose` for this to run or `vscode` to develop inside
a container.
[![Docker Image](https://img.shields.io/badge/docker-repository-blue)][odoo-docker]

## The Dockerfile
Dockerized version of Odoo for development and debugging.
You will need `docker-compose` for to run this project.
You can either just use docker or `vscode` to develop inside a container.

Starting from [odoo-docker], add development tools
Starting from [odoo-docker] (development version), add required tools
and a user for development with the same UID as yourself.

## Starting...

To generate missing local files, run:
`scripts/generate.sh` with either *devcontainer* or *compose* argument.
It will generate the `.env` file, `docker-compose.override.yaml` and
launcher configuration.
You should edit the compose override file for the mounts and ports you want.
If you change the configuration, restart your container instance.

Fork or clone this repository and...
Using the *devcontainer*, you are working inside the odoo container.
Using *docker-compose*, you work on your machine and run Odoo inside a
container, you can attach debug remotely.
container, you can attach to debugger remotely.

```shell
# Clone other repositories (optional, see later)
# Generate additional files
scripts/setup.py devcontainer # or compose
# Edit the generated files
vim .env
vim docker-compose.override.yaml
# Go...
docker-compose up -d # or reopen in devcontainer
```

Sample commands:

```shell
# start up odoo and the database
docker-compose up -d

# connect and run things on the containers
docker-compose exec odoo bash
docker-compose exec db psql -U odoo -l
docker-compose exec odoo psql # it's also available there

# copy files to and from the container
docker copy myfile.tar dockerodoo-odoo-1:/
Expand Down Expand Up @@ -68,7 +71,7 @@ your-project/
├── scripts/ # Scripts for environment automation
├── ... # Common files (.gitignore, etc.)
├── .env # Environment definition (generated)
├── Dockerfile # Image definition
├── Dockerfile # Docker image definition
├── docker-compose.yml # The default docker-compose (and generated override)
├── requirements-dev.txt # Python requirements for development
└── README.md # This file
Expand All @@ -95,14 +98,12 @@ File locations:

The repository is configured for a specific version of Odoo, if you want to run
another version, you'll have to update a few files:
- `.env` change ODOO_VERSION (see scripts/env-template file too)
- `.pylintrc`: valid-odoo-versions
- check odoo requirements and preferred versions
- `.env` change ODOO_VERSION, POSTGRES_VERSION
(see scripts/env-template file too)
- `.pylintrc`: valid-odoo-versions (if you use it)

| odoo version | python | postgres |
| ------------ | ------ | -------- |
| 16.0 | 3.10 | 14 |
| 17.0 | 3.10 | 14 |
You may want to checkout the sources or rebuild the container after this
operation.

## Cloning odoo

Expand All @@ -117,9 +118,11 @@ [email protected]:odoo
git clone $ODOO_SOURCE/odoo.git
mkdir odoo-addons
# optionally clone what you need (example)
cd odoo-addons
pushd odoo-addons
git clone $ODOO_SOURCE/design-themes.git
git clone $ODOO_SOURCE/enterprise.git
popd
git clone $ODOO_SOURCE/documentation.git
```

Add the path in the *docker-comopse.override.yaml* file.
Expand Down Expand Up @@ -166,16 +169,9 @@ pytest --odoo-http --odoo-database test_db_1 addons/template
docker-compose -f docker-compose.yaml -f docker-compose.test.yaml run --rm odoo
```

If you want to run integration tests with the browser, you will have to install
a web-browser in the container.
Since the image is based on Ubuntu, chromium requires snap which
is not running in the container.
You can install [google-chrome](https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb).

```shell
curl https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb --output /tmp/google-chrome.deb
apt-get install /tmp/google-chrome.deb
```
A version of chrome is installed in the devcontainer if you want to run
integration tests.
Source: [google-chrome](https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb).

## Translations

Expand All @@ -197,21 +193,6 @@ scripts/translations-export.sh addons/template/template_module/
scripts/translations-export.sh addons/template/template_module/
```

# Credits

Based on:

* [dockerdoo]

Bunch of ideas taken from:

* [Odoo] ([odoo-docker](https://github.com/odoo/docker))
* [OCA] ([maintainer-quality-tools](https://github.com/OCA/maintainer-quality-tools))
* [click-odoo-contrib]


[click-odoo-contrib]: https://github.com/acsone/click-odoo-contrib
[dockerdoo]: https://github.com/iterativo-git/dockerdoo
[OCA]: https://github.com/OCA
[Odoo]: https://github.com/odoo
[odoo-docker]: https://github.com/kmagusiak/odoo-docker
3 changes: 2 additions & 1 deletion addons/template/template_module/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Template for a module.
# Template module
Copy that start building a module.
2 changes: 1 addition & 1 deletion docker-compose.test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Service Odoo to run the tests
# docker-compose: enable test run

services:
odoo:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Base for running docker
# docker-compose: base for running docker

volumes:
odoo_data:
Expand Down
62 changes: 0 additions & 62 deletions scripts/generate.sh

This file was deleted.

12 changes: 10 additions & 2 deletions scripts/launch.devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
"request": "launch",
"redirectOutput": false,
"cwd": "${workspaceFolder}",
"justMyCode": false,
"justMyCode": true,
"program": "/usr/bin/odoo-bin",
"args": [
"--workers=0",
"--stop-after-init",
"--test-enable",
"-d", "test",
"-i", "${input:odoo_module}",
"--test-enable",
"--test-tags", "${input:test_tags}",
"--limit-time-real=100000"
]
},
Expand All @@ -63,6 +65,12 @@
"id": "odoo_module",
"type": "promptString",
"description": "Odoo module to test"
},
{
"id": "test_tags",
"type": "promptString",
"description": "Odoo test tag selector",
"default": "standard"
}
]
}
Loading

0 comments on commit 5e7a8ce

Please sign in to comment.