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.

345 lines
8.7 KiB

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