Skip to content

Commit 83b218a

Browse files
committed
[IMP] add Dockerfile
1 parent 4dc6abc commit 83b218a

4 files changed

Lines changed: 353 additions & 0 deletions

File tree

.dockerignore

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
**.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
# mypy
123+
.mypy_cache/
124+
.dmypy.json
125+
dmypy.json
126+
127+
# Pyre type checker
128+
.pyre/
129+
*.ps
130+
*.xlsx
131+
132+
.filestore/
133+
src/
134+
setup/
135+
Dockerfile
136+
.copier-answers.yml
137+
.dockerignore
138+
.filestore/
139+
.editorconfig
140+
.eslintrc.yml
141+
.git
142+
.github
143+
.gitignore
144+
.oca_hooks.cfg
145+
.pre-commit-config.yaml
146+
.prettierrc.yml
147+
.pylintrc
148+
.pylintrc-mandatory
149+
.ruff.toml
150+
.CONTRIBUTE.md
151+
.pytest_cache/
152+
.ruff_cache/
153+
README.md
154+
repos.yaml
155+
requirements.txt
156+
test-requirements.txt
157+
oca_dependencies.txt
158+
setup.cfg
159+
tasks.py
160+
.vscode
161+
nohup.out
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "14.0*"
7+
push:
8+
branches:
9+
- "14.0"
10+
- "14.0-ocabot-*"
11+
12+
jobs:
13+
buildx:
14+
runs-on: ubuntu-latest
15+
steps:
16+
-
17+
name: Checkout
18+
uses: actions/checkout@v4
19+
20+
-
21+
name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
-
25+
name: Build and push
26+
uses: docker/build-push-action@v6
27+
with:
28+
context: .
29+
file: Dockerfile
30+
tags: |
31+
ghcr.io/oca/oca-custom:14.0-oca-latest
32+
# cache-from: type=registry,ref=ghcr.io/oca/oca-custom:14.0-oca-latest
33+
cache-to: type=local,dest=/tmp/.buildx-cache
34+
# pull: true
35+
load: true
36+
-
37+
name: Test install oca_all in docker image
38+
run: |
39+
docker compose up -d db
40+
sleep 10 # Attendre que PostgreSQL soit prêt
41+
docker compose run --rm odoo odoo -c /etc/odoo.cfg -i oca_all --without-demo= --stop-after-init
42+
43+
-
44+
name: Login to ghcr.io
45+
if: ${{ github.repository_owner == 'OCA' && github.ref == 'refs/heads/14.0' || startsWith(github.ref, 'refs/tags/') }}
46+
uses: docker/login-action@v3
47+
with:
48+
registry: ghcr.io
49+
username: ${{ github.repository_owner }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
-
53+
name: Push image
54+
if: ${{ github.repository_owner == 'OCA' && github.ref == 'refs/heads/14.0' }}
55+
uses: docker/build-push-action@v6
56+
with:
57+
context: .
58+
file: Dockerfile
59+
tags: |
60+
ghcr.io/oca/oca-custom:14.0-oca-latest
61+
cache-from: type=local,src=/tmp/.buildx-cache
62+
cache-to: type=inline
63+
push: true
64+
65+
-
66+
name: Push image with tag if tagged
67+
if: ${{ github.repository_owner == 'OCA' && startsWith(github.ref, 'refs/tags/') }}
68+
uses: docker/build-push-action@v6
69+
with:
70+
context: .
71+
file: Dockerfile
72+
tags: |
73+
ghcr.io/oca/oca-custom:${{ github.ref_name }}
74+
cache-from: type=local,src=/tmp/.buildx-cache
75+
cache-to: type=inline
76+
push: true

Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# syntax=docker/dockerfile:1.4
2+
3+
###############################################################
4+
# Base stage, with the non-python runtime dependencies, and uv.
5+
#
6+
7+
FROM ghcr.io/acsone/odoo-bedrock:14.0-py39-focal-latest AS base
8+
9+
# Install apt runtime dependencies.
10+
RUN set -e \
11+
&& apt update \
12+
&& apt -y install --no-install-recommends \
13+
postgresql-client \
14+
&& apt -y clean \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Install uv, and configure it for optimal usage in Dockerfile.
18+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
19+
ENV UV_PROJECT_ENVIRONMENT=$VIRTUAL_ENV
20+
ENV UV_LINK_MODE=copy
21+
ENV UV_COMPILE_BYTECODE=1
22+
23+
###############################################################
24+
# Dependencies stage, where we install tools necessary to build
25+
# source distributions, and install all the locked dependencies
26+
# in the virtual environment.
27+
#
28+
29+
FROM base AS dependencies
30+
31+
# Install git and other build tools.
32+
RUN set -e \
33+
&& apt update \
34+
&& apt -y install --no-install-recommends \
35+
git \
36+
python3.9-dev \
37+
build-essential \
38+
libpq-dev \
39+
&& apt -y clean \
40+
&& rm -rf /var/lib/apt/lists/*
41+
42+
# Install the locked dependencies in the virtual environment,
43+
# but not the project
44+
RUN --mount=type=cache,target=/root/.cache/uv \
45+
--mount=type=bind,source=uv.lock,target=uv.lock \
46+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
47+
uv sync --frozen --no-install-project
48+
49+
###############################################################
50+
# In this runtime stage, we install the app in editable mode,
51+
# on top of dependencies.
52+
#
53+
54+
FROM base AS runtime
55+
56+
COPY --from=dependencies $VIRTUAL_ENV $VIRTUAL_ENV
57+
58+
# Install the app
59+
COPY . /app
60+
WORKDIR /app
61+
RUN python -m compileall .
62+
RUN --mount=type=cache,target=/root/.cache/uv \
63+
uv sync --locked --no-dev

docker-compose.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
services:
2+
odoo:
3+
image: ghcr.io/oca/oca-custom:14.0-oca-latest
4+
networks:
5+
- internal
6+
- kwkhtmltopdf
7+
# build:
8+
# context: ./
9+
# cache_from:
10+
volumes:
11+
- oca_filestore:/data/odoo/filestore
12+
command: ["odoo", "-c", "/etc/odoo.cfg"]
13+
ports:
14+
- 8069:8069
15+
environment:
16+
- DB_HOST=db
17+
- DB_PASSWORD=${POSTGRES_PASSWORD:-ocapwd}
18+
- DB_USER=${POSTGRES_USER:-oca}
19+
- DB_NAME=${POSTGRES_DB:-oca}
20+
- UNACCENT=True
21+
- WORKERS=0
22+
- LIST_DB=False
23+
- WITHOUT_DEMO=False
24+
- KWKHTMLTOPDF_SERVER_URL=http://kwkhtmltopdf:8080
25+
- ODOO_REPORT_URL=http://odoo:8069
26+
- RUNNING_ENV=dev
27+
28+
db:
29+
image: postgres
30+
volumes:
31+
- oca_pgdata:/var/lib/postgresql/data
32+
environment:
33+
POSTGRES_DB: ${POSTGRES_DB:-oca}
34+
POSTGRES_USER: ${POSTGRES_USER:-oca}
35+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-ocapwd}
36+
# POSTGRES_HOST_AUTH_METHOD: "password"
37+
networks:
38+
- internal
39+
40+
kwkhtmltopdf:
41+
image: ghcr.io/acsone/kwkhtmltopdf:0.12.5-latest
42+
networks:
43+
- kwkhtmltopdf
44+
45+
networks:
46+
internal:
47+
kwkhtmltopdf:
48+
49+
volumes:
50+
oca_pgdata:
51+
driver: local
52+
oca_filestore:
53+
driver: local

0 commit comments

Comments
 (0)