#+PROPERTY: Effort_ALL 0 0:30 1:00 2:00 0.5d 1d 1.5d 2d 3d 4d 5d #+PROPERTY: Max_effort_ALL 0 0:30 1:00 2:00 0.5d 1d 1.5d 2d 3d 4d 5d #+PROPERTY: header-args:python :var filename=(buffer-file-name) #+PROPERTY: header-args:sh :var filename=(buffer-file-name) #+TODO: TODO WIP BLOCKED | DONE CANCELED #+LATEX_HEADER: \usepackage[margin=0.5in]{geometry} #+LaTeX_CLASS: article #+OPTIONS: H:8 ^:nil prop:("Effort" "Max_effort") tags:not-in-toc #+COLUMNS: %50ITEM %Effort(Min Effort) %Max_effort(Max Effort) #+BEGIN_LaTeX \hypersetup{ linkcolor=blue, pdfborder={0 0 0 0} } #+END_LaTeX #+TITLE: Lokavaluto Dev Pack #+LATEX: \pagebreak Resources (docs, tools) to help getting things done in the lokavaluto team #+LATEX: \pagebreak #+LATEX: \pagebreak * 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=. You can run this from any terminal, and don't care about the directory from where you launch this. #+BEGIN_SRC shell curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash #+END_SRC If you are curious of what it is doing, check: https://git.myceliandre.fr/Lokavaluto/dev-pack/src/branch/dev/src/install.sh#L252-L273 *** MacOSX There are 2 ways to get docker on mac: - docker desktop for mac - docker toolbox for mac (obsolete, but works with older macs) They are basically described here: https://docs.docker.com/docker-for-mac/docker-toolbox/ **** Docker Desktop for mac 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 **** Docker Toolbox for mac This docker installs will create a virtualbox with a linux inside. Your =/Users= will be automatically mapped into your virtualbox linux VM. ***** Requirements You'll not need anything more than the Docker Toolbox for mac installed. This link will help you with that: https://docs.docker.com/toolbox/toolbox_install_mac/ ***** Deployment We have a magic script for you that will install or update your current installation of =compose= and of the =charms=. You need to run this code in the bash of your Virtualbox, and don't care about the directory from where you launch this. #+BEGIN_SRC shell curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash #+END_SRC *** Windows There are different ways to run docker on windows, the preferred is on WSL2 with a native docker daemon running in the WSL2 environment. But this is still not out, so you might prefer to run "Docker For Windows". In that latter case you won't be able to use our tool =compose= for the moment. However you can use the full blown =docker-compose= method. **** Windows - docker for windows ***** Requirements - =bash= >= 4.3 - =docker= >= 17.06 - =docker-compose= ***** Deployment You'll need to get our charms if you want to use our same postgres image. This script will take care of what you need if run from a bash in WSL, and don't care about the directory from where you launch this. #+BEGIN_SRC shell curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash #+END_SRC **** Windows - docker in WSL2 Just run this script in a bash session under WSL2, and don't care about the directory from where you launch this. #+BEGIN_SRC shell curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash #+END_SRC ** Usage *** using =compose= This method only works if you are on linux, MacOSX, or Windows WSL2 with docker installed inside WSL2. 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, execute these command in a shell: #+BEGIN_SRC shell cat < compose.yml odoo: charm: odoo-tecnativa docker-compose: #image: docker.0k.io/mirror/odoo:rc_12.0-MYC-INIT image: docker.0k.io/mirror/odoo:rc_13.0-MYC-INIT ## Important to keep as a list: otherwise it'll overwrite charm's arguments. #command: # - "--log-level=debug" #environment: # TOTO: TATA #options: # workers: 1 # modules: ## 'base' is automatically added # - l10n_fr # - mymodule # database: mybase ## defaults to database in relation # ## Odoo configuration file # conf: # options: # email_from: me@example.com ## Create a direct access from 0.0.0.0:80 relations: web-proxy: apache: ## be sure to add the following domain to your /etc/hosts domain: odoo EOF #+END_SRC You can then launch the service(s) with: #+BEGIN_SRC shell compose up #+END_SRC **** Access odoo from your browser You should access your odoo through the web-proxy, but if this is not what you want, you can access it directly. ***** Using the web-proxy to access odoo You'll need to modify your =/etc/hosts= to include the domain name 'odoo' as a domain name for =127.0.0.1=. #+BEGIN_SRC shell cat < .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 < docker-compose.yml version: '2.0' services: odoo: ports: - 8069:8069 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_12.0-MYC-INIT 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