To learn more about the DeepCode Server and the prerequisites, go here. 


We support GitLab 9.0.0 or greater for both GitLab Community Edition and GitLab Enterprise Edition.


  

Video Tutorial


  

  

Documentation

Creating a user account

DeepCode needs to have access to one user account at which it will create comments on your pull requests and commits. It is recommended to choose a name for the user that signals that this user is controlled artificially (e.g. "DeepCode Bot"). The user can either be created as normal user or as admin user. The latter is easier to setup but you might feel more comfortable not assigning admin rights.


1. Normal user

Create a normal user. DeepCode's code review will work for all repositories for which the user ha"developer" permissions. Thus you need to manually give it these permissions on all repositories for which you want to enable the code review.


2. Admin user

Create an admin user. DeepCode's code review will work for all current and future repositories.


Creating a personal access token

To give DeepCode Server access to the user account please follow these instructions to create a personal access token for the created user. The required scopes are api, read_user, read_repository. It is not recommended to set an expiration date on the token. Record the access token as it is required later.


 

 

Setting up an application inside GitLab

  1. Visit your GitLab instance and log in.
  2. Navigate to user settings.
  3. Navigate to "Applications".
  4. In the name field, enter "DeepCode".
  5. In the redirect URI field, enter the full URL to the DeepCode server and append "/api/gl/login". For example: http://my-deepcode/api/gl/login
  6. Select the scopes "api", "read_user" and "read_repository".
  7. Click "Save application"


The Application details page contains secret keys. You are going to need both Application ID and Secret  to configure DeepCode server in the next step.


 

 

  

DeepCode Server

DeepCode Server is the self-managed software that will integrate with GitLab. Before you set it up, first create the configuration files that are necessary to run DeepCode Server:

  1. Create a directory at some path that will hold all configuration files.
  2. Change working directory to this folder.
  3. Create a file gl.env with the following content:
PRODUCT=gl_op
HOST_URL=http://my-deepcode-url
FRONT_PORT=any port available on your host, 8080 by default
GIT_LAB_URL=http://my-gitlab-url
GIT_LAB_APP_ID=MyGitLabAppId
GIT_LAB_APP_SECRET=MyGitLabAppSecret
GIT_LAB_PERSONAL_ACCESS_TOKEN=MyGitLabPersonalAccessToken
NODE_TLS_REJECT_UNAUTHORIZED=0 or 1

 

HOST_URL

Replace this with the URL under which DeepCode Server will be reachable. E.g. http://deep.code or http://179.16.64.12:8081Please note that because the server is running inside a docker container the hostname localhost  will not work. Further, if you use any IP address that points to the local network e.g. 192.168.*.*  you need to enable a special option in GitLab.

 

GIT_LAB_URL

Insert the URL of your GitLab Server. E.g. http://git.lab or http://17.65.954.21:7990 

 

GIT_LAB_APP_ID and GIT_LAB_APP_SECRET

Insert the Application ID and Secret  of your GitLab Application created earlier.

 

PERSONAL_ACCESS_TOKEN

Insert the personal access token that you created earlier. 

 

NODE_TLS_REJECT_UNAUTHORIZED

If you host GitLab using self-signed SSL certificate, please set this value or 0  (number zero) Otherwise, remove it or leave it 1 

 

FRONT_PORT

The container exposes a webserver on port 8080 by default. Usually, you would bind it to port 80 by replacing FRONT_PORT with 80. 

   


  

Command for starting the server

The full command to start DeepCode Server is as follows:

  docker run --rm -it -v '/var/run/docker.sock:/var/run/docker.sock' -v $PWD:$PWD -w $PWD --env-file ./gl.env --name deepcode deepcode

 

Arguments description:

  docker run                 \ # Run a docker container
    --rm                     \ # Remove the container after it was stopped.
    -it                      \ # (Optional) to acquire terminal
    -v '/var/run/docker.sock:/var/run/docker.sock' \ # Mount Docker socket file
    -v $PWD:$PWD             \ # Mount working dir for storing container data between restarts
    -w $PWD                  \ # set working directory
    --env-file ./gl.env      \ # Configuration file created earlier
    --name deepcode          \ # (Optional) set container name
    deepcode                   # Name of docker image to run.

Container data

This folder will contain data of the running container:

  • mysqldata for persistent database
  • redisdata for cache
  • clones for temporary cache with cloned repositories



To finish the integration, manage the DeepCode Server


If you encounter problems at any point during the setup please don't hesitate to ask for help at deepcode@deepcode.ai