Codacy Installation (Swarm)

1 - Prerequisites


 

In the Enterprise version, Codacy works by using Docker running in a containerised environment. This process will take around 20 min to complete, from an empty machine to a fully working Codacy installation.

 

1.1 - Hardware (Recommended specs)

1.1.1 - One Instance (2 concurrent analysis):

Running Codacy in one machine is possible and works great if you have up to 200 users and provide enough computing power to easily have 2 concurrent analysis.

Leader specs:
16 cores CPU
32GB RAM
1TB+ SSD Drive

1.1.2 - Two Instances (4 concurrent analysis):

Using two machines will be enough for 400 users and 4 concurrent analysis. 

Leader specs:
2-4 cores CPU
8GB RAM
100GB+ SSD Drive

Worker specs:
10+ cores CPU
16GB+ RAM
1TB+ SSD Drive

1.1.3 - Three Instances (>4 concurrent analysis)

Leader specs:
2-4 cores CPU
8GB RAM
100GB+ SSD Drive

Worker Listener specs:
2 cores CPU
4GB RAM
1TB+ SSD Drive

Worker Manager specs:
8 cores CPU
16GB+ RAM
100GB+ SSD Drive

 

1.2 - Network

Codacy application requires several ports to be used.

1.2.1 - Internal

For the leader machine, you will need these ports:

  • 80 [TCP] - Application HTTP
  • 443 [TCP] - Application HTTPS
  • 9000 [TCP] - Control Panel HTTP
  • 9443 [TCP] - Control Panel HTTPS
  • 16005 [TCP] - Monitoring (average analysis times, analysis queues, ...)
  • 16006 [TCP] - Application API (coverage, ...)
  • 2377 [TCP] - Docker Swarm Cluster Management Communications
  • 7946 [TCP] - Docker Swarm Communication Among Nodes
  • 7946 [UDP] - Docker Swarm Communication Among Nodes
  • 4789 [UDP] - Docker Swarm Overlay Network Traffic

Additional nodes will require:

  • 2377 [TCP] - Docker Swarm Cluster Management Communications
  • 7946 [TCP] - Docker Swarm Communication Among Nodes
  • 7946 [UDP] - Docker Swarm Communication Among Nodes
  • 4789 [UDP] - Docker Swarm Overlay Network Traffic

1.2.2 - External

All this ports should be accessible to all the servers

 

1.3 - Database

Codacy requires a PostgreSQL (>=9.4) database to run.

This database should be accessible by all the nodes.

Codacy will need a database user with CREATEDB permissions.

To test the DB connection, you will need to be able to successfully connect to it through a docker container:

docker run -it --rm postgres:9.4.5 sh -c 'exec psql -h "<POSTGRESQL-HOST>" -p "<POSTGRESQL-PORT>" -U <POSTGRESQL-USER>'

 

1.4 - Software

Codacy is compatible with the following operating systems:

  • Ubuntu 16.04

If you need to install Codacy on a different operative system please contact us first. Although docker aims at being environment independent, not all Linux distributions fully support the docker features that Codacy relies on to run. Installing Codacy on a different OS may yield unpredictable results or it may not run at all.

 

2 - Installation


The installation is made with a one line shell script:

bash -c "$(curl -fsSL https://get.codacy.com/)"

This script will update the kernel and install the required Docker version to run Codacy. If you previously installed docker, please check the documentation on how to uninstall it before running this script.

The script will need to restart the server to apply the changes. After the server restarts, run the same bash command as before:

bash -c "$(curl -fsSL https://get.codacy.com/)"

The script will detect that docker is installed (it was installed with this script so you can ignore the warning and wait 20 seconds) then ask for proxy configurations. It will then proceed to install the Codacy Control Panel.

Adding more machines

To allow more concurrent analysis we allow you to add up to two nodes in your Codacy setup.

To do so, you can run the same script that was ran in the new machine:

bash -c "$(curl -fsSL https://get.codacy.com/)"

 

This time, select to setup the secondary machines as worker nodes. You will be asked for some information that you can get from the leader node, with: 

docker swarm join-token worker

After this, you will be ready to start the configuration process in step (3).

 

3 - Configuration


