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.

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