From 7722b55a64b6e5e4601180f51e2db2cee17e0f23 Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Thu, 20 Jul 2017 17:17:43 +0200 Subject: [PATCH 01/10] fix table of contents --- docker/README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docker/README.md b/docker/README.md index f7b18d84c..6f2ac8d93 100644 --- a/docker/README.md +++ b/docker/README.md @@ -5,26 +5,26 @@ In order to make it work, please use the same directories structure as described ##### Table of contents -1. [Preliminary steps](#preliminary-steps) -1.1. [docker/env file](#docker-env) -1.2. [docker/nginx_with_ssl.conf.example file](#nginx-conf) -1.3. [setup the server](#setup-server) -1.4. [buy a domain name and link it with the droplet](#buy-domain-link-droplet) -1.5. [connect to the droplet via SSH](#connect-to-droplet) -1.6. [create SWAP file in coreOs](#create-swap-file) -1.7. [setup folders and env file](#setup-folders-env-file) -1.8. [SSL certificate with LetsEncrypt](#ssl-certificate-letsencrypt) +1. [Preliminary steps](#preliminary-steps))
+1.1. [docker/env file](#docker-env))
+1.2. [docker/nginx_with_ssl.conf.example file](#nginx-conf))
+1.3. [setup the server](#setup-server))
+1.4. [buy a domain name and link it with the droplet](#buy-domain-link-droplet))
+1.5. [connect to the droplet via SSH](#connect-to-droplet))
+1.6. [create SWAP file in coreOs](#create-swap-file))
+1.7. [setup folders and env file](#setup-folders-env-file))
+1.8. [SSL certificate with LetsEncrypt](#ssl-certificate-letsencrypt))
1.9. [install docker-compose](#install-docker-compose) -2. [Deployment](#deployment) -2.1. [pull images](#pull-images) -2.2. [setup database](#setup-database) -2.3. [build assets](#build-assets) -2.4. [prepare Elasticsearch (search engine)](#prepare-elastic) +2. [Deployment](#deployment))
+2.1. [pull images](#pull-images))
+2.2. [setup database](#setup-database))
+2.3. [build assets](#build-assets))
+2.4. [prepare Elasticsearch (search engine)](#prepare-elastic))
2.5. [start all services](#start-services) 3. [Generate SSL certificate by Letsencrypt](#generate-sll-cert-letsencrypt) 4. [Docker utils](#docker-utils) -5. [Fabmanager update](#update-fabmanager) -5.1. [Steps](#update-steps) +5. [Fabmanager update](#update-fabmanager))
+5.1. [Steps](#update-steps))
5.2. [Good to know](#good-to-know) ## Preliminary steps From 1833ac2890a31c1d37e4045be741d08caf93b664 Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Thu, 20 Jul 2017 17:18:19 +0200 Subject: [PATCH 02/10] arg --- docker/README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docker/README.md b/docker/README.md index 6f2ac8d93..33be4cc73 100644 --- a/docker/README.md +++ b/docker/README.md @@ -5,26 +5,26 @@ In order to make it work, please use the same directories structure as described ##### Table of contents -1. [Preliminary steps](#preliminary-steps))
-1.1. [docker/env file](#docker-env))
-1.2. [docker/nginx_with_ssl.conf.example file](#nginx-conf))
-1.3. [setup the server](#setup-server))
-1.4. [buy a domain name and link it with the droplet](#buy-domain-link-droplet))
-1.5. [connect to the droplet via SSH](#connect-to-droplet))
-1.6. [create SWAP file in coreOs](#create-swap-file))
-1.7. [setup folders and env file](#setup-folders-env-file))
-1.8. [SSL certificate with LetsEncrypt](#ssl-certificate-letsencrypt))
+1. [Preliminary steps](#preliminary-steps)
+1.1. [docker/env file](#docker-env)
+1.2. [docker/nginx_with_ssl.conf.example file](#nginx-conf)
+1.3. [setup the server](#setup-server)
+1.4. [buy a domain name and link it with the droplet](#buy-domain-link-droplet)
+1.5. [connect to the droplet via SSH](#connect-to-droplet)
+1.6. [create SWAP file in coreOs](#create-swap-file)
+1.7. [setup folders and env file](#setup-folders-env-file)
+1.8. [SSL certificate with LetsEncrypt](#ssl-certificate-letsencrypt)
1.9. [install docker-compose](#install-docker-compose) -2. [Deployment](#deployment))
-2.1. [pull images](#pull-images))
-2.2. [setup database](#setup-database))
-2.3. [build assets](#build-assets))
-2.4. [prepare Elasticsearch (search engine)](#prepare-elastic))
+2. [Deployment](#deployment)
+2.1. [pull images](#pull-images)
+2.2. [setup database](#setup-database)
+2.3. [build assets](#build-assets)
+2.4. [prepare Elasticsearch (search engine)](#prepare-elastic)
2.5. [start all services](#start-services) 3. [Generate SSL certificate by Letsencrypt](#generate-sll-cert-letsencrypt) 4. [Docker utils](#docker-utils) -5. [Fabmanager update](#update-fabmanager))
-5.1. [Steps](#update-steps))
+5. [Fabmanager update](#update-fabmanager)
+5.1. [Steps](#update-steps)
5.2. [Good to know](#good-to-know) ## Preliminary steps From aa4ef99d0275d006d0b864b3ff2aca733191fb7f Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Thu, 20 Jul 2017 17:37:03 +0200 Subject: [PATCH 03/10] work in progress --- docker/README.md | 82 +++++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/docker/README.md b/docker/README.md index 33be4cc73..289840c39 100644 --- a/docker/README.md +++ b/docker/README.md @@ -27,49 +27,48 @@ In order to make it work, please use the same directories structure as described 5.1. [Steps](#update-steps)
5.2. [Good to know](#good-to-know) -## Preliminary steps +## Preliminary steps -### docker/env file +### docker/env file -Make a copy of the **env.example** and use it as a starting point. +Make a copy of the **docker/env.example** file and use it as a starting point. Set all the environment variables needed by your application. Please refer to the [FabManager README](https://github.com/LaCasemate/fab-manager/blob/master/README.md) for explanations about those variables. -### docker/nginx_with_ssl.conf.example file +### docker/nginx_with_ssl.conf.example file * Replace **MAIN_DOMAIN** (example: fab-manager.com). * Replace **URL_WITH_PROTOCOL_HTTPS** (example: https://www.fab-manager.com). * Replace **ANOTHER_URL_1**, **ANOTHER_URL_2** (example: .fab-manager.fr) -Side note: -* Use nginx.conf.example if you are not using **SSL** +**Use nginx.conf.example if you don't want SSL for your app.** -### setup the server +### setup the server -Go to **DigitalOcean** and create a Droplet with operating system coreOS **stable**. +Go to [DigitalOcean](https://www.digitalocean.com/) and create a Droplet with operating system coreOS **stable**. You need at least 2GB of addressable memory (RAM + swap) to install and use FabManager. Choose a datacenter. Set the hostname as your domain name. -### buy a domain name and link it with the droplet +### buy a domain name and link it with the droplet -1. Buy a domain name on OVH +1. Buy a domain name on [OVH](https://www.ovh.com/fr/) 2. Replace the IP address of the domain with the droplet's IP (you can enable the flexible ip and use it) 3. **Do not** try to access your domain name right away, DNS are not aware of the change yet so **WAIT** and be patient. -### connect to the droplet via SSH +### connect to the droplet via SSH You can already connect to the server with this command: `ssh core@droplet-ip`. When DNS propagation will be done, you will be able to connect to the server with `ssh core@your-domain-name`. -### create SWAP file in coreOS +### create SWAP file in coreOS -Firstly, switch to sudo and create a swap file +Switch to sudo and create a swap file: ```bash sudo -i @@ -97,7 +96,7 @@ ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d $(/usr/sbin/losetup -j ${SWAPF WantedBy=multi-user.target ``` -Then add service and start: +Then enable the service and start it: ```bash systemctl enable /etc/systemd/system/swap.service @@ -105,27 +104,32 @@ systemctl start swap exit ``` -### setup folders and env file +### setup folders and env file +Create the config folder: ```bash mkdir -p /home/core/fabmanager/config ``` -Copy the previously customized `env.example` file as `/home/core/fabmanager/config/env` +Then, copy the previously customized `env.example` file as `/home/core/fabmanager/config/env` +Create the nginx folder: ```bash mkdir -p /home/core/fabmanager/config/nginx ``` +Then, Copy the previously customized `nginx_with_ssl.conf.example` as `/home/core/fabmanager/config/nginx/fabmanager.conf` -OR -Copy the previously customized `nginx.conf.example` as `/home/core/fabmanager/config/nginx/fabmanager.conf` if you do not want ssl support (not recommended !). -### SSL certificate with LetsEncrypt +**OR** + +Copy the previously customized `nginx.conf.example` as `/home/core/fabmanager/config/nginx/fabmanager.conf` if you do not want to use ssl (not recommended !). + +### SSL certificate with LetsEncrypt -*TO BE READ ONLY IF YOU WANT TO USE SSL*. +**FOLLOW THOSE INSTRUCTIONS ONLY IF YOU WANT TO USE SSL**. Let's Encrypt is a new Certificate Authority that is free, automated, and open. Let’s Encrypt certificates expire after 90 days, so automation of renewing your certificates is important. @@ -175,8 +179,8 @@ WantedBy=timers.target That's all for the moment. Keep on with the installation, we'll complete that part after deployment in the [Generate SSL certificate by Letsencrypt](#generate-ssl-cert-letsencrypt). -### Install docker-compose +### Install docker-compose ```bash curl -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > ./docker-compose @@ -187,18 +191,18 @@ sudo chmod +x /opt/bin/docker-compose Then copy docker-compose.yml to your app folder `/home/core/fabmanager`. -## Deployment +## Deployment -### pull images +### pull images ```bash docker-compose pull ``` -### setup database +### setup database ```bash docker-compose run --rm fabmanager bundle exec rake db:create # create the database @@ -206,23 +210,23 @@ docker-compose run --rm fabmanager bundle exec rake db:migrate # run all the mig docker-compose run --rm fabmanager bundle exec rake db:seed # seed the database ``` -### build assets +### build assets `docker-compose run --rm fabmanager bundle exec rake assets:precompile` -### prepare Elasticsearch (search engine) +### prepare Elasticsearch (search engine) `docker-compose run --rm fabmanager bundle exec rake fablab:es_build_stats` -#### start all services +#### start all services `docker-compose up -d` + ### Generate SSL certificate by Letsencrypt - **Important: app must be run before starting letsencrypt** @@ -248,8 +252,8 @@ sudo systemctl start letsencrypt.timer (check) sudo systemctl list-timers ``` -## Docker utils +## Docker utils ### Restart app @@ -271,38 +275,38 @@ sudo systemctl start letsencrypt.timer `docker-compose restart` -## Fabmanager update +## Fabmanager update *This procedure updates fabmanager to the last version by default.* -### Steps +### Steps When a new version is available, this is how to update fabmanager app in a production environment, using docker-compose : -#### go to your app folder +1. go to your app folder `cd fabmananger` -#### pull last docker images +2. pull last docker images `docker-compose pull` -#### stop the app +3. stop the app `docker-compose stop fabmanager` -#### remove old assets +4. remove old assets `sudo rm -Rf public/assets/` -#### compile new assets +5. compile new assets `docker-compose run --rm fabmanager bundle exec rake assets:precompile` -#### run specific commands +6. run specific commands Do not forget to check if there are commands to run for your upgrade. Those commands are always specified in the [CHANGELOG](https://github.com/LaCasemate/fab-manager/blob/master/CHANGELOG.md) and prefixed by *[TODO DEPLOY]*. @@ -310,7 +314,7 @@ They are also present in the [release pages](https://github.com/LaCasemate/fab-m They execute specific tasks so they can't be automatic and have to be run by hand. -#### restart all containers +7. restart all containers ```bash docker-compose down @@ -319,8 +323,8 @@ They execute specific tasks so they can't be automatic and have to be run by han You can check that all containers are running with `docker ps`. -### Good to know +### Good to know #### Is it possible to update several versions at the same time ? From 48a5b45e06cbb8742ab92da604b3fb05975787d6 Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Thu, 20 Jul 2017 17:42:55 +0200 Subject: [PATCH 04/10] struggling with links --- docker/README.md | 57 +++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/docker/README.md b/docker/README.md index 289840c39..e267880d9 100644 --- a/docker/README.md +++ b/docker/README.md @@ -6,37 +6,34 @@ In order to make it work, please use the same directories structure as described ##### Table of contents 1. [Preliminary steps](#preliminary-steps)
-1.1. [docker/env file](#docker-env)
-1.2. [docker/nginx_with_ssl.conf.example file](#nginx-conf)
-1.3. [setup the server](#setup-server)
-1.4. [buy a domain name and link it with the droplet](#buy-domain-link-droplet)
-1.5. [connect to the droplet via SSH](#connect-to-droplet)
-1.6. [create SWAP file in coreOs](#create-swap-file)
-1.7. [setup folders and env file](#setup-folders-env-file)
-1.8. [SSL certificate with LetsEncrypt](#ssl-certificate-letsencrypt)
-1.9. [install docker-compose](#install-docker-compose) +1.1. docker/env file
+1.2. docker/nginx_with_ssl.conf.example file
+1.3. setup the server
+1.4. buy a domain name and link it with the droplet
+1.5. connect to the droplet via SSH
+1.6. create SWAP file in coreOs
+1.7. setup folders and env file
+1.8. SSL certificate with LetsEncrypt
+1.9. install docker-compose 2. [Deployment](#deployment)
-2.1. [pull images](#pull-images)
-2.2. [setup database](#setup-database)
-2.3. [build assets](#build-assets)
-2.4. [prepare Elasticsearch (search engine)](#prepare-elastic)
-2.5. [start all services](#start-services) -3. [Generate SSL certificate by Letsencrypt](#generate-sll-cert-letsencrypt) +2.1. pull images
+2.2. setup database
+2.3. build assets
+2.4. prepare Elasticsearch (search engine)
+2.5. start all services +3. [Generate SSL certificate by Letsencrypt](#generate-sll-certificate-by-letsencrypt) 4. [Docker utils](#docker-utils) -5. [Fabmanager update](#update-fabmanager)
-5.1. [Steps](#update-steps)
-5.2. [Good to know](#good-to-know) +5. [Fabmanager update](#fabmanager-update)
+5.1. Steps
+5.2. Good to know - ## Preliminary steps - ### docker/env file Make a copy of the **docker/env.example** file and use it as a starting point. Set all the environment variables needed by your application. Please refer to the [FabManager README](https://github.com/LaCasemate/fab-manager/blob/master/README.md) for explanations about those variables. - ### docker/nginx_with_ssl.conf.example file * Replace **MAIN_DOMAIN** (example: fab-manager.com). @@ -45,27 +42,23 @@ Set all the environment variables needed by your application. Please refer to th **Use nginx.conf.example if you don't want SSL for your app.** - ### setup the server Go to [DigitalOcean](https://www.digitalocean.com/) and create a Droplet with operating system coreOS **stable**. You need at least 2GB of addressable memory (RAM + swap) to install and use FabManager. Choose a datacenter. Set the hostname as your domain name. - ### buy a domain name and link it with the droplet 1. Buy a domain name on [OVH](https://www.ovh.com/fr/) 2. Replace the IP address of the domain with the droplet's IP (you can enable the flexible ip and use it) 3. **Do not** try to access your domain name right away, DNS are not aware of the change yet so **WAIT** and be patient. - ### connect to the droplet via SSH You can already connect to the server with this command: `ssh core@droplet-ip`. When DNS propagation will be done, you will be able to connect to the server with `ssh core@your-domain-name`. - ### create SWAP file in coreOS Switch to sudo and create a swap file: @@ -104,7 +97,6 @@ systemctl start swap exit ``` - ### setup folders and env file Create the config folder: @@ -126,7 +118,6 @@ Copy the previously customized `nginx_with_ssl.conf.example` as `/home/core/fabm Copy the previously customized `nginx.conf.example` as `/home/core/fabmanager/config/nginx/fabmanager.conf` if you do not want to use ssl (not recommended !). - ### SSL certificate with LetsEncrypt **FOLLOW THOSE INSTRUCTIONS ONLY IF YOU WANT TO USE SSL**. @@ -179,7 +170,6 @@ WantedBy=timers.target That's all for the moment. Keep on with the installation, we'll complete that part after deployment in the [Generate SSL certificate by Letsencrypt](#generate-ssl-cert-letsencrypt). - ### Install docker-compose ```bash @@ -191,17 +181,14 @@ sudo chmod +x /opt/bin/docker-compose Then copy docker-compose.yml to your app folder `/home/core/fabmanager`. - ## Deployment - ### pull images ```bash docker-compose pull ``` - ### setup database ```bash @@ -210,22 +197,18 @@ docker-compose run --rm fabmanager bundle exec rake db:migrate # run all the mig docker-compose run --rm fabmanager bundle exec rake db:seed # seed the database ``` - ### build assets `docker-compose run --rm fabmanager bundle exec rake assets:precompile` - ### prepare Elasticsearch (search engine) `docker-compose run --rm fabmanager bundle exec rake fablab:es_build_stats` - #### start all services `docker-compose up -d` - ### Generate SSL certificate by Letsencrypt **Important: app must be run before starting letsencrypt** @@ -252,7 +235,6 @@ sudo systemctl start letsencrypt.timer (check) sudo systemctl list-timers ``` - ## Docker utils ### Restart app @@ -275,12 +257,10 @@ sudo systemctl start letsencrypt.timer `docker-compose restart` - ## Fabmanager update *This procedure updates fabmanager to the last version by default.* - ### Steps @@ -323,7 +303,6 @@ They execute specific tasks so they can't be automatic and have to be run by han You can check that all containers are running with `docker ps`. - ### Good to know #### Is it possible to update several versions at the same time ? From cba2751a8a7ce6dc9dd321ec63c45929898edc05 Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Thu, 20 Jul 2017 17:43:59 +0200 Subject: [PATCH 05/10] fix link generate ssl certif --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index e267880d9..8228c3f52 100644 --- a/docker/README.md +++ b/docker/README.md @@ -21,7 +21,7 @@ In order to make it work, please use the same directories structure as described 2.3. build assets
2.4. prepare Elasticsearch (search engine)
2.5. start all services -3. [Generate SSL certificate by Letsencrypt](#generate-sll-certificate-by-letsencrypt) +3. [Generate SSL certificate by Letsencrypt](#generate-ssl-certificate-by-letsencrypt) 4. [Docker utils](#docker-utils) 5. [Fabmanager update](#fabmanager-update)
5.1. Steps
From 5cddf8d16d297204f36fe238ff8e763915ebda85 Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Thu, 20 Jul 2017 17:49:18 +0200 Subject: [PATCH 06/10] modifs and try fix steps of update part --- docker/README.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/docker/README.md b/docker/README.md index 8228c3f52..7cacf1402 100644 --- a/docker/README.md +++ b/docker/README.md @@ -259,47 +259,46 @@ sudo systemctl start letsencrypt.timer ## Fabmanager update -*This procedure updates fabmanager to the last version by default.* +*This procedure updates fabmanager to the most recent version by default.* ### Steps - When a new version is available, this is how to update fabmanager app in a production environment, using docker-compose : 1. go to your app folder -`cd fabmananger` + `cd fabmananger` 2. pull last docker images -`docker-compose pull` + `docker-compose pull` 3. stop the app -`docker-compose stop fabmanager` + `docker-compose stop fabmanager` 4. remove old assets -`sudo rm -Rf public/assets/` + `sudo rm -Rf public/assets/` 5. compile new assets -`docker-compose run --rm fabmanager bundle exec rake assets:precompile` + `docker-compose run --rm fabmanager bundle exec rake assets:precompile` 6. run specific commands -Do not forget to check if there are commands to run for your upgrade. Those commands -are always specified in the [CHANGELOG](https://github.com/LaCasemate/fab-manager/blob/master/CHANGELOG.md) and prefixed by *[TODO DEPLOY]*. -They are also present in the [release pages](https://github.com/LaCasemate/fab-manager/releases). + **Do not forget** to check if there are commands to run for your upgrade. Those commands + are always specified in the [CHANGELOG](https://github.com/LaCasemate/fab-manager/blob/master/CHANGELOG.md) and prefixed by **[TODO DEPLOY]**. + They are also present in the [releases page](https://github.com/LaCasemate/fab-manager/releases). -They execute specific tasks so they can't be automatic and have to be run by hand. + Those commands execute specific tasks and have to be run by hand. 7. restart all containers -```bash - docker-compose down - docker-compose up -d -``` + ```bash + docker-compose down + docker-compose up -d + ``` You can check that all containers are running with `docker ps`. From 3e68e7d8174a44ac47d1ab684b6803c1a586a23f Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Thu, 20 Jul 2017 17:50:37 +0200 Subject: [PATCH 07/10] modifs and try fix steps of update part --- docker/README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docker/README.md b/docker/README.md index 7cacf1402..c174caa61 100644 --- a/docker/README.md +++ b/docker/README.md @@ -267,38 +267,38 @@ When a new version is available, this is how to update fabmanager app in a produ 1. go to your app folder - `cd fabmananger` + `cd fabmananger` 2. pull last docker images - `docker-compose pull` + `docker-compose pull` 3. stop the app - `docker-compose stop fabmanager` + `docker-compose stop fabmanager` 4. remove old assets - `sudo rm -Rf public/assets/` + `sudo rm -Rf public/assets/` 5. compile new assets - `docker-compose run --rm fabmanager bundle exec rake assets:precompile` + `docker-compose run --rm fabmanager bundle exec rake assets:precompile` 6. run specific commands - **Do not forget** to check if there are commands to run for your upgrade. Those commands - are always specified in the [CHANGELOG](https://github.com/LaCasemate/fab-manager/blob/master/CHANGELOG.md) and prefixed by **[TODO DEPLOY]**. - They are also present in the [releases page](https://github.com/LaCasemate/fab-manager/releases). - - Those commands execute specific tasks and have to be run by hand. + **Do not forget** to check if there are commands to run for your upgrade. Those commands + are always specified in the [CHANGELOG](https://github.com/LaCasemate/fab-manager/blob/master/CHANGELOG.md) and prefixed by **[TODO DEPLOY]**. + They are also present in the [releases page](https://github.com/LaCasemate/fab-manager/releases). + + Those commands execute specific tasks and have to be run by hand. 7. restart all containers - ```bash - docker-compose down - docker-compose up -d - ``` + ```bash + docker-compose down + docker-compose up -d + ``` You can check that all containers are running with `docker ps`. From 6ba880275fc403bf89b57272c1e6efba47ccf3a3 Mon Sep 17 00:00:00 2001 From: Cyril Date: Thu, 20 Jul 2017 19:54:37 +0200 Subject: [PATCH 08/10] Update README.md --- docker/README.md | 238 +++++++++++++++++++++++++---------------------- 1 file changed, 127 insertions(+), 111 deletions(-) diff --git a/docker/README.md b/docker/README.md index c174caa61..97bbcec4c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,122 +1,105 @@ # Install Fabmanager app in production with Docker -This README tries to describe all the steps to put a fabmanager app into production on a server, based on a solution using Docker and DigitalOcean. +This README tries to describe all the steps to put a fabmanager app into production on a server, based on a solution using Docker and Docker-compose. +We recommend DigitalOcean, but these steps will work on any Docker-compatible cloud provider or local server. + In order to make it work, please use the same directories structure as described in this guide in your fabmanager app folder. +You will need to be root through the rest of the setup. ##### Table of contents 1. [Preliminary steps](#preliminary-steps)
-1.1. docker/env file
-1.2. docker/nginx_with_ssl.conf.example file
-1.3. setup the server
-1.4. buy a domain name and link it with the droplet
-1.5. connect to the droplet via SSH
-1.6. create SWAP file in coreOs
-1.7. setup folders and env file
-1.8. SSL certificate with LetsEncrypt
-1.9. install docker-compose -2. [Deployment](#deployment)
-2.1. pull images
-2.2. setup database
-2.3. build assets
-2.4. prepare Elasticsearch (search engine)
-2.5. start all services +1.1. setup the server
+1.2. buy a domain name and link it with the droplet
+1.3. connect to the droplet via SSH
+1.4. prepare server
+1.5. setup folders and env file
+1.6. setup nginx file
+1.7. SSL certificate with LetsEncrypt
+1.8. requirements +2. [Install Fabmanager](#install-fabmanager)
+2.1. Add docker-compose.yml file
+2.2. pull images
+2.3. setup database
+2.4. build assets
+2.5. prepare Elasticsearch (search engine)
+2.6. start all services 3. [Generate SSL certificate by Letsencrypt](#generate-ssl-certificate-by-letsencrypt) 4. [Docker utils](#docker-utils) -5. [Fabmanager update](#fabmanager-update)
+5. [Update Fabmanager](#update-fabmanager)
5.1. Steps
5.2. Good to know ## Preliminary steps -### docker/env file +### setup the server + +Go to [DigitalOcean](https://www.digitalocean.com/) and create a Droplet with One-click apps **"Docker on Ubuntu 16.04 LTS"** (Docker and Docker-compose are preinstalled). +You need at least 2GB of addressable memory (RAM + swap) to install and use FabManager. +We recommend 4 GB RAM for larger communities. +Choose a datacenter. Set the hostname as your domain name. + +### buy a domain name and link it with the server + +1. Buy a domain name on [OVH](https://www.ovh.com/fr/) +2. Replace the IP address of the domain with the droplet's IP (you can enable the flexible ip and use it) +3. **Do not** try to access your domain name right away, DNS are not aware of the change yet so **WAIT** and be patient. + +### connect to the server via SSH + +You can already connect to the server with this command: `ssh root@server-ip`. When DNS propagation will be done, you will be able to +connect to the server with `ssh root@your-domain-name`. + +### prepare server + +We recommend you to : +- ugprade your system +- add at least 2GB of swap +- verify that you are using a connection via an SSH key. If so, you can set the root passord (for the debug console) and disable password connection. +To do this, you can use the following script : + +```bash +cd /root +git clone https://github.com/sleede/lazyscripts.git +cd lazyscripts/ +chmod a+x prepare-vps.sh +./prepare-vps +``` + + +### setup folders and env file + +Create the config folder: +```bash +mkdir -p /apps/fabmanager/config +``` Make a copy of the **docker/env.example** file and use it as a starting point. Set all the environment variables needed by your application. Please refer to the [FabManager README](https://github.com/LaCasemate/fab-manager/blob/master/README.md) for explanations about those variables. -### docker/nginx_with_ssl.conf.example file +Then, copy the previously customized `env.example` file as `/apps/fabmanager/config/env` + +### setup nginx file + +Create the nginx folder: +```bash +mkdir -p /apps/fabmanager/config/nginx +``` + +Customize the docker/nginx_with_ssl.conf.example file * Replace **MAIN_DOMAIN** (example: fab-manager.com). * Replace **URL_WITH_PROTOCOL_HTTPS** (example: https://www.fab-manager.com). * Replace **ANOTHER_URL_1**, **ANOTHER_URL_2** (example: .fab-manager.fr) **Use nginx.conf.example if you don't want SSL for your app.** -### setup the server - -Go to [DigitalOcean](https://www.digitalocean.com/) and create a Droplet with operating system coreOS **stable**. -You need at least 2GB of addressable memory (RAM + swap) to install and use FabManager. -Choose a datacenter. Set the hostname as your domain name. - -### buy a domain name and link it with the droplet - -1. Buy a domain name on [OVH](https://www.ovh.com/fr/) -2. Replace the IP address of the domain with the droplet's IP (you can enable the flexible ip and use it) -3. **Do not** try to access your domain name right away, DNS are not aware of the change yet so **WAIT** and be patient. - -### connect to the droplet via SSH - -You can already connect to the server with this command: `ssh core@droplet-ip`. When DNS propagation will be done, you will be able to -connect to the server with `ssh core@your-domain-name`. - -### create SWAP file in coreOS - -Switch to sudo and create a swap file: - -```bash -sudo -i -touch /2GiB.swap -chattr +C /2GiB.swap -fallocate -l 2048m /2GiB.swap -chmod 600 /2GiB.swap -mkswap /2GiB.swap -``` - -Create file **/etc/systemd/system/swap.service**, filling it with the lines: - -```bash -[Unit] -Description=Turn on swap -[Service] -Type=oneshot -Environment="SWAPFILE=/2GiB.swap" -RemainAfterExit=true -ExecStartPre=/usr/sbin/losetup -f ${SWAPFILE} -ExecStart=/usr/bin/sh -c "/sbin/swapon $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)" -ExecStop=/usr/bin/sh -c "/sbin/swapoff $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)" -ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)" -[Install] -WantedBy=multi-user.target -``` - -Then enable the service and start it: - -```bash -systemctl enable /etc/systemd/system/swap.service -systemctl start swap -exit -``` - -### setup folders and env file - -Create the config folder: -```bash -mkdir -p /home/core/fabmanager/config -``` - -Then, copy the previously customized `env.example` file as `/home/core/fabmanager/config/env` - -Create the nginx folder: -```bash -mkdir -p /home/core/fabmanager/config/nginx -``` - Then, -Copy the previously customized `nginx_with_ssl.conf.example` as `/home/core/fabmanager/config/nginx/fabmanager.conf` +Copy the previously customized `nginx_with_ssl.conf.example` as `/apps/fabmanager/config/nginx/fabmanager.conf` **OR** -Copy the previously customized `nginx.conf.example` as `/home/core/fabmanager/config/nginx/fabmanager.conf` if you do not want to use ssl (not recommended !). +Copy the previously customized `nginx.conf.example` as `/apps/fabmanager/config/nginx/fabmanager.conf` if you do not want to use ssl (not recommended !). ### SSL certificate with LetsEncrypt @@ -127,15 +110,15 @@ Let’s Encrypt certificates expire after 90 days, so automation of renewing you Here is the setup for a systemd timer and service to renew the certificates and reboot the app Docker container: ```bash -mkdir -p /home/core/fabmanager/config/nginx/ssl +mkdir -p /apps/fabmanager/config/nginx/ssl ``` -Run `openssl dhparam -out dhparam.pem 4096` in the folder /home/core/fabmanager/config/nginx/ssl (generate dhparam.pem file) +Run `openssl dhparam -out dhparam.pem 4096` in the folder /apps/fabmanager/config/nginx/ssl (generate dhparam.pem file) ```bash -mkdir -p /home/core/fabmanager/letsencrypt/config/ +mkdir -p /apps/fabmanager/letsencrypt/config/ ``` -Copy the previously customized `webroot.ini.example` as `/home/core/fabmanager/letsencrypt/config/webroot.ini` +Copy the previously customized `webroot.ini.example` as `/appsfabmanager/letsencrypt/config/webroot.ini` ```bash -mkdir -p /home/core/fabmanager/letsencrypt/etc/webrootauth +mkdir -p /apps/fabmanager/letsencrypt/etc/webrootauth ``` Run `docker pull quay.io/letsencrypt/letsencrypt:latest` @@ -149,7 +132,7 @@ Requires=docker.service [Service] Type=oneshot -ExecStart=/usr/bin/docker run --rm --name letsencrypt -v "/home/core/fabmanager/log:/var/log/letsencrypt" -v "/home/core/fabmanager/letsencrypt/etc:/etc/letsencrypt" -v "/home/core/fabmanager/letsencrypt/config:/letsencrypt-config" quay.io/letsencrypt/letsencrypt:latest -c "/letsencrypt-config/webroot.ini" certonly +ExecStart=/usr/bin/docker run --rm --name letsencrypt -v "/apps/fabmanager/log:/var/log/letsencrypt" -v "/apps/fabmanager/letsencrypt/etc:/etc/letsencrypt" -v "/apps/fabmanager/letsencrypt/config:/letsencrypt-config" quay.io/letsencrypt/letsencrypt:latest -c "/letsencrypt-config/webroot.ini" certonly ExecStartPost=-/usr/bin/docker restart fabmanager_nginx_1 ``` @@ -170,18 +153,37 @@ WantedBy=timers.target That's all for the moment. Keep on with the installation, we'll complete that part after deployment in the [Generate SSL certificate by Letsencrypt](#generate-ssl-cert-letsencrypt). -### Install docker-compose +### Requirements + + +Verify that Docker and Docker-composer are installed : +(This is normally the case if you used a pre-configured image.) ```bash -curl -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > ./docker-compose +docker info +docker-compose -v +``` + +Otherwise, you can install docker to ubuntu with the following instructions : +https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository + +To install docker-compose : + +```bash +curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > ./docker-compose sudo mkdir -p /opt/bin sudo mv docker-compose /opt/bin/ sudo chmod +x /opt/bin/docker-compose ``` -Then copy docker-compose.yml to your app folder `/home/core/fabmanager`. -## Deployment + +## Install Fabmanager + +### Add docker-compose.yml file + +Copy docker-compose.yml to your app folder `/apps/fabmanager`. +The docker-compose commands must be launched from the folder `/apps/fabmanager`. ### pull images @@ -211,7 +213,7 @@ docker-compose run --rm fabmanager bundle exec rake db:seed # seed the database ### Generate SSL certificate by Letsencrypt -**Important: app must be run before starting letsencrypt** +**Important: app must be run on http before starting letsencrypt** Start letsencrypt service : ```bash @@ -219,7 +221,7 @@ sudo systemctl start letsencrypt.service ``` If the certificate was successfully generated then update the nginx configuration file and activate the ssl port and certificate -editing the file `/home/core/fabmanager/config/nginx/fabmanager.conf`. +editing the file `/apps/fabmanager/config/nginx/fabmanager.conf`. Remove your app container and run your app to apply the changes running the following commands: ```bash @@ -235,29 +237,43 @@ sudo systemctl start letsencrypt.timer (check) sudo systemctl list-timers ``` -## Docker utils +## Docker utils with docker-compose ### Restart app -`docker restart fabmanager-app` +`docker-compose restart fabmanager` ### Remove app -`docker rm -f fabmanager-app` +`docker-compose down fabmanager` + +### Restart all containers + +`docker-compose restart` + +### Remove all containers + +`docker-compose down` + +### Start all containers + +`docker-compose up -d` ### Open a bash in the app context -`docker exec -it fabmanager-app bash` +`docker-compose run --rm fabmanager bash` ### Show services status `docker-compose ps` -### Restart all services +### Restart nginx container -`docker-compose restart` +`docker-compose restart nginx` -## Fabmanager update + + +## update Fabmanager *This procedure updates fabmanager to the most recent version by default.* @@ -267,7 +283,7 @@ When a new version is available, this is how to update fabmanager app in a produ 1. go to your app folder - `cd fabmananger` + `cd /apps/fabmanager` 2. pull last docker images @@ -279,7 +295,7 @@ When a new version is available, this is how to update fabmanager app in a produ 4. remove old assets - `sudo rm -Rf public/assets/` + `rm -Rf public/assets/` 5. compile new assets From fa0c2f7dee7dfac586c38c05c33afd4d80adb332 Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Fri, 21 Jul 2017 09:27:29 +0200 Subject: [PATCH 09/10] fix br --- docker/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/README.md b/docker/README.md index 97bbcec4c..caf7a2232 100644 --- a/docker/README.md +++ b/docker/README.md @@ -18,11 +18,11 @@ You will need to be root through the rest of the setup. 1.7. SSL certificate with LetsEncrypt
1.8. requirements 2. [Install Fabmanager](#install-fabmanager)
-2.1. Add docker-compose.yml file
-2.2. pull images
-2.3. setup database
-2.4. build assets
-2.5. prepare Elasticsearch (search engine)
+2.1. Add docker-compose.yml file
+2.2. pull images
+2.3. setup database
+2.4. build assets
+2.5. prepare Elasticsearch (search engine)
2.6. start all services 3. [Generate SSL certificate by Letsencrypt](#generate-ssl-certificate-by-letsencrypt) 4. [Docker utils](#docker-utils) From c6d4a6c735a1c08b6c641f75355ebc4377478493 Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Fri, 21 Jul 2017 14:19:59 +0200 Subject: [PATCH 10/10] rm old docker README --- docker/README-old.md | 377 ------------------------------------------- 1 file changed, 377 deletions(-) delete mode 100644 docker/README-old.md diff --git a/docker/README-old.md b/docker/README-old.md deleted file mode 100644 index aa68af960..000000000 --- a/docker/README-old.md +++ /dev/null @@ -1,377 +0,0 @@ -# full procedure to put into production a fabmanager app with Docker - -This README tries to describe all steps to put a fabmanager app into production on a server, based on a solution using Docker and DigitalOcean. -In order to make all this stuff working, please use the same directories structure as described in this guide in your fabmanager app folder. - -### docker/env - -Make a copy of the **env.example** and use it as a starting point. -List all the environment variables needed by your application. - -### docker/nginx_with_ssl.conf.example - -* Use nginx.conf.example especially if you are not using **SSL** -* Replace **MAIN_DOMAIN** (example: fab-manager.com). -* Replace **URL_WITH_PROTOCOL_HTTPS** (example: https://www.fab-manager.com). -* Replace **ANOTHER_URL_1**, **ANOTHER_URL_2** (example: .fab-manager.fr) - - - -## Things are getting serious, starting deployment process guys - - -### setup the server - -Go to **DigitalOcean** and create a Droplet with operating system coreOS **stable**. -You need at least 2GB of addressable memory (RAM + swap) to install and use FabManager!. -Choose datacenter. Set hostname as your domain name. - - -### Buy domain name and link it with the droplet - -1. Buy a domain name on OVH -2. Replace IP of the domain with droplet's IP (you can enable the flexible ip and use it) -3. **Do not** fuck up trying to access your domain name right away, DNS are not aware of the change yet so **WAIT** and be patient. - - -### Connect to the droplet via SSH - -You can already connect to the server with this command: `ssh core@droplet-ip`. When DNS propagation will be done, you will be able to -connect to the server with `ssh core@your-domain-name`. - - - -### Create SWAP file in coreOS - -Firstly, switch to sudo and create swap file - -```bash -sudo -i -touch /2GiB.swap -chattr +C /2GiB.swap -fallocate -l 2048m /2GiB.swap -chmod 600 /2GiB.swap -mkswap /2GiB.swap -``` - -Create file **/etc/systemd/system/swap.service**, filling it with the lines: - -```bash -[Unit] -Description=Turn on swap -[Service] -Type=oneshot -Environment="SWAPFILE=/2GiB.swap" -RemainAfterExit=true -ExecStartPre=/usr/sbin/losetup -f ${SWAPFILE} -ExecStart=/usr/bin/sh -c "/sbin/swapon $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)" -ExecStop=/usr/bin/sh -c "/sbin/swapoff $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)" -ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)" -[Install] -WantedBy=multi-user.target -``` - -Then add service and start: - -```bash -systemctl enable /etc/systemd/system/swap.service -systemctl start swap -exit -``` - -### Setup folders and env file - -```bash -mkdir -p /home/core/fabmanager/config -``` - -Copy the previously customized `env.example` file as `/home/core/fabmanager/config/env` - -```bash -mkdir -p /home/core/fabmanager/config/nginx -``` - -Copy the previously customized `nginx_with_ssl.conf.example` as `/home/core/fabmanager/config/nginx/fabmanager.conf` -OR -Copy the previously customized `nginx.conf.example` as `/home/core/fabmanager/config/nginx/fabmanager.conf` if you do not want ssl support (not recommended !). - - -### SSL certificate with LetsEncrypt -Let's Encrypt is a new Certificate Authority that is free, automated, and open. -Let’s Encrypt certificates expire after 90 days, so automation of renewing your certificates is important. -Here is the setup for a systemd timer and service to renew the certificates and reboot the app Docker container - -```bash -mkdir -p /home/core/fabmanager/config/nginx/ssl -``` -Run `openssl dhparam -out dhparam.pem 4096` in the folder /home/core/fabmanager/config/nginx/ssl (generate dhparam.pem file) -```bash -mkdir -p /home/core/fabmanager/letsencrypt/config/ -``` -Copy the previously customized `webroot.ini.example` as `/home/core/fabmanager/letsencrypt/config/webroot.ini` -```bash -mkdir -p /home/core/fabmanager/letsencrypt/etc/webrootauth -``` - -Run `docker pull quay.io/letsencrypt/letsencrypt:latest` - -Create file (with sudo) /etc/systemd/system/letsencrypt.service with - -```bash -[Unit] -Description=letsencrypt cert update oneshot -Requires=docker.service - -[Service] -Type=oneshot -ExecStart=/usr/bin/docker run --rm --name letsencrypt -v "/home/core/fabmanager/log:/var/log/letsencrypt" -v "/home/core/fabmanager/letsencrypt/etc:/etc/letsencrypt" -v "/home/core/fabmanager/letsencrypt/config:/letsencrypt-config" quay.io/letsencrypt/letsencrypt:latest -c "/letsencrypt-config/webroot.ini" certonly -ExecStartPost=-/usr/bin/docker restart fabmanager_nginx_1 -``` - -Create file (with sudo) /etc/systemd/system/letsencrypt.timer with -```bash -[Unit] -Description=letsencrypt oneshot timer -Requires=docker.service - -[Timer] -OnCalendar=*-*-1 06:00:00 -Persistent=true -Unit=letsencrypt.service - -[Install] -WantedBy=timers.target -``` - -Then deploy your app and read the "Generate SSL certificate by Letsencrypt" section to complete the installation of the letsencrypt certificate. - - -### Deploy dockers containers on host - -```bash -docker pull redis:3.0 -docker pull postgres:9.4 -docker pull elasticsearch:1.7 -docker pull sleede/fab-manager - -docker run --restart=always -d --name=fabmanager-postgres -v /home/core/fabmanager/postgresql:/var/lib/postgresql/data postgres:9.4 -docker run --restart=always -d --name=fabmanager-redis -v /home/core/fabmanager/redis:/data redis:3.0 -docker run --restart=always -d --name=fabmanager-elastic -v /home/core/fabmanager/elasticsearch:/usr/share/elasticsearch/data elasticsearch:1.7 -``` - -### Rails specific commands - -#### DB CREATE - -```bash -docker run --rm \ - --link=fabmanager-postgres:postgres \ - --link=fabmanager-redis:redis \ - --link=fabmanager-elastic:elasticsearch \ - -e RAILS_ENV=production \ - --env-file /home/core/fabmanager/config/env \ - sleede/fab-manager \ - bundle exec rake db:create -``` - -#### DB MIGRATE - -```bash -docker run --rm \ - --link=fabmanager-postgres:postgres \ - --link=fabmanager-redis:redis \ - --link=fabmanager-elastic:elasticsearch \ - -e RAILS_ENV=production \ - --env-file /home/core/fabmanager/config/env \ - -v /home/core/fabmanager/plugins:/usr/src/app/plugins \ - sleede/fab-manager \ - bundle exec rake db:migrate -``` - -#### DB SEED - -```bash -docker run --rm \ - --link=fabmanager-postgres:postgres \ - --link=fabmanager-redis:redis \ - --link=fabmanager-elastic:elasticsearch \ - -e RAILS_ENV=production ADMIN_EMAIL=youradminemail ADMIN_PASSWORD=youradminpassword \ - --env-file /home/core/fabmanager/config/env \ - -v /home/core/fabmanager/plugins:/usr/src/app/plugins \ - sleede/fab-manager \ - bundle exec rake db:seed -``` - - -#### PREPARE ELASTIC - -```bash -docker run --rm \ - --link=fabmanager-postgres:postgres \ - --link=fabmanager-postgres:postgres \ - --link=fabmanager-redis:redis \ - --link=fabmanager-elastic:elasticsearch \ - -e RAILS_ENV=production \ - --env-file /home/core/fabmanager/config/env \ - -v /home/core/fabmanager/plugins:/usr/src/app/plugins \ - sleede/fab-manager \ - bundle exec rake fablab:es_build_stats -``` - - -#### BUILD ASSETS - -```bash -docker run --rm \ - --link=fabmanager-postgres:postgres \ - --link=fabmanager-redis:redis \ - --link=fabmanager-elastic:elasticsearch \ - -e RAILS_ENV=production \ - --env-file /home/core/fabmanager/config/env \ - -v /home/core/fabmanager/public/assets:/usr/src/app/public/assets \ - -v /home/core/fabmanager/plugins:/usr/src/app/plugins \ - sleede/fab-manager \ - bundle exec rake assets:precompile -``` - - -#### RUN APP - -```bash -docker run --restart=always -d --name=fabmanager \ - --link=fabmanager-postgres:postgres \ - --link=fabmanager-redis:redis \ - --link=fabmanager-elastic:elasticsearch \ - -e RAILS_ENV=production \ - -e RACK_ENV=production \ - --env-file /home/core/fabmanager/config/env \ - -v /home/core/fabmanager/public/assets:/usr/src/app/public/assets \ - -v /home/core/fabmanager/public/uploads:/usr/src/app/public/uploads \ - -v /home/core/fabmanager/invoices:/usr/src/app/invoices \ - -v /home/core/fabmanager/exports:/usr/src/app/exports \ - -v /home/core/fabmanager/plugins:/usr/src/app/plugins \ - -v /home/core/fabmanager/log:/var/log/supervisor \ - sleede/fab-manager - -docker run --restart=always -d --name=nginx \ - -p 80:80 \ - -p 443:443 \ - --link=fabmanager:fabmanager \ - -v /home/core/fabmanager/config/nginx:/etc/nginx/conf.d \ - -v /home/core/fabmanager/letsencrypt/etc:/etc/letsencrypt \ - -v /home/core/fabmanager/log:/var/log/nginx \ - --volumes-from fabmanager:ro \ - nginx:1.9 - -``` - - -### Generate SSL certificate by Letsencrypt (app must be run before start letsencrypt) - -Start letsencrypt service : -```bash -sudo systemctl start letsencrypt.service -``` - -If the certificate was successfully generated then update the nginx configuration file and activate the ssl port and certificate. -Edit `/home/core/fabmanager/config/nginx/fabmanager.conf` -Remove your app and Run your app to apply changes - -Finally, if everything is ok, start letsencrypt timer to update the certificate every 1st of the month : - -```bash -sudo systemctl enable letsencrypt.timer -sudo systemctl start letsencrypt.timer -(check) sudo systemctl list-timers -``` - - -### Dockers utils - -#### Restart app - -`docker restart fabmanager-app` - -#### Remove app - -`docker rm -f fabmanager-app` - -#### Open a bash in the app context - -`docker exec -it fabmanager-app bash` - - - - -### If you want deploy with Docker Compose - -#### download docker compose https://github.com/docker/compose/releases - -```bash -curl -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > ./docker-compose -sudo mkdir -p /opt/bin -sudo mv docker-compose /opt/bin/ -sudo chmod +x /opt/bin/docker-compose -``` - -#### Setup folders and env file - -```bash -mkdir -p /home/core/fabmanager/config -``` - -Copy the previously customized `env` file as `/home/core/fabmanager/config/env` - -```bash -mkdir -p /home/core/fabmanager/config/nginx -``` - -Copy the previously customized `nginx_with_ssl.conf.example` as `/home/core/fabmanager/config/nginx/fabmanager.conf` -Read the "SSL certificate with LetsEncrypt" section -OR -Copy the previously customized `nginx.conf.example` as `/home/core/fabmanager/config/nginx/fabmanager.conf` if you do not want ssl support (not recommended !). - - -#### copy docker-compose.yml to /home/core/fabmanager - -#### pull images - -`docker-compose pull` - -#### create/migrate/seed db - -```bash -docker-compose run --rm fabmanager bundle exec rake db:create -docker-compose run --rm fabmanager bundle exec rake db:migrate -docker-compose run --rm fabmanager bundle exec rake db:seed -``` - -#### build assets - -`docker-compose run --rm fabmanager bundle exec rake assets:precompile` - -#### PREPARE ELASTIC -`docker-compose run --rm fabmanager bundle exec rake fablab:es_build_stats` - -#### run create and run all services - -`docker-compose up -d` - -#### restart all services - -`docker-compose restart` - -#### show services status - -`docker-compose ps` - -#### update service fabmanager, rebuild assets and restart fabmanager - -```bash -docker-compose pull fabmanager -docker-compose stop fabmanager -sudo rm -rf fabmanager/public/assets -docker-compose run --rm fabmanager bundle exec rake assets:precompile -docker-compose down -docker-compose up -d -```