diff --git a/docs/setup/classic.md b/docs/setup/classic.md index ff07913a..3033dfb4 100644 --- a/docs/setup/classic.md +++ b/docs/setup/classic.md @@ -7,28 +7,49 @@ parent: Setup ## Classic setup -1. Install Node.js +1. Install Node.js and postgreSQL ```bash curl -sL https://deb.nodesource.com/setup_12.x | bash - -apt-get install -y nodejs +apt-get install -y nodejs postgresql ``` [source](https://github.com/nodesource/distributions/blob/master/README.md) -2. Install Gancio +1. Install Gancio ```bash npm install --global gancio ``` -3. Setup +1. Create a database (optional as you can use sqlite, but recommended) ```bash +sudo -u postgres psql +postgres=# create database gancio; +postgres=# create user gancio with encrypted password 'gancio'; +postgres=# grant all privileges on database gancio to gancio; +``` + +1. Create a user to run gancio from +```bash +adduser gancio +su gancio +``` + +1. Test & launch interactive setup +```bash +gancio --help gancio setup ``` -4. Start +1. Start ```bash gancio start ``` -5. Enjoy :tada: -Point your web browser to [http://localhost:3000](http://localhost:3000) +1. Point your web browser to [http://localhost:13120](http://localhost:13120) or where you selected during setup. +1. [Setup nginx as a proxy](/setup/nginx) +1. Deploy in production +If you don't use the [docker way](/setup/docker), in production you should use something like **[pm2](http://pm2.keymetrics.io/)**: +```bash +sudo npm install --global pm2 +pm2 gancio start +``` diff --git a/docs/setup/dev.md b/docs/setup/dev.md new file mode 100644 index 00000000..3033dfb4 --- /dev/null +++ b/docs/setup/dev.md @@ -0,0 +1,55 @@ +--- +layout: default +title: Classic +permalink: /setup/classic +parent: Setup +--- + +## Classic setup + +1. Install Node.js and postgreSQL +```bash +curl -sL https://deb.nodesource.com/setup_12.x | bash - +apt-get install -y nodejs postgresql +``` +[source](https://github.com/nodesource/distributions/blob/master/README.md) +1. Install Gancio +```bash +npm install --global gancio +``` + +1. Create a database (optional as you can use sqlite, but recommended) +```bash +sudo -u postgres psql +postgres=# create database gancio; +postgres=# create user gancio with encrypted password 'gancio'; +postgres=# grant all privileges on database gancio to gancio; +``` + +1. Create a user to run gancio from +```bash +adduser gancio +su gancio +``` + +1. Test & launch interactive setup +```bash +gancio --help +gancio setup +``` + +1. Start +```bash +gancio start +``` +1. Point your web browser to [http://localhost:13120](http://localhost:13120) or where you selected during setup. + +1. [Setup nginx as a proxy](/setup/nginx) + +1. Deploy in production +If you don't use the [docker way](/setup/docker), in production you should use something like **[pm2](http://pm2.keymetrics.io/)**: + +```bash +sudo npm install --global pm2 +pm2 gancio start +``` diff --git a/docs/setup/docker.md b/docs/setup/docker.md index ff6036b3..ed009e19 100644 --- a/docs/setup/docker.md +++ b/docs/setup/docker.md @@ -7,4 +7,38 @@ parent: Setup ## Install with docker +**You do not need to clone the full repo as we distribute gancio via npm.** +[Dockerfile](https://git.lattuga.net/cisti/gancio/raw/docker/docker/Dockerfile) and [docker-compose.yml](https://git.lattuga.net/cisti/gancio/raw/docker/docker/docker-compose.yml) are the only needed files. +1. Create a directory where everything related to gancio is stored (db, images, config) +```bash +mkdir /opt/gancio +cd /opt/gancio +``` +:information_source: you can choose a different directory of course + +1. Download docker-compose.yml and Dockerfile +```bash +wget https://git.lattuga.net/cisti/gancio/raw/docker/docker/Dockerfile +wget https://git.lattuga.net/cisti/gancio/raw/docker/docker/docker-compose.yml +``` + +1. Create an empty configuration file +``` +touch config.json +``` +After first setup, you can modify this file and restart the container on your needs. + +1. Build docker image and launch interactive setup in one step +``` +docker-compose run --rm gancio gancio setup +``` + +1. Run your container +```bash +docker-compose up -d +``` + +1. [Setup nginx as a proxy](/setup/nginx) + +1. Point your web browser to [http://localhost:13120](http://localhost:13120) or where you specified during setup and enjoy :tada: \ No newline at end of file diff --git a/docs/setup/nginx.md b/docs/setup/nginx.md new file mode 100644 index 00000000..6c529f53 --- /dev/null +++ b/docs/setup/nginx.md @@ -0,0 +1,71 @@ +--- +layout: default +title: Nginx +permalink: /setup/nginx +parent: Setup +--- + +## Nginx proxy configuration +This is the default nginx configuration for gancio, please modify at least the **server_name** and **ssl_certificate**'s path + +```nginx +server { + listen 80; + listen [::]:80; + server_name gancio.cisti.org; + root /var/www/letsencrypt; + location /.well-known/acme-challenge/ { allow all; } + location / { return 301 https://$host$request_uri; } +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name gancio.cisti.org; + + ssl_protocols TLSv1.2; + ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA; + ssl_prefer_server_ciphers on; + ssl_session_cache shared:SSL:10m; + + # Uncomment these lines once you acquire a certificate: + # ssl_certificate /etc/letsencrypt/live/gancio.cisti.org/fullchain.pem; + # ssl_certificate_key /etc/letsencrypt/live/gancio.cisti.org/privkey.pem; + + keepalive_timeout 70; + sendfile on; + client_max_body_size 80m; + + gzip on; + gzip_disable "msie6"; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + add_header Strict-Transport-Security "max-age=31536000"; + + location / { + try_files $uri @proxy; + } + + location @proxy { + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Proxy ""; + proxy_pass_header Server; + + proxy_pass http://127.0.0.1:13120; + proxy_buffering on; + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + + tcp_nodelay on; + } +} + +``` \ No newline at end of file diff --git a/docs/setup/setup.md b/docs/setup/setup.md index ea91f09b..161fd097 100644 --- a/docs/setup/setup.md +++ b/docs/setup/setup.md @@ -4,9 +4,13 @@ title: Setup permalink: /setup has_children: true nav_order: 2 +has_toc: false --- # Setup -You would setup **Gancio** for different scenario -{: .fs-6 } \ No newline at end of file + +- ## [Setup with docker](/setup/docker) +- ## [Classic setup](/setup/classic) +- ## [Nginx as a proxy](/setup/nginx) +- ## [Hacking & contribute](/dev) \ No newline at end of file diff --git a/server/cli.js b/server/cli.js index 1d8f4991..1655c9ac 100755 --- a/server/cli.js +++ b/server/cli.js @@ -188,7 +188,7 @@ require('yargs') .option('config', { alias: 'c', describe: 'Configuration file', - default: './gancio_config.json', + default: '/gancio/config.json', }) .coerce('config', config_path => { const absolute_config_path = path.resolve(cwd, config_path)