@ -79,7 +79,14 @@ https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in
*** Windows
*** 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
**** Requirements
@ -92,4 +99,175 @@ https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in
** 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:
#+BEGIN_SRC shell
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
#+END_SRC
You can then launch the service(s) with:
#+BEGIN_SRC shell
compose up
#+END_SRC
*** 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:
#+BEGIN_SRC shell
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
#+END_SRC
You can then run:
#+BEGIN_SRC shell
docker-compose up -d
#+END_SRC
**** 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.
#+BEGIN_SRC sh
## 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
#+END_SRC
***** Create odoo table and odoo user
#+BEGIN_SRC shell
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'
#+END_SRC