The configuration interface is web-based and can be accessed via port 9000 over HTTP (e.g., http://192.168.0.1:9000) of the server you've installed on (make sure that the port 9000 is accessible from your local computer).

 

3.1 - Server license

The first screen will ask you for a license to be installed to access the application web UI. This will be a file with the extension .dlk. This will provide you access to download a custom built virtual infrastructure of Codacy that you can run in your own infrastructure.

The license should be provided by a Codacy representative.

3.2 - Control panel

After validating the license, you will be presented with the Codacy Control Panel, used to configure and update the application.

Codacy Control Panel

The console provides access to configuration keys and allows Codacy to be updated so it is strongly advised that the console is secured against unwanted access.

 

3.3 - Application updates

For the initial application installation or future Codacy updates, click the button CHECK FOR UPDATES , on the top right corner. If a new update is available, a new option will appear:

New version available

Before any new version is ready to start running, a manual check of configurations is required. To configure the new version, click on the upper right corner link CONFIGURE . This will open a new screen with every configuration key required to run Codacy.

Application configuration

Codacy will provide some sane default settings. You will need to change a couple to connect the database, setup DNS and HTTPS.

To configure the connection to the database change following settings:

Mandatory settings to be reviewed

 

To configure the public DNS you need to change Host IP to either the machine public IP or the DNS you have configured. This will be used to send emails, generate links and needs to be a global DNS (local host changes in your machine will not work).

 

After this you should be ready to Save.

 

After configuring the main sections and saving, if you have a setup with more than two nodes, you will be able to configure the analysis distribution by selecting in which machines the listener and the manager components will run. Make sure you follow the specs in the beginning.

 

codacy-enterprise-docker-swarm-labels.png

 

After configuring the application, you will return to the update screen. This time, however, a new option to pull the version is presented in the upper left corner:

PULL option available

 

Pressing PULL dockers will start an async method that can take up to 30 min, depending on your internet connection. This will pull Codacy images from dockerhub, making them available in the local registry for application execution.

 


Pulling dockers

 

When done, a success message will show in the logs, and refreshing the page will show a new option RUN in the upper right corner toolbar:

Docker pulled & RUN

 

Pressing RUN will start the application. At any time, you can check the status of Codacy by navigating to Support:

Support screen

There, all dockers will show their status. Also, the DOWNLOAD LOGS link will create a zip file with all container logs, that can be used to debug your installation at any time.

 

3.3.1 - Updating the Control Panel

Some updates might require the latest version of the control panel. To download the latest version you need to login to the machine via SSH and execute: 

bash -c "$(curl -fsSL https://getenterprise.codacy.com/get)" -s update

After the installation is completed you'll be able to access your server via HTTP on port 9000. There should be a new version running.

 

3.4 Running Codacy

Database IP

If the database IP is incorrectly configured, Codacy will try to do an initial connection and wait on it before enabling the HTTP server. If the server is inaccessible, this will render Codacy unavailable.

You can navigate to port 80 (http) or port 443 (https) of your server in order to test your installation of Codacy. Codacy will provide you with a checkup page that will scan for any missed configuration setting.


Failed settings screen

 

3.5 Registration

When all settings are correct, Codacy will ask you to create the initial account in the registration screen.


Registration panel

The first user to register will be admin and will be able to administer the platform and create additional users.

 

3.6 Initial configuration

Internet access

At this point, as the application finished downloading all components; internet access can be removed from the machine if required.

 

Default patterns

You should now go to 'Admin > Patterns' to select the default patterns. These defaults will be applied to new projects when registered into the platform.

 


Code patterns 

Codacy is now ready to be used.

 

4 - Additional configurations


HTTP - Custom Port

To change the default control panel port (9000) you should export the environment variable "DOPLICATED_CLIENT_PORT" before invoking the control panel update command. 

bash -c "$(curl -fsSL https://getenterprise.codacy.com/get)" -s update

HTTPS - Control Panel

To have the control panel accessible with HTTPS, simply navigate to it and, in the settings panel, upload your CSR file without password, and the certificate key to the CSR file. By enabling the HTTPS settings, the control panel will be accessible through HTTPS, and it will use the configured port (9443 by default).  

 

Screen_Shot_2018-01-25_at_10.43.15.png

 

HTTPS - Codacy

To have Codacy accessible through HTTPS, click on "Configure" and set up the parameters as shown below; upload your CSR file without password, and the certificate key to the CSR file. This will enable HTTPS on Codacy on port 443 by default.

After this is complete make sure you "Save" and click "Reload".

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.