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.

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