diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..fa0b483c --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,7 @@ +FROM node:latest +EXPOSE 13120 +WORKDIR / +#COPY config/default.json /data/gancio/config/gancio_config.json +RUN yarn global add gancio +#ENTRYPOINT ["gancio", "--config", "/gancio/config.json"] +#CMD ["gancio", "start", "--config", "/data/gancio/gancio_config.json"] diff --git a/docker/db.sqlite b/docker/db.sqlite new file mode 100644 index 00000000..ad63406a Binary files /dev/null and b/docker/db.sqlite differ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 00000000..efddd8e6 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,33 @@ +version: '3' + +services: + db: + image: postgres + container_name: postgres + volumes: + - ./init.sql:/docker-entrypoint-initdb.d/init.sql + - db:/var/lib/postgres + - /etc/localtime:/etc/localtime:ro + environment: + - POSTGRES_USER=gancio + - POSTGRES_DB=gancio + - POSTGRES_PASSWORD=gancio + restart: always + ports: + - 5432:5432 + gancio: + build: . + image: node:latest + container_name: gancio + command: gancio start /gancio/config.json + volumes: + - ./db.sqlite:/gancio/db.sqlite + - ./config.json:/gancio/config.json + - ./uploads:/gancio/uploads + depends_on: + - db + ports: + - 13120:13120 +volumes: + db: + gancio: diff --git a/docker/init.db b/docker/init.db new file mode 100644 index 00000000..e69de29b diff --git a/docs/_config.yml b/docs/_config.yml index 206fe112..0066e4db 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -17,8 +17,8 @@ title: Gancio email: gancio@cisti.org description: >- # this means to ignore newlines until "baseurl:" A shared agenda for local communities -baseurl: "" # the subpath of your site, e.g. /blog -url: "" # the base hostname & protocol for your site, e.g. http://example.com +baseurl: "/gancio" # the subpath of your site, e.g. /blog +url: "https://prove.fugadalcontrollo.org" # the base hostname & protocol for your site, e.g. http://example.com #twitter_username: jekyllrb #github_username: jekyll diff --git a/docs/index.md b/docs/index.md index e44177ef..b239ee75 100644 --- a/docs/index.md +++ b/docs/index.md @@ -12,7 +12,7 @@ permalink: / A shared agenda for local communities. {: .fs-6 } -[Get started now](/setup){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } [Demo](https://gancio.cisti.org){: .btn .btn-green .fs-5 .mb-4 .mb-md-0 } +[Get started now](/setup){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } [Demo](https://demo.fugadalcontrollo.org){: .btn .btn-green .fs-5 .mb-4 .mb-md-0 } [Source](https://git.lattuga.net/cisti/gancio){: .btn .fs-5 } diff --git a/docs/setup/classic.md b/docs/setup/classic.md index 2ba79d69..35b11b22 100644 --- a/docs/setup/classic.md +++ b/docs/setup/classic.md @@ -7,13 +7,13 @@ 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 ``` @@ -26,19 +26,40 @@ postgres=# create user gancio with encrypted password 'gancio'; postgres=# grant all privileges on database gancio to gancio; ``` -4. Create a new user +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 ``` -5. Setup & test +1. Test & launch interactive setup +```bash +gancio --help +gancio setup +``` + +1. Start ```bash gancio --help gancio setup gancio start ``` +1. Point your web browser to [http://localhost:13120](http://localhost:13120) or where you selected during setup. -6. Enjoy :tada: -Point your web browser to [http://localhost:3000](http://localhost:3000) +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/package.json b/package.json index e13e4612..fe91b959 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gancio", - "version": "0.9.31", + "version": "0.10.0", "description": "A shared agenda for local communities", "author": "lesion", "scripts": { @@ -8,6 +8,7 @@ "build": "nuxt build", "start": "cross-env NODE_ENV=production node server/cli.js", "lint": "eslint --ext .js,.vue --ignore-path .gitignore .", + "doc": "cd docs && bundle exec jekyll b", "precommit": "npm run lint", "migrate:dev": "sequelize db:migrate", "migrate": "NODE_ENV=production sequelize db:migrate" 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)