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.

383 lines
10 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 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=. You can run this
  39. from any terminal, and don't care about the directory from where you
  40. launch this.
  41. #+BEGIN_SRC shell
  42. curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash
  43. #+END_SRC
  44. If you are curious of what it is doing, check:
  45. https://git.myceliandre.fr/Lokavaluto/dev-pack/src/branch/dev/src/install.sh#L252-L273
  46. *** MacOSX
  47. There are 2 ways to get docker on mac:
  48. - docker desktop for mac
  49. - docker toolbox for mac (obsolete, but works with older macs)
  50. They are basically described here:
  51. https://docs.docker.com/docker-for-mac/docker-toolbox/
  52. **** Docker Desktop for mac
  53. We are using =compose=, and installation process will download
  54. =compose= binary, and our =charm-store=.
  55. ***** Requirements
  56. On MacOSX, you'll need to install homebrew and gnu tools:
  57. https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
  58. ***** TODO Deployment
  59. **** Docker Toolbox for mac
  60. This docker installs will create a virtualbox with a linux inside.
  61. Your =/Users= will be automatically mapped into your virtualbox linux VM.
  62. ***** Requirements
  63. You'll not need anything more than the Docker Toolbox for mac installed.
  64. This link will help you with that:
  65. https://docs.docker.com/toolbox/toolbox_install_mac/
  66. ***** Deployment
  67. We have a magic script for you that will install or update your
  68. current installation of =compose= and of the =charms=.
  69. You need to run this code in the bash of your Virtualbox, and don't
  70. care about the directory from where you launch this.
  71. #+BEGIN_SRC shell
  72. curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash
  73. #+END_SRC
  74. *** Windows
  75. There are different ways to run docker on windows, the preferred is on
  76. WSL2 with a native docker daemon running in the WSL2 environment.
  77. But this is still not out, so you might prefer to run "Docker For
  78. Windows". In that latter case you won't be able to use our tool
  79. =compose= for the moment. However you can use the full blown
  80. =docker-compose= method.
  81. **** Windows - docker for windows
  82. ***** Requirements
  83. - =bash= >= 4.3
  84. - =docker= >= 17.06
  85. - =docker-compose=
  86. ***** Deployment
  87. You'll need to get our charms if you want to use our same postgres
  88. image.
  89. This script will take care of what you need if run from a bash in WSL,
  90. and don't care about the directory from where you launch this.
  91. #+BEGIN_SRC shell
  92. curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash
  93. #+END_SRC
  94. **** Windows - docker in WSL2
  95. Just run this script in a bash session under WSL2,
  96. and don't care about the directory from where you launch this.
  97. #+BEGIN_SRC shell
  98. curl -sS https://git.myceliandre.fr/Lokavaluto/dev-pack/raw/branch/dev/src/install.sh | bash
  99. #+END_SRC
  100. ** Usage
  101. *** using =compose=
  102. This method only works if you are on linux, MacOSX, or Windows WSL2
  103. with docker installed inside WSL2.
  104. You need to create a =compose.yml= that suits your need. You can
  105. create it wherever you want as long as either you launch =compose= in
  106. a sub-directory or you specify the location of the =compose= file with
  107. the =-f COMPOSEFILE= option. Here's a good start, execute these command
  108. in a shell:
  109. #+BEGIN_SRC shell
  110. cat <<EOF > compose.yml
  111. odoo:
  112. charm: odoo-tecnativa
  113. docker-compose:
  114. #image: docker.0k.io/mirror/odoo:rc_12.0-MYC-INIT
  115. image: docker.0k.io/mirror/odoo:rc_13.0-MYC-INIT
  116. ## Important to keep as a list: otherwise it'll overwrite charm's arguments.
  117. #command:
  118. # - "--log-level=debug"
  119. #environment:
  120. # TOTO: TATA
  121. #options:
  122. # workers: 1
  123. # modules: ## 'base' is automatically added
  124. # - l10n_fr
  125. # - mymodule
  126. # database: mybase ## defaults to database in relation
  127. # ## Odoo configuration file
  128. # conf:
  129. # options:
  130. # email_from: me@example.com
  131. ## Create a direct access from 0.0.0.0:80
  132. relations:
  133. web-proxy:
  134. apache:
  135. ## be sure to add the following domain to your /etc/hosts
  136. domain: odoo
  137. EOF
  138. #+END_SRC
  139. You can then launch the service(s) with:
  140. #+BEGIN_SRC shell
  141. compose up
  142. #+END_SRC
  143. **** Access odoo from your browser
  144. You should access your odoo through the web-proxy, but if this is not
  145. what you want, you can access it directly.
  146. ***** Using the web-proxy to access odoo
  147. You'll need to modify your =/etc/hosts= to include the domain name 'odoo'
  148. as a domain name for =127.0.0.1=.
  149. #+BEGIN_SRC shell
  150. cat <<EOF | sudo tee -a /etc/hosts
  151. 127.0.0.1 odoo
  152. EOF
  153. #+END_SRC
  154. This will ask for your password as it need write access to =/etc/hosts=.
  155. You can then use =http://odoo= to access your odoo instance.
  156. ***** Direct connection to odoo container
  157. You should be able to point your browser to the ip of the odoo
  158. container. You can find this IP using =docker-ip=.
  159. If you are lazy, this might work:
  160. #+BEGIN_SRC shell
  161. ODOO_IP=$(docker-ip | grep odoo | sed -r 's/ +/ /g' | cut -f 3 -d " ")
  162. echo "Odoo is up and running on: http://$ODOO_IP:8069"
  163. #+END_SRC
  164. If your setup allow direct access from the host running your browser
  165. to the container's network, then you can point your browser towards
  166. the given address.
  167. *** using =docker-compose=
  168. If you are NOT using =compose= and are using =docker-compose=, (for
  169. instance because you are on windows and want to stay in the official
  170. way to install docker.
  171. You'll need also to initialize the postgres database.
  172. **** Creating =docker-compose.yml=
  173. You can run this instructions from your bash to create both =.env= and
  174. =docker-compose.yml= files:
  175. #+BEGIN_SRC shell
  176. cat <<EOF > .env
  177. ## Location of the charm-store (to build postgres)
  178. CHARM_STORE=~/.charm-store
  179. ## Password for postgres's 'odoo' user
  180. PG_DATABASE=odoo
  181. PG_USER=odoo
  182. PG_PASS=odoopassword
  183. ## Password for odoo admin tasks (create/delete/archive databases)
  184. ODOO_ADMIN_PASSWORD=adminpass
  185. ## Password for postgres admin user 'postgres'
  186. POSTGRES_ROOT_PASSWORD=postgresrootpassword
  187. EOF
  188. cat <<EOF > docker-compose.yml
  189. version: '2.0'
  190. services:
  191. odoo:
  192. ports:
  193. - 8069:8069
  194. command:
  195. - odoo
  196. - --config=/opt/odoo/auto/odoo.conf
  197. - --workers=1
  198. - -i base,l10n_fr
  199. - --database=odoo
  200. environment:
  201. ADMIN_PASSWORD: \${ODOO_ADMIN_PASSWORD}
  202. INITIAL_LANG: fr_FR
  203. LIST_DB: 'true'
  204. PGDATABASE: \${PG_DATABASE}
  205. PGHOST: postgres
  206. PGPASSWORD: \${PG_PASS}
  207. PGUSER: \${PG_USER}
  208. #image: docker.0k.io/mirror/odoo:rc_12.0-MYC-INIT
  209. image: docker.0k.io/mirror/odoo:rc_13.0-MYC-INIT
  210. links:
  211. - postgres
  212. restart: unless-stopped
  213. tty: true
  214. volumes:
  215. ## Volume is changed from normal 'compose' build
  216. - odoo-data:/var/lib/odoo:rw
  217. postgres:
  218. build: \${CHARM_STORE}/postgres/build
  219. restart: unless-stopped
  220. volumes:
  221. ## Volume is changed from normal 'compose' build
  222. - postgres-data:/var/lib/postgresql/data:rw
  223. ## Was added, differing from the normal 'compose' build
  224. environment:
  225. - POSTGRES_ROOT_PASSWORD
  226. - PG_DATABASE
  227. - PG_USER
  228. - PG_PASS
  229. ## new section
  230. volumes:
  231. odoo-data:
  232. postgres-data:
  233. EOF
  234. #+END_SRC
  235. You can then run:
  236. #+BEGIN_SRC shell
  237. docker-compose up -d
  238. #+END_SRC
  239. **** initialisation
  240. This is only needed if you use the 'docker-compose' method. You need
  241. to do it once.
  242. ***** Set master password and allow access from odoo container
  243. container 'postgres' needs to be up before running the following:
  244. You need to do this only once.
  245. #+BEGIN_SRC sh
  246. ## Update postgres password
  247. docker-compose exec -T postgres bash -c \
  248. 'PGUSER=postgres psql <<<"ALTER USER postgres WITH ENCRYPTED password "'\\\''$POSTGRES_ROOT_PASSWORD'\\\'
  249. ## Set pg_hba.conf
  250. docker-compose exec -T postgres bash -c '
  251. PG_HBA=/var/lib/postgresql/data/pg_hba.conf
  252. if ! grep -E "^host all all (0.0.0.0/0|all) md5\$" "$PG_HBA" >/dev/null 2>&1; then
  253. if grep -E "^host all all (0.0.0.0/0|all) trust\$" "$PG_HBA" >/dev/null 2>&1; then
  254. sed -ri '\''s%^host all all (0\.0\.0\.0/0|all) trust$%host all all \1 md5%g'\'' \
  255. "$PG_HBA"
  256. echo "Accepting connection from outside."
  257. else
  258. echo "Can'\''t ensure connection from outside." >&2
  259. exit 1
  260. fi
  261. fi
  262. '
  263. if [ "$?" != 0 ]; then
  264. echo "Error: can't update pg_hba.conf" >&2
  265. else
  266. docker-compose restart postgres
  267. fi
  268. #+END_SRC
  269. ***** Create odoo table and odoo user
  270. #+BEGIN_SRC shell
  271. docker-compose exec -T postgres bash -c \
  272. 'PGUSER=postgres createdb $PG_DATABASE'
  273. docker-compose exec -T postgres bash -c \
  274. 'PGUSER=postgres psql "$PG_DATABASE"' \
  275. <<<'CREATE EXTENSION IF NOT EXISTS unaccent;'
  276. docker-compose exec -T postgres bash -c \
  277. 'PGUSER=postgres psql <<<"CREATE USER \"$PG_USER\" WITH PASSWORD '\''$PG_PASS'\'' CREATEDB NOCREATEROLE;"'
  278. docker-compose exec -T postgres bash -c \
  279. 'PGUSER=postgres prefix_pg_local_command=" " pgm chown $PG_USER $PG_DATABASE'
  280. #+END_SRC