Doc, tools for lokavaluto development
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Valentin Lab 08cdba6caf new: [README.org] added 'usage' section for ``compose`` and ``docker-compose``. 5 years ago
src First import 5 years ago
README.org new: [README.org] added 'usage' section for ``compose`` and ``docker-compose``. 5 years ago

README.org

Lokavaluto Dev Pack

\hypersetup{ linkcolor=blue, pdfborder={0 0 0 0} }

Resources (docs, tools) to help getting things done in the lokavaluto team

Common dev environment

We recommend you to try to stick to a somewhat common environment to avoid as much as possible any problem stemming from your installation.

The most important part is the usage of the same docker image of odoo and the same version of postgres. Here are suggestion of how to install it.

Installation

Linux

We are using compose, and installation process will download compose binary, and our charm-store.

Requirements
  • bash >= 4.3

  • docker >= 17.06

  • curl ## for installation

  • git

Deployment

We have a magic script for you that will install or update your current installation of compose and of the charms.

curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash

If you are curious of what it is doing, check:

https://git.myceliandre.fr/Lokavaluto/dev-pack/src/branch/dev/src/install.sh#L203-L258

MacOSX

We are using compose, and installation process will download compose binary, and our charm-store.

Requirements

On MacOSX, you'll need to install homebrew and gnu tools:

https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/

TODO Deployment

Windows - docker for windows

There are many ways to use docker on windows.

If you intend to use docker for windows, then you wont be able to use our tool compose for the moment. However you can use the full blown docker-compose method.

Requirements
  • bash >= 4.3

  • docker >= 17.06

  • docker-compose

TODO Deployment

Usage

using compose

You need to create a compose.yml that suits your need. You can create it wherever you want as long as either you launch compose in a sub-directory or you specify the location of the compose file with the -f COMPOSEFILE option. Here's a good start:

cat <<EOF > compose.yml
odoo:
  charm: odoo-tecnativa
  # docker-compose:
  #   ## Important to keep as a list: otherwise it'll overwrite charm's arguments.
  #   command:
  #     - "--log-level=debug"
  #   environment:
  #     TOTO: TATA
  #   image: mynewimage
  # options:
  #   workers: 1
  #   modules:  ## 'base' is automatically added
  #     - l10n_fr
  #     - mymodule
  #   database: mybase  ## defaults to database in relation

EOF

You can then launch the service(s) with:

compose up

using docker-compose

If you are NOT using compose and are using docker-compose, (for instance because you are on windows and want to stay in the official way to install docker.

You'll need also to initialize the postgres database.

Creating docker-compose.yml

You can run this instructions from your bash to create both .env and docker-compose.yml files:

cat <<EOF > .env
## Location of the charm-store (to build postgres)
CHARM_STORE=~/.charm-store

## Password for postgres's 'odoo' user
PG_DATABASE=odoo
PG_USER=odoo
PG_PASS=odoopassword

## Password for odoo admin tasks (create/delete/archive databases)
ODOO_ADMIN_PASSWORD=adminpass

## Password for postgres admin user 'postgres'
POSTGRES_ROOT_PASSWORD=postgresrootpassword
EOF
cat <<EOF > docker-compose.yml
version: '2.0'
services:
  odoo:
    command:
    - odoo
    - --config=/opt/odoo/auto/odoo.conf
    - --workers=1
    - -i base,l10n_fr
    - --database=odoo
    environment:
      ADMIN_PASSWORD: \${ODOO_ADMIN_PASSWORD}
      INITIAL_LANG: fr_FR
      LIST_DB: 'true'
      PGDATABASE: \${PG_DATABASE}
      PGHOST: postgres
      PGPASSWORD: \${PG_PASS}
      PGUSER: \${PG_USER}
    image: docker.0k.io/mirror/odoo:rc_13.0-MYC-INIT
    links:
    - postgres
    restart: unless-stopped
    tty: true
    volumes:
    ## Volume is changed from normal 'compose' build
    - odoo-data:/var/lib/odoo:rw
  postgres:
    build: \${CHARM_STORE}/postgres/build
    restart: unless-stopped
    volumes:
      ## Volume is changed from normal 'compose' build
      - postgres-data:/var/lib/postgresql/data:rw
    ## Was added, differing from the normal 'compose' build
    environment:
      - POSTGRES_ROOT_PASSWORD
      - PG_DATABASE
      - PG_USER
      - PG_PASS
## new section
volumes:
  odoo-data:
  postgres-data:
EOF

You can then run:

docker-compose up -d
initialisation

This is only needed if you use the 'docker-compose' method. You need to do it once.

Set master password and allow access from odoo container

container 'postgres' needs to be up before running the following:

You need to do this only once.

## Update postgres password
docker-compose exec -T postgres bash -c \
  'PGUSER=postgres psql <<<"ALTER USER postgres WITH ENCRYPTED password "'\\\''$POSTGRES_ROOT_PASSWORD'\\\'

## Set pg_hba.conf
docker-compose exec -T postgres bash -c '
PG_HBA=/var/lib/postgresql/data/pg_hba.conf
if ! grep -E "^host all all (0.0.0.0/0|all) md5\$" "$PG_HBA" >/dev/null 2>&1; then
     if grep -E "^host all all (0.0.0.0/0|all) trust\$" "$PG_HBA" >/dev/null 2>&1; then
         sed -ri '\''s%^host all all (0\.0\.0\.0/0|all) trust$%host all all \1 md5%g'\'' \
             "$PG_HBA"
         echo "Accepting connection from outside."
     else
         echo "Can'\''t ensure connection from outside." >&2
         exit 1
     fi
fi
'

if [ "$?" != 0 ]; then
    echo "Error: can't update pg_hba.conf" >&2
else
    docker-compose restart postgres
fi
Create odoo table and odoo user
docker-compose exec -T postgres bash -c \
  'PGUSER=postgres createdb $PG_DATABASE'

docker-compose exec -T postgres bash -c \
  'PGUSER=postgres psql "$PG_DATABASE"' \
  <<<'CREATE EXTENSION IF NOT EXISTS unaccent;'

docker-compose exec -T postgres bash -c \
  'PGUSER=postgres psql <<<"CREATE USER \"$PG_USER\" WITH PASSWORD '\''$PG_PASS'\'' CREATEDB NOCREATEROLE;"'

docker-compose exec -T postgres bash -c \
  'PGUSER=postgres prefix_pg_local_command=" " pgm chown $PG_USER $PG_DATABASE'