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.

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