]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/blob - README.md
update README.
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git] / README.md
1 # Cryptoportfolio app
2
3 Back and front end for cryptoportfolio project.
4
5 Server binaries and webapp files are shipped to Github. No need to install dev dependencies to deploy it. All you need is [ansible](http://docs.ansible.com/ansible/latest/intro_installation.html#installing-the-control-machine)
6
7 - [Deploy](#deploy) : deploy server binaries and webapp archive to a server with ansible
8 - [Server](#server) : server written in golang
9 - [Webapp](#webapp) : JS (React)
10 - [Release](#release) : release server binaries and webapp archive to github with ansible.
11
12 Dir tree
13 ```
14 |- api/*.go api endpoints
15 |- db/*.go database models
16 |- cmd/
17 | |--- app/
18 | |-- Makefile
19 | |-- conf.toml server configuration file (dev)
20 | |-- main.go server entry point
21 | |--- ansible/
22 | |-- ansible.cfg
23 | |-- hosts
24 | |-- requirements.yml
25 | |-- conf.toml.j2 server configuration file (prod)
26 | |-- cryptoportfolio-app.j2 server systemd file
27 | |-- vars.yml playbook variables (vault)
28 | |-- release.yml release playbook
29 | |-- deploy.yml deploy playbook
30 | |--- web/
31 | |-- env/ app environments
32 | |-- dev.env
33 | |-- prod.env
34 | |-- js/ js source code
35 | |-- static/ index.html and style.css
36 ```
37 ## Server
38 #### Install
39 ##### Golang installation (if needed)
40 1. Download right package at [https://golang.org/dl](https://golang.org/dl)
41 2. Install it
42 ```
43 tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
44
45 export PATH=$PATH:/usr/local/go/bin
46 ```
47 #### Fetch dependencies
48 Simply run at the root of project :
49 ```
50 make install
51 ```
52 #### Run locally
53 You need postgres running on `localhost:5432` and the following setup:
54 ```
55 CREATE USER cryptoportfolio;
56 ALTER USER cryptoportfolio WITH ENCRYPTED PASSWORD 'cryptoporfolio-dev';
57 ALTER ROLE cryptoportfolio WITH CREATEDB ;
58 CREATE DATABASE cryptoportfolio OWNER cryptoportfolio;
59 ```
60 Then run the app in cmd/app:
61 ```
62 cd cmd/app
63 make run
64 ```
65 ## Webapp
66 #### Install
67 You will need `npm`, `node` and `yarn`, then:
68 ```
69 cd cmd/web
70 make install
71 ```
72
73 #### Build local webapp
74 ```
75 make static ENV=dev
76 ```
77 Files are now ready to be served by server.
78
79 ## Ansible install requirements
80 ```
81 cd cmd/ansible
82
83 ansible-galaxy install -r requirements.yml
84 ```
85 ## Releasing
86 To release, you need to have all dev environments setup for server and webapp. The token used to push to Github is in cmd/ansible/vars.yml. You need a password to decrypt this file. Ask me. You need to store this password in a file such as `~/.vault_cryptoportfolio_pass.txt`
87
88 You can then run the release.yml playbook, don't forget to provide a the release version :
89 ```
90 cd cmd/ansible
91
92 ansible-playbook release.yml --extra-vars "version=X.X.X" --vault-password-file=~/.vault_cryptoportfolio_pass.txt
93 ```
94 ## Deploy
95 change `hosts` file :
96 ```
97 [jloup-home]
98 jlj.am
99
100 [jloup-home:vars]
101 ansible_port=21
102 ansible_user=ansible-deploy # This user will be used to carry out operation on remote machine
103 # To make it work, this user should not be prompted for password when sudo
104 # else you need to pass --ask-sudo-pass when running playbook
105
106 app_user=jloup # user that will run the app service
107 app_domain=jlj.am
108
109 postgres_database=cryptoportfolio
110 postgres_user=cryptoportfolio
111 postgres_password=cryptoportfolio-dev
112
113 linux_arch=386 # your machine arch. should be one if [386, amd64]
114 ```
115
116 ```
117 cd cmd/ansible
118
119 ansible-playbook deploy.yml --extra-vars "version=X.X.X" --vault-password-file=~/.vault_cryptoportfolio_pass.txt
120 ```