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.

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