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.

273 lines
6.7 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. **** TODO Deployment
  61. ** Usage
  62. *** using =compose=
  63. You need to create a =compose.yml= that suits your need. You can
  64. create it wherever you want as long as either you launch =compose= in
  65. a sub-directory or you specify the location of the =compose= file with
  66. the =-f COMPOSEFILE= option. Here's a good start:
  67. #+BEGIN_SRC shell
  68. cat <<EOF > compose.yml
  69. odoo:
  70. charm: odoo-tecnativa
  71. # docker-compose:
  72. # ## Important to keep as a list: otherwise it'll overwrite charm's arguments.
  73. # command:
  74. # - "--log-level=debug"
  75. # environment:
  76. # TOTO: TATA
  77. # image: mynewimage
  78. # options:
  79. # workers: 1
  80. # modules: ## 'base' is automatically added
  81. # - l10n_fr
  82. # - mymodule
  83. # database: mybase ## defaults to database in relation
  84. EOF
  85. #+END_SRC
  86. You can then launch the service(s) with:
  87. #+BEGIN_SRC shell
  88. compose up
  89. #+END_SRC
  90. *** using =docker-compose=
  91. If you are NOT using =compose= and are using =docker-compose=, (for
  92. instance because you are on windows and want to stay in the official
  93. way to install docker.
  94. You'll need also to initialize the postgres database.
  95. **** Creating =docker-compose.yml=
  96. You can run this instructions from your bash to create both =.env= and
  97. =docker-compose.yml= files:
  98. #+BEGIN_SRC shell
  99. cat <<EOF > .env
  100. ## Location of the charm-store (to build postgres)
  101. CHARM_STORE=~/.charm-store
  102. ## Password for postgres's 'odoo' user
  103. PG_DATABASE=odoo
  104. PG_USER=odoo
  105. PG_PASS=odoopassword
  106. ## Password for odoo admin tasks (create/delete/archive databases)
  107. ODOO_ADMIN_PASSWORD=adminpass
  108. ## Password for postgres admin user 'postgres'
  109. POSTGRES_ROOT_PASSWORD=postgresrootpassword
  110. EOF
  111. cat <<EOF > docker-compose.yml
  112. version: '2.0'
  113. services:
  114. odoo:
  115. command:
  116. - odoo
  117. - --config=/opt/odoo/auto/odoo.conf
  118. - --workers=1
  119. - -i base,l10n_fr
  120. - --database=odoo
  121. environment:
  122. ADMIN_PASSWORD: \${ODOO_ADMIN_PASSWORD}
  123. INITIAL_LANG: fr_FR
  124. LIST_DB: 'true'
  125. PGDATABASE: \${PG_DATABASE}
  126. PGHOST: postgres
  127. PGPASSWORD: \${PG_PASS}
  128. PGUSER: \${PG_USER}
  129. image: docker.0k.io/mirror/odoo:rc_13.0-MYC-INIT
  130. links:
  131. - postgres
  132. restart: unless-stopped
  133. tty: true
  134. volumes:
  135. ## Volume is changed from normal 'compose' build
  136. - odoo-data:/var/lib/odoo:rw
  137. postgres:
  138. build: \${CHARM_STORE}/postgres/build
  139. restart: unless-stopped
  140. volumes:
  141. ## Volume is changed from normal 'compose' build
  142. - postgres-data:/var/lib/postgresql/data:rw
  143. ## Was added, differing from the normal 'compose' build
  144. environment:
  145. - POSTGRES_ROOT_PASSWORD
  146. - PG_DATABASE
  147. - PG_USER
  148. - PG_PASS
  149. ## new section
  150. volumes:
  151. odoo-data:
  152. postgres-data:
  153. EOF
  154. #+END_SRC
  155. You can then run:
  156. #+BEGIN_SRC shell
  157. docker-compose up -d
  158. #+END_SRC
  159. **** initialisation
  160. This is only needed if you use the 'docker-compose' method. You need
  161. to do it once.
  162. ***** Set master password and allow access from odoo container
  163. container 'postgres' needs to be up before running the following:
  164. You need to do this only once.
  165. #+BEGIN_SRC sh
  166. ## Update postgres password
  167. docker-compose exec -T postgres bash -c \
  168. 'PGUSER=postgres psql <<<"ALTER USER postgres WITH ENCRYPTED password "'\\\''$POSTGRES_ROOT_PASSWORD'\\\'
  169. ## Set pg_hba.conf
  170. docker-compose exec -T postgres bash -c '
  171. PG_HBA=/var/lib/postgresql/data/pg_hba.conf
  172. if ! grep -E "^host all all (0.0.0.0/0|all) md5\$" "$PG_HBA" >/dev/null 2>&1; then
  173. if grep -E "^host all all (0.0.0.0/0|all) trust\$" "$PG_HBA" >/dev/null 2>&1; then
  174. sed -ri '\''s%^host all all (0\.0\.0\.0/0|all) trust$%host all all \1 md5%g'\'' \
  175. "$PG_HBA"
  176. echo "Accepting connection from outside."
  177. else
  178. echo "Can'\''t ensure connection from outside." >&2
  179. exit 1
  180. fi
  181. fi
  182. '
  183. if [ "$?" != 0 ]; then
  184. echo "Error: can't update pg_hba.conf" >&2
  185. else
  186. docker-compose restart postgres
  187. fi
  188. #+END_SRC
  189. ***** Create odoo table and odoo user
  190. #+BEGIN_SRC shell
  191. docker-compose exec -T postgres bash -c \
  192. 'PGUSER=postgres createdb $PG_DATABASE'
  193. docker-compose exec -T postgres bash -c \
  194. 'PGUSER=postgres psql "$PG_DATABASE"' \
  195. <<<'CREATE EXTENSION IF NOT EXISTS unaccent;'
  196. docker-compose exec -T postgres bash -c \
  197. 'PGUSER=postgres psql <<<"CREATE USER \"$PG_USER\" WITH PASSWORD '\''$PG_PASS'\'' CREATEDB NOCREATEROLE;"'
  198. docker-compose exec -T postgres bash -c \
  199. 'PGUSER=postgres prefix_pg_local_command=" " pgm chown $PG_USER $PG_DATABASE'
  200. #+END_SRC