Skip to content

Commit 37e66e7

Browse files
committed
Create v14 config
1 parent 019537f commit 37e66e7

16 files changed

+482
-0
lines changed

.devcontainer/Dockerfile

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
FROM debian:buster-slim
2+
MAINTAINER Odoo S.A. <[email protected]>
3+
4+
SHELL ["/bin/bash", "-xo", "pipefail", "-c"]
5+
6+
# Generate locale C.UTF-8 for postgres and general locale data
7+
ENV LANG C.UTF-8
8+
9+
# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf
10+
RUN apt-get update && \
11+
apt-get install -y --no-install-recommends \
12+
ca-certificates \
13+
curl \
14+
dirmngr \
15+
fonts-noto-cjk \
16+
git \
17+
gnupg \
18+
libssl-dev \
19+
node-less \
20+
npm \
21+
python3-num2words \
22+
python3-pdfminer \
23+
python3-pip \
24+
python3-phonenumbers \
25+
python3-pyldap \
26+
python3-qrcode \
27+
python3-renderpm \
28+
python3-setuptools \
29+
python3-slugify \
30+
python3-vobject \
31+
python3-watchdog \
32+
python3-xlrd \
33+
python3-xlwt \
34+
xz-utils \
35+
&& curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb \
36+
&& echo 'ea8277df4297afc507c61122f3c349af142f31e5 wkhtmltox.deb' | sha1sum -c - \
37+
&& apt-get install -y --no-install-recommends ./wkhtmltox.deb \
38+
&& rm -rf /var/lib/apt/lists/* wkhtmltox.deb
39+
40+
# install latest postgresql-client
41+
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' > /etc/apt/sources.list.d/pgdg.list \
42+
&& GNUPGHOME="$(mktemp -d)" \
43+
&& export GNUPGHOME \
44+
&& repokey='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8' \
45+
&& gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "${repokey}" \
46+
&& gpg --batch --armor --export "${repokey}" > /etc/apt/trusted.gpg.d/pgdg.gpg.asc \
47+
&& gpgconf --kill all \
48+
&& rm -rf "$GNUPGHOME" \
49+
&& apt-get update \
50+
&& apt-get install --no-install-recommends -y postgresql-client \
51+
&& rm -f /etc/apt/sources.list.d/pgdg.list \
52+
&& rm -rf /var/lib/apt/lists/*
53+
54+
# Install rtlcss (on Debian buster)
55+
RUN npm install -g rtlcss
56+
57+
# Copy Odoo installation package downloaded in the previous GitHub Action step
58+
COPY ./odoo.deb /
59+
60+
# Install Odoo
61+
RUN apt-get update \
62+
&& apt-get -y install --no-install-recommends ./odoo.deb \
63+
&& rm -rf /var/lib/apt/lists/* odoo.deb
64+
65+
# Copy entrypoint script and Odoo configuration file
66+
COPY ./entrypoint.sh /
67+
COPY ./odoo.conf /etc/odoo/
68+
COPY ./wait-for-psql.py /usr/local/bin/wait-for-psql.py
69+
70+
# Set permissions and Mount /var/lib/odoo to allow restoring filestore and /mnt/extra-addons for users addons
71+
RUN chown odoo /etc/odoo/odoo.conf \
72+
&& mkdir -p /mnt/extra-addons \
73+
&& chown -R odoo /mnt/extra-addons
74+
VOLUME ["/var/lib/odoo", "/mnt/extra-addons"]
75+
76+
# Expose Odoo services
77+
EXPOSE 8069 8071 8072
78+
79+
# Set the default config file
80+
ENV ODOO_RC /etc/odoo/odoo.conf
81+
82+
# Set default user when running the container
83+
USER odoo
84+
85+
ENTRYPOINT ["/entrypoint.sh"]
86+
CMD ["odoo"]

.devcontainer/URL.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://nightly.odoo.com/14.0/nightly/deb/odoo_14.0.latest_all.deb

.devcontainer/devcontainer.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "Odoo Dev Container",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "odoo",
5+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/custom",
6+
"remoteUser": "root",
7+
"forwardPorts": [8069],
8+
"shutdownAction": "stopCompose",
9+
"customizations": {
10+
"vscode": {
11+
"settings": {
12+
"terminal.integrated.shell.linux": "/bin/bash"
13+
},
14+
"extensions": [
15+
"ms-python.python",
16+
"ms-python.vscode-pylance",
17+
"GitHub.copilot",
18+
"GitHub.copilot-chat",
19+
"DavidAnson.vscode-markdownlint",
20+
"DotJoshJohnson.xml"
21+
]
22+
}
23+
}
24+
}

.devcontainer/docker-compose.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3.1'
2+
services:
3+
odoo:
4+
image: "ghcr.io/m3r3nix/odoo-v14-community:latest"
5+
depends_on:
6+
- db
7+
ports:
8+
- "8069:8069"
9+
volumes:
10+
- ../custom:/mnt/extra-addons
11+
db:
12+
image: postgres:13
13+
environment:
14+
- POSTGRES_DB=postgres
15+
- POSTGRES_PASSWORD=odoo
16+
- POSTGRES_USER=odoo

.devcontainer/entrypoint.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ -v PASSWORD_FILE ]; then
6+
PASSWORD="$(< $PASSWORD_FILE)"
7+
fi
8+
9+
# set the postgres database host, port, user and password according to the environment
10+
# and pass them as arguments to the odoo process if not present in the config file
11+
: ${HOST:=${DB_PORT_5432_TCP_ADDR:='db'}}
12+
: ${PORT:=${DB_PORT_5432_TCP_PORT:=5432}}
13+
: ${USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}}
14+
: ${PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}}
15+
16+
DB_ARGS=()
17+
function check_config() {
18+
param="$1"
19+
value="$2"
20+
if grep -q -E "^\s*\b${param}\b\s*=" "$ODOO_RC" ; then
21+
value=$(grep -E "^\s*\b${param}\b\s*=" "$ODOO_RC" |cut -d " " -f3|sed 's/["\n\r]//g')
22+
fi;
23+
DB_ARGS+=("--${param}")
24+
DB_ARGS+=("${value}")
25+
}
26+
check_config "db_host" "$HOST"
27+
check_config "db_port" "$PORT"
28+
check_config "db_user" "$USER"
29+
check_config "db_password" "$PASSWORD"
30+
31+
case "$1" in
32+
-- | odoo)
33+
shift
34+
if [[ "$1" == "scaffold" ]] ; then
35+
exec odoo "$@"
36+
else
37+
wait-for-psql.py ${DB_ARGS[@]} --timeout=30
38+
exec odoo "$@" "${DB_ARGS[@]}"
39+
fi
40+
;;
41+
-*)
42+
wait-for-psql.py ${DB_ARGS[@]} --timeout=30
43+
exec odoo "$@" "${DB_ARGS[@]}"
44+
;;
45+
*)
46+
exec "$@"
47+
esac
48+
49+
exit 1

.devcontainer/odoo.conf

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[options]
2+
addons_path = /mnt/extra-addons
3+
data_dir = /var/lib/odoo
4+
; admin_passwd = admin
5+
; csv_internal_sep = ,
6+
; db_maxconn = 64
7+
; db_name = False
8+
; db_template = template1
9+
; dbfilter = .*
10+
; debug_mode = False
11+
; email_from = False
12+
; limit_memory_hard = 2684354560
13+
; limit_memory_soft = 2147483648
14+
; limit_request = 8192
15+
; limit_time_cpu = 60
16+
; limit_time_real = 120
17+
; list_db = True
18+
; log_db = False
19+
; log_handler = [':INFO']
20+
; log_level = info
21+
; logfile = None
22+
; longpolling_port = 8072
23+
; max_cron_threads = 2
24+
; osv_memory_age_limit = 1.0
25+
; osv_memory_count_limit = False
26+
; smtp_password = False
27+
; smtp_port = 25
28+
; smtp_server = localhost
29+
; smtp_ssl = False
30+
; smtp_user = False
31+
; workers = 0
32+
; xmlrpc = True
33+
; xmlrpc_interface =
34+
; xmlrpc_port = 8069
35+
; xmlrpcs = True
36+
; xmlrpcs_interface =
37+
; xmlrpcs_port = 8071

.devcontainer/wait-for-psql.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python3
2+
import argparse
3+
import psycopg2
4+
import sys
5+
import time
6+
7+
8+
if __name__ == '__main__':
9+
arg_parser = argparse.ArgumentParser()
10+
arg_parser.add_argument('--db_host', required=True)
11+
arg_parser.add_argument('--db_port', required=True)
12+
arg_parser.add_argument('--db_user', required=True)
13+
arg_parser.add_argument('--db_password', required=True)
14+
arg_parser.add_argument('--timeout', type=int, default=5)
15+
16+
args = arg_parser.parse_args()
17+
18+
start_time = time.time()
19+
while (time.time() - start_time) < args.timeout:
20+
try:
21+
conn = psycopg2.connect(user=args.db_user, host=args.db_host, port=args.db_port, password=args.db_password, dbname='postgres')
22+
error = ''
23+
break
24+
except psycopg2.OperationalError as e:
25+
error = e
26+
else:
27+
conn.close()
28+
time.sleep(1)
29+
30+
if error:
31+
print("Database connection failure: %s" % error, file=sys.stderr)
32+
sys.exit(1)

.github/workflows/docker-publish.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Build and Push Odoo Dev Container
2+
3+
on:
4+
push:
5+
paths:
6+
- '.devcontainer/URL.conf'
7+
workflow_dispatch:
8+
9+
env:
10+
# Use docker.io for Docker Hub if empty
11+
REGISTRY: ghcr.io
12+
13+
14+
jobs:
15+
build:
16+
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
# This is used to complete the identity challenge
22+
# with sigstore/fulcio when running outside of PRs.
23+
id-token: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v3
28+
29+
# Set up BuildKit Docker container builder to be able to build
30+
# multi-platform images and export cache
31+
# https://github.com/docker/setup-buildx-action
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
34+
35+
# Login against a Docker registry except on PR
36+
# https://github.com/docker/login-action
37+
- name: Log into registry ${{ env.REGISTRY }}
38+
if: github.event_name != 'pull_request'
39+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
# Download .deb package with curl from the provided URL in the ./devcontainer/URL.txt file
46+
- name: Download odoo.deb package
47+
if: github.event_name != 'pull_request'
48+
run: |
49+
curl -sSL -o .devcontainer/odoo.deb $(cat .devcontainer/URL.conf)
50+
51+
# Set environmet variables based on the downloaded .deb package version number
52+
- name: Set Odoo version environment variable
53+
if: github.event_name != 'pull_request'
54+
run: |
55+
export ODOO_DEB_VERSION=$(dpkg-deb -f .devcontainer/odoo.deb version)
56+
echo "ODOO_DEB_VERSION=${ODOO_DEB_VERSION}" >> $GITHUB_ENV
57+
echo "ODOO_MAIN_VERSION=${ODOO_DEB_VERSION:0:2}" >> $GITHUB_ENV
58+
echo "ODOO_TYPE=$(echo $ODOO_DEB_VERSION | grep -q 'e' && echo 'enterprise' || echo 'community')" >> $GITHUB_ENV
59+
60+
# Use the tag 'latest' only if the downloaded .deb package is for the Enterprise version (Enterprise download URL only provides the latest build)
61+
# or if the download URL includes the word 'latest' (for Community version you can use either latest or any specific date)
62+
- name: Determine if latest tag should be used
63+
if: github.event_name != 'pull_request'
64+
run: |
65+
if [[ "${{ env.ODOO_TYPE }}" == "enterprise" ]] || grep -q 'latest' .devcontainer/URL.conf; then
66+
echo "IS_LATEST=true" >> $GITHUB_ENV
67+
else
68+
echo "IS_LATEST=false" >> $GITHUB_ENV
69+
fi
70+
71+
# Extract metadata (tags, labels) for Docker
72+
# https://github.com/docker/metadata-action
73+
- name: Extract Docker metadata
74+
if: ${{ github.event_name != 'pull_request' }}
75+
id: meta
76+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
77+
with:
78+
images: ${{ env.REGISTRY }}/${{ github.actor }}/odoo-v${{ env.ODOO_MAIN_VERSION }}-${{ env.ODOO_TYPE }}
79+
tags: |
80+
type=raw,value=${{ env.ODOO_DEB_VERSION }}
81+
type=raw,value=latest,enable=${{ env.IS_LATEST }}
82+
83+
# Build and push Docker image with Buildx (don't push on PR)
84+
# https://github.com/docker/build-push-action
85+
- name: Build and push Docker image
86+
if: ${{ github.event_name != 'pull_request' }}
87+
id: build-and-push
88+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
89+
with:
90+
context: ./.devcontainer
91+
file: ./.devcontainer/Dockerfile
92+
push: true
93+
tags: ${{ steps.meta.outputs.tags }}
94+
labels: ${{ steps.meta.outputs.labels }}
95+
cache-from: type=gha
96+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)