1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

work in progress

This commit is contained in:
Nicolas Florentin 2017-07-20 17:37:03 +02:00
parent 1833ac2890
commit aa4ef99d02

View File

@ -27,49 +27,48 @@ In order to make it work, please use the same directories structure as described
5.1. [Steps](#update-steps)<br/> 5.1. [Steps](#update-steps)<br/>
5.2. [Good to know](#good-to-know) 5.2. [Good to know](#good-to-know)
## Preliminary steps
<a id="preliminary-steps"></a> <a id="preliminary-steps"></a>
## Preliminary steps
### docker/env file
<a id="docker-env"></a> <a id="docker-env"></a>
### 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. 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
<a id="nginx-conf"></a> <a id="nginx-conf"></a>
### docker/nginx_with_ssl.conf.example file
* Replace **MAIN_DOMAIN** (example: fab-manager.com). * Replace **MAIN_DOMAIN** (example: fab-manager.com).
* Replace **URL_WITH_PROTOCOL_HTTPS** (example: https://www.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) * Replace **ANOTHER_URL_1**, **ANOTHER_URL_2** (example: .fab-manager.fr)
Side note: **Use nginx.conf.example if you don't want SSL for your app.**
* Use nginx.conf.example if you are not using **SSL**
### setup the server
<a id="setup-server"></a> <a id="setup-server"></a>
### 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. 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. Choose a datacenter. Set the hostname as your domain name.
### buy a domain name and link it with the droplet
<a id="buy-domain-link-droplet"></a> <a id="buy-domain-link-droplet"></a>
### 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) 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. 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
<a id="connect-to-droplet"></a> <a id="connect-to-droplet"></a>
### 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 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`. connect to the server with `ssh core@your-domain-name`.
### create SWAP file in coreOS
<a id="create-swap-file"></a> <a id="create-swap-file"></a>
### create SWAP file in coreOS
Firstly, switch to sudo and create a swap file Switch to sudo and create a swap file:
```bash ```bash
sudo -i sudo -i
@ -97,7 +96,7 @@ ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d $(/usr/sbin/losetup -j ${SWAPF
WantedBy=multi-user.target WantedBy=multi-user.target
``` ```
Then add service and start: Then enable the service and start it:
```bash ```bash
systemctl enable /etc/systemd/system/swap.service systemctl enable /etc/systemd/system/swap.service
@ -105,27 +104,32 @@ systemctl start swap
exit exit
``` ```
### setup folders and env file
<a id="setup-folders-env-file"></a> <a id="setup-folders-env-file"></a>
### setup folders and env file
Create the config folder:
```bash ```bash
mkdir -p /home/core/fabmanager/config 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 ```bash
mkdir -p /home/core/fabmanager/config/nginx 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 `/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 !).
<a id="ssl-certificate-letsencrypt"></a> <a id="ssl-certificate-letsencrypt"></a>
### 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 is a new Certificate Authority that is free, automated, and open.
Lets Encrypt certificates expire after 90 days, so automation of renewing your certificates is important. Lets 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). 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
<a id="install-docker-compose"></a> <a id="install-docker-compose"></a>
### Install docker-compose
```bash ```bash
curl -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > ./docker-compose 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`. Then copy docker-compose.yml to your app folder `/home/core/fabmanager`.
## Deployment
<a id="deployment"></a> <a id="deployment"></a>
## Deployment
### pull images
<a id="pull-images"></a> <a id="pull-images"></a>
### pull images
```bash ```bash
docker-compose pull docker-compose pull
``` ```
### setup database
<a id="setup-database"></a> <a id="setup-database"></a>
### setup database
```bash ```bash
docker-compose run --rm fabmanager bundle exec rake db:create # create the database 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 docker-compose run --rm fabmanager bundle exec rake db:seed # seed the database
``` ```
### build assets
<a id="build-assets"></a> <a id="build-assets"></a>
### build assets
`docker-compose run --rm fabmanager bundle exec rake assets:precompile` `docker-compose run --rm fabmanager bundle exec rake assets:precompile`
### prepare Elasticsearch (search engine)
<a id="prepare-elastic"></a> <a id="prepare-elastic"></a>
### prepare Elasticsearch (search engine)
`docker-compose run --rm fabmanager bundle exec rake fablab:es_build_stats` `docker-compose run --rm fabmanager bundle exec rake fablab:es_build_stats`
#### start all services
<a id="start-services"></a> <a id="start-services"></a>
#### start all services
`docker-compose up -d` `docker-compose up -d`
<a id="generate-ssl-cert-letsencrypt"></a>
### Generate SSL certificate by Letsencrypt ### Generate SSL certificate by Letsencrypt
<a name="generate-ssl-cert-letsencrypt"></a>
**Important: app must be run before starting letsencrypt** **Important: app must be run before starting letsencrypt**
@ -248,8 +252,8 @@ sudo systemctl start letsencrypt.timer
(check) sudo systemctl list-timers (check) sudo systemctl list-timers
``` ```
## Docker utils
<a id="docker-utils"></a> <a id="docker-utils"></a>
## Docker utils
### Restart app ### Restart app
@ -271,38 +275,38 @@ sudo systemctl start letsencrypt.timer
`docker-compose restart` `docker-compose restart`
## Fabmanager update
<a id="update-fabmanager"></a> <a id="update-fabmanager"></a>
## Fabmanager update
*This procedure updates fabmanager to the last version by default.* *This procedure updates fabmanager to the last version by default.*
### Steps
<a id="update-steps"></a> <a id="update-steps"></a>
### Steps
When a new version is available, this is how to update fabmanager app in a production environment, using docker-compose : 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` `cd fabmananger`
#### pull last docker images 2. pull last docker images
`docker-compose pull` `docker-compose pull`
#### stop the app 3. stop the app
`docker-compose stop fabmanager` `docker-compose stop fabmanager`
#### remove old assets 4. remove old assets
`sudo rm -Rf public/assets/` `sudo rm -Rf public/assets/`
#### compile new 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`
#### run specific commands 6. run specific commands
Do not forget to check if there are commands to run for your upgrade. Those 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]*. 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. 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 ```bash
docker-compose down 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`. You can check that all containers are running with `docker ps`.
### Good to know
<a id="good-to-know"></a> <a id="good-to-know"></a>
### Good to know
#### Is it possible to update several versions at the same time ? #### Is it possible to update several versions at the same time ?