From fa03c48db32bfb6d3ed57f214a0643c5ca9cab08 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 11 Oct 2019 17:03:18 +0200 Subject: [PATCH] Update docs and support Signed-off-by: Thomas Citharel --- support/guides/development/development.md | 25 ++++-------- support/guides/development/styleguide.md | 10 ++++- support/guides/development/tests.md | 20 +++++++++- support/guides/install/install.md | 39 +++++++++++-------- .../nginx/{mobilizon.vhost => mobilizon.conf} | 18 +++++++++ 5 files changed, 74 insertions(+), 38 deletions(-) rename support/nginx/{mobilizon.vhost => mobilizon.conf} (82%) diff --git a/support/guides/development/development.md b/support/guides/development/development.md index cb96f1f3e..b1fca76d5 100644 --- a/support/guides/development/development.md +++ b/support/guides/development/development.md @@ -6,19 +6,20 @@ make ``` ## Manual -### Server - * Install dependencies: - * Elixir (and Erlang) by following the instructions at [https://elixir-lang.github.io/install.html](https://elixir-lang.github.io/install.html) - * Fetch backend Elixir dependencies with `mix deps.get`. * [PostgreSQL]() with PostGIS + * Install NodeJS (we guarantee support for the latest LTS and later) ![](https://img.shields.io/badge/node-%3E%3D%2010.0+-brightgreen.svg) * Start services: * Start postgres * Setup services: * Make sure the postgis extension is installed on your system. * Create a postgres user with database creation capabilities, using the following: `createuser -d -P mobilizon` and set `mobilizon` as the password. + * Install packages + * Fetch backend Elixir dependencies with `mix deps.get`. + * Go into the `cd js` directory, `yarn install` and then back `cd ../` + * Setup * Create your database with `mix ecto.create`. * Create the postgis extension on the database with a postgres user that has superuser capabilities: `psql mobilizon_dev` @@ -26,23 +27,11 @@ make ``` create extension if not exists postgis; ``` * Run migrations: `mix ecto.migrate`. - * Start Phoenix endpoint with `mix phx.server`. + * Start Phoenix endpoint with `mix phx.server`. The client development server will also automatically be launched and will reload on file change. Now you can visit [`localhost:4000`](http://localhost:4000) in your browser and see the website (server *and* client) in action. -### Client - -If you plan to specifically change the client side (front-end), do the following -once the server is running: - - * Install NodeJS (we guarantee support for the latest LTS and later) ![](https://img.shields.io/badge/node-%3E%3D%2010.0+-brightgreen.svg) - * Change directory to `js/` and do: - * Install JavaScript package dependencies: `yarn install`. - * Run the development server in watch mode: `yarn run dev`. This will open a - browser at [`localhost:8080`](http://localhost:8080) that gets - automatically reloaded on change. - ## Docker You need to install the latest supported [Docker](https://docs.docker.com/install/#supported-platforms) and [Docker-Compose](https://docs.docker.com/compose/install/) before using the Docker way of installing Mobilizon. @@ -50,4 +39,4 @@ Just run : ```bash make start ``` -to start a database container, an API container and the front-end dev container running on localhost. +to build and launch a database container and an API container running on localhost. diff --git a/support/guides/development/styleguide.md b/support/guides/development/styleguide.md index 5670dcadd..7965df7b9 100644 --- a/support/guides/development/styleguide.md +++ b/support/guides/development/styleguide.md @@ -12,11 +12,17 @@ These two commands must not return an error code, since they are required to pas ## Front-end -We use `tslint` with the `tslint-config-airbnb` preset. -Errors should be reported when running in dev mode `yarn run dev` or when building a production bundle `yarn run build`. +### Linting + +We use `tslint` and `eslint` with the `airbnb` preset. +Errors should be reported when the development server is running or when building a production bundle `yarn run build`. Please run the following command before pushing code `yarn run lint`. This command must not return an error code, since it's required to pass inside CI. We also try to follow the [official Vue.js style guide](https://vuejs.org/v2/style-guide/). + +### Styleguide + +We present the components used on Mobilizon's front-end here: https://framasoft.frama.io/mobilizon/frontend/. The documentation is builded through [Vue Styleguidist](https://vue-styleguidist.github.io/) \ No newline at end of file diff --git a/support/guides/development/tests.md b/support/guides/development/tests.md index ab180ccfd..003a01d3b 100644 --- a/support/guides/development/tests.md +++ b/support/guides/development/tests.md @@ -33,4 +33,22 @@ mix test test/mobilizon/actors/actors_test.exs:85 ## Front-end -Waiting for [https://framagit.org/framasoft/mobilizon/merge_requests/42](https://framagit.org/framasoft/mobilizon/merge_requests/42) to be ready. +### Unit tests + +Not done yet. + +### End-to-end tests + +We use [Cypress](https://cypress.io) for End-to-end testing. + +When inside the `js` directory, you can do either +```bash +npx cypress run +``` +to run the tests, or +```bash +npx cypress open +``` +to open the interactive GUI. + +Cypress provided [a subscription](https://www.cypress.io/oss-plan) to their recording dashboard since Mobilizon is an Open-Source project. Thanks! \ No newline at end of file diff --git a/support/guides/install/install.md b/support/guides/install/install.md index baccbba8e..a4da4d074 100644 --- a/support/guides/install/install.md +++ b/support/guides/install/install.md @@ -86,23 +86,6 @@ Finally, build the front-end with yarn run build ``` -### Testing - -Go back to the previous directory - -```bash -cd .. -``` - -Now try to run the server - -```bash -mix phx.server -``` - -It runs on port 4000. - - ## Services ### Systemd @@ -130,3 +113,25 @@ It will run Mobilizon and enable startup on boot. You can follow the logs with ```bash sudo journalctl -fu mobilizon.service ``` + +The Elixir server runs on port 4000 on the local interface only, so you need to add a reverse-proxy. + +## Reverse proxy + +### Nginx + +Copy the file from `support/nginx/mobilizon.conf` to `/etc/nginx/sites-available`. + +```bash +sudo cp support/nginx/mobilizon.conf /etc/nginx/sites-available +``` + +Then symlink the file into the `/etc/nginx/sites-enabled` directory. + +```bash +sudo ln -s /etc/nginx/sites-available/mobilizon.conf /etc/nginx/sites-enabled/ +``` + +Edit the file `/etc/nginx/sites-available` and adapt it to your own configuration. + +Test the configuration with `sudo nginx -t` and reload nginx with `systemctl reload nginx`. \ No newline at end of file diff --git a/support/nginx/mobilizon.vhost b/support/nginx/mobilizon.conf similarity index 82% rename from support/nginx/mobilizon.vhost rename to support/nginx/mobilizon.conf index 66d34d2f5..762fa94f4 100644 --- a/support/nginx/mobilizon.vhost +++ b/support/nginx/mobilizon.conf @@ -34,6 +34,8 @@ server { ssl_stapling on; ssl_stapling_verify on; + gzip on; + gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; @@ -45,13 +47,29 @@ server { client_max_body_size 16m; location / { + gzip off; proxy_http_version 1.1; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # For Websocket support proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; + proxy_redirect off; + proxy_pass http://localhost:4000; client_max_body_size 16m; } + + location ~* \.(css|js)$ { + root /var/www/mobilizon/priv/static; + etag off; + expires 1y; + access_log off; + add_header Cache-Control public; + } + }