This is a quick step-by-step guide to install Cloud.net on a server using Docker.
Minimum requirements
- A server running Ubuntu 14.04 LTS with at least 2GB of RAM.
- Onapp control panel with required permissions
- SMTP and few other third party logins
Installation
- Install Docker and Docker Compose
Please follow the instructions on the official Docker website to install Docker and Docker Compose on the server.
https://docs.docker.com/engine/installation/ubuntulinux/ https://docs.docker.com/compose/install/
- Clone the Cloud.net Github repo
$ git clone https://github.com/OnApp/cloudnet.git
$ cd cloudnet
-
You will find self signed SSL certificates inside certs/ directory. Replace these with the proper SSL certificates with the same file name and location. These certificates are later mounted as a volume to the container running nginx.
-
Almost all of the required and third party logins and keys are read from .env.docker file. Make a copy of the sample environment file.
$ cp dotenv.sample .env.docker
You will need to enter values for all the keys under REQUIRED. The keys under PRE-CONFIGURED can be left as such unless you have made changes to how docker has been composed.
ONAPP_ROLE is the OnApp user role that grants restricted permissions to Cloud.net users. Run the command in the next step to create it.
- Temporarily add
RAILS_ENV=test
at top of .env.docker and run the following commands
$ docker-compose run --no-deps --rm cloudnet-app rake create_onapp_role
The ID will need to be added to the ONAPP_ROLE setting in .env.docker
$ docker-compose run --no-deps --rm cloudnet-app rails generate symmetric_encryption:new_keys production
Copy the generated key as value for SYMMETRIC_ENCRYPTION_KEY in .env.docker
Likewise, run the following command to generate values for DEVISE_SECRET_KEY and COOKIES_SECRET_BASE each:
$ docker-compose run --no-deps --rm cloudnet-app rake secret
Now remove RAILS_ENV=test from .env.docker
- Run the following commands to create and setup the database
$ docker-compose run --rm cloudnet-app rake db:create RAILS_ENV=production
$ docker-compose run --rm cloudnet-app rake db:schema:load RAILS_ENV=production
$ docker-compose run --rm cloudnet-app rake db:seed RAILS_ENV=production
- Finally, you can run the containers with the following command:
$ docker-compose up -d
The app should now be up and running on the HTTPS port on the servers IP address. There will be only one app container running at this point. You can add more app containers as required by running $ docker-compose scale cloudnet-app=2
which will bring up another app container.
To check the status of the containers, run $ docker-compose ps
Updating
Pull the updated image from Docker Hub:
$ docker pull onapp/cloudnet
Run any pending migrations:
$ docker-compose run --rm cloudnet-app rake db:migrate RAILS_ENV=production
Run $ docker-compose ps
and note the current container names. Typically, they should be cloudnet_cloudnet-app_1 and cloudnet_cloudnet-app_2 assuming you scaled to two app containers.
Now, scale up another 2 (or more, as much as you need) app containers.
$ docker-compose scale cloudnet-app=4
This will start two new containers with the updated image, cloudnet_cloudnet-app_3 and cloudnet_cloudnet-app_4. Wait for few minutes until the new containers have started and is ready to serve requests. We now need to stop and remove the older containers running on the older image.
$ docker stop cloudnet_cloudnet-app_1
$ docker stop cloudnet_cloudnet-app_2
At this point, you will have two new containers based on the newer image. If there was a problem and you would like to roll-back to the older containers, you could simply start the stopped containers and stop the newer ones.
Once you have made sure everything is working correctly, you could remove the older containers.
$ docker-compose rm cloudnet-app