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.

329 lines
8.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #+PROPERTY: Effort_ALL 0 0:30 1:00 2:00 0.5d 1d 1.5d 2d 3d 4d 5d
  2. #+PROPERTY: Max_effort_ALL 0 0:30 1:00 2:00 0.5d 1d 1.5d 2d 3d 4d 5d
  3. #+PROPERTY: header-args:python :var filename=(buffer-file-name)
  4. #+PROPERTY: header-args:sh :var filename=(buffer-file-name)
  5. #+TODO: TODO WIP BLOCKED | DONE CANCELED
  6. #+LATEX_HEADER: \usepackage[margin=0.5in]{geometry}
  7. #+LaTeX_CLASS: article
  8. #+OPTIONS: H:8 ^:nil prop:("Effort" "Max_effort") tags:not-in-toc
  9. #+COLUMNS: %50ITEM %Effort(Min Effort) %Max_effort(Max Effort)
  10. #+BEGIN_LaTeX
  11. \hypersetup{
  12. linkcolor=blue,
  13. pdfborder={0 0 0 0}
  14. }
  15. #+END_LaTeX
  16. #+TITLE: Lokavaluto Dev Pack
  17. #+LATEX: \pagebreak
  18. Resources (docs, tools) to help getting things done in the lokavaluto team
  19. #+LATEX: \pagebreak
  20. #+LATEX: \pagebreak
  21. * Common dev environment
  22. We recommend you to try to stick to a somewhat common environment to
  23. avoid as much as possible any problem stemming from your installation.
  24. The most important part is the usage of the same docker image of odoo
  25. and the same version of postgres. Here are suggestion of how to
  26. install it.
  27. ** Installation
  28. *** Linux
  29. We are using =compose=, and installation process will download
  30. =compose= binary, and our =charm-store=.
  31. **** Requirements
  32. - =bash= >= 4.3
  33. - =docker= >= 17.06
  34. - =curl= ## for installation
  35. - =git=
  36. **** Deployment
  37. We have a magic script for you that will install or update your
  38. current installation of =compose= and of the =charms=.
  39. #+BEGIN_SRC shell
  40. curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash
  41. #+END_SRC
  42. If you are curious of what it is doing, check:
  43. https://git.myceliandre.fr/Lokavaluto/dev-pack/src/branch/dev/src/install.sh#L203-L258
  44. *** MacOSX
  45. We are using =compose=, and installation process will download
  46. =compose= binary, and our =charm-store=.
  47. **** Requirements
  48. On MacOSX, you'll need to install homebrew and gnu tools:
  49. https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
  50. **** TODO Deployment
  51. *** Windows - docker for windows
  52. There are many ways to use docker on windows.
  53. If you intend to use docker for windows, then you wont be able to use
  54. our tool =compose= for the moment. However you can use the full blown
  55. =docker-compose= method.
  56. **** Requirements
  57. - =bash= >= 4.3
  58. - =docker= >= 17.06
  59. - =docker-compose=
  60. **** Deployment
  61. You'll need to get our charms if you want to use our same postgres
  62. image.
  63. This script will take care of what you need:
  64. #+BEGIN_SRC shell
  65. curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash
  66. #+END_SRC
  67. ** Usage
  68. *** using =compose=
  69. You need to create a =compose.yml= that suits your need. You can
  70. create it wherever you want as long as either you launch =compose= in
  71. a sub-directory or you specify the location of the =compose= file with
  72. the =-f COMPOSEFILE= option. Here's a good start:
  73. #+BEGIN_SRC shell
  74. cat <<EOF > compose.yml
  75. odoo:
  76. charm: odoo-tecnativa
  77. docker-compose:
  78. image: docker.0k.io/mirror/odoo:rc_13.0-MYC-INIT
  79. ## Important to keep as a list: otherwise it'll overwrite charm's arguments.
  80. #command:
  81. # - "--log-level=debug"
  82. #environment:
  83. # TOTO: TATA
  84. #options:
  85. # workers: 1
  86. # modules: ## 'base' is automatically added
  87. # - l10n_fr
  88. # - mymodule
  89. # database: mybase ## defaults to database in relation
  90. # ## Odoo configuration file
  91. # conf:
  92. # options:
  93. # email_from: me@example.com
  94. ## Create a direct access from 0.0.0.0:80
  95. relations:
  96. web-proxy:
  97. apache:
  98. ## be sure to add the following domain to your /etc/hosts
  99. domain: odoo
  100. EOF
  101. #+END_SRC
  102. You can then launch the service(s) with:
  103. #+BEGIN_SRC shell
  104. compose up
  105. #+END_SRC
  106. **** Access odoo from your browser
  107. You should access your odoo through the web-proxy, but if this is not
  108. what you want, you can access it directly.
  109. ***** Using the web-proxy to access odoo
  110. You'll need to modify your =/etc/hosts= to include the domain name 'odoo'
  111. as a domain name for =127.0.0.1=.
  112. #+BEGIN_SRC shell
  113. cat <<EOF | sudo tee -a /etc/hosts
  114. 127.0.0.1 odoo
  115. EOF
  116. #+END_SRC
  117. This will ask for your password as it need write access to =/etc/hosts=.
  118. You can then use =http://odoo= to access your odoo instance.
  119. ***** Direct connection to odoo container
  120. You should be able to point your browser to the ip of the odoo
  121. container. You can find this IP using =docker-ip=.
  122. If you are lazy, this might work:
  123. #+BEGIN_SRC shell
  124. ODOO_IP=$(docker-ip | grep odoo | sed -r 's/ +/ /g' | cut -f 3 -d " ")
  125. echo "Odoo is up and running on: http://$ODOO_IP:8069"
  126. #+END_SRC
  127. If your setup allow direct access from the host running your browser
  128. to the container's network, then you can point your browser towards
  129. the given address.
  130. *** using =docker-compose=
  131. If you are NOT using =compose= and are using =docker-compose=, (for
  132. instance because you are on windows and want to stay in the official
  133. way to install docker.
  134. You'll need also to initialize the postgres database.
  135. **** Creating =docker-compose.yml=
  136. You can run this instructions from your bash to create both =.env= and
  137. =docker-compose.yml= files:
  138. #+BEGIN_SRC shell
  139. cat <<EOF > .env
  140. ## Location of the charm-store (to build postgres)
  141. CHARM_STORE=~/.charm-store
  142. ## Password for postgres's 'odoo' user
  143. PG_DATABASE=odoo
  144. PG_USER=odoo
  145. PG_PASS=odoopassword
  146. ## Password for odoo admin tasks (create/delete/archive databases)
  147. ODOO_ADMIN_PASSWORD=adminpass
  148. ## Password for postgres admin user 'postgres'
  149. POSTGRES_ROOT_PASSWORD=postgresrootpassword
  150. EOF
  151. cat <<EOF > docker-compose.yml
  152. version: '2.0'
  153. services:
  154. odoo:
  155. ports:
  156. - 8069:8069
  157. command:
  158. - odoo
  159. - --config=/opt/odoo/auto/odoo.conf
  160. - --workers=1
  161. - -i base,l10n_fr
  162. - --database=odoo
  163. environment:
  164. ADMIN_PASSWORD: \${ODOO_ADMIN_PASSWORD}
  165. INITIAL_LANG: fr_FR
  166. LIST_DB: 'true'
  167. PGDATABASE: \${PG_DATABASE}
  168. PGHOST: postgres
  169. PGPASSWORD: \${PG_PASS}
  170. PGUSER: \${PG_USER}
  171. image: docker.0k.io/mirror/odoo:rc_13.0-MYC-INIT
  172. links:
  173. - postgres
  174. restart: unless-stopped
  175. tty: true
  176. volumes:
  177. ## Volume is changed from normal 'compose' build
  178. - odoo-data:/var/lib/odoo:rw
  179. postgres:
  180. build: \${CHARM_STORE}/postgres/build
  181. restart: unless-stopped
  182. volumes:
  183. ## Volume is changed from normal 'compose' build
  184. - postgres-data:/var/lib/postgresql/data:rw
  185. ## Was added, differing from the normal 'compose' build
  186. environment:
  187. - POSTGRES_ROOT_PASSWORD
  188. - PG_DATABASE
  189. - PG_USER
  190. - PG_PASS
  191. ## new section
  192. volumes:
  193. odoo-data:
  194. postgres-data:
  195. EOF
  196. #+END_SRC
  197. You can then run:
  198. #+BEGIN_SRC shell
  199. docker-compose up -d
  200. #+END_SRC
  201. **** initialisation
  202. This is only needed if you use the 'docker-compose' method. You need
  203. to do it once.
  204. ***** Set master password and allow access from odoo container
  205. container 'postgres' needs to be up before running the following:
  206. You need to do this only once.
  207. #+BEGIN_SRC sh
  208. ## Update postgres password
  209. docker-compose exec -T postgres bash -c \
  210. 'PGUSER=postgres psql <<<"ALTER USER postgres WITH ENCRYPTED password "'\\\''$POSTGRES_ROOT_PASSWORD'\\\'
  211. ## Set pg_hba.conf
  212. docker-compose exec -T postgres bash -c '
  213. PG_HBA=/var/lib/postgresql/data/pg_hba.conf
  214. if ! grep -E "^host all all (0.0.0.0/0|all) md5\$" "$PG_HBA" >/dev/null 2>&1; then
  215. if grep -E "^host all all (0.0.0.0/0|all) trust\$" "$PG_HBA" >/dev/null 2>&1; then
  216. sed -ri '\''s%^host all all (0\.0\.0\.0/0|all) trust$%host all all \1 md5%g'\'' \
  217. "$PG_HBA"
  218. echo "Accepting connection from outside."
  219. else
  220. echo "Can'\''t ensure connection from outside." >&2
  221. exit 1
  222. fi
  223. fi
  224. '
  225. if [ "$?" != 0 ]; then
  226. echo "Error: can't update pg_hba.conf" >&2
  227. else
  228. docker-compose restart postgres
  229. fi
  230. #+END_SRC
  231. ***** Create odoo table and odoo user
  232. #+BEGIN_SRC shell
  233. docker-compose exec -T postgres bash -c \
  234. 'PGUSER=postgres createdb $PG_DATABASE'
  235. docker-compose exec -T postgres bash -c \
  236. 'PGUSER=postgres psql "$PG_DATABASE"' \
  237. <<<'CREATE EXTENSION IF NOT EXISTS unaccent;'
  238. docker-compose exec -T postgres bash -c \
  239. 'PGUSER=postgres psql <<<"CREATE USER \"$PG_USER\" WITH PASSWORD '\''$PG_PASS'\'' CREATEDB NOCREATEROLE;"'
  240. docker-compose exec -T postgres bash -c \
  241. 'PGUSER=postgres prefix_pg_local_command=" " pgm chown $PG_USER $PG_DATABASE'
  242. #+END_SRC