Setup of Development env

These instructions are meant for developing RhodeCode from source code. To setup a development environment with all needed services for development follow the below actions:

define dev workspace home

Setup env variable WORKSPACE_HOME to your absolute path where you repositories for dev are stored. e.g

example:

WORKSPACE_HOME=/media/psf/Home/workspace

Set this on bash:

export WORKSPACE_HOME=/media/psf/Home/workspace

get rcstack & docker

To quickly get and install latest rcstack run this command

# create the rhodecode-docker dir, and cd into it
mkdir -p $WORKSPACE_HOME/rhodecode-docker && cd $WORKSPACE_HOME/rhodecode-docker

# get latest rcstack
curl -L -s -o rcstack https://code.rhodecode.com/rhodecode-enterprise-docker/raw/master/scripts/rcstack/rcstack && chmod +x rcstack

./rcstack init

Previously used ./rcstack init command will setup docker, and bootstrap the env, but we still need to fetch dev-tools

# make sure we got the latest dev-tools installed
curl -L -s -o dev-tools https://code.rhodecode.com/rhodecode-enterprise-docker/raw/master/scripts/dev-tools/dev-tools && chmod +x dev-tools

# Please check available options using --help
./dev-tools --help

Obtain source code

Please clone the following repositories into the WORKSPACE_HOME directory

For CE development:

cd $WORKSPACE_HOME/rhodecode-docker
git clone ssh://rhodecode@code.rhodecode.com:3022/rhodecode-vcsserver
git clone ssh://rhodecode@code.rhodecode.com:3022/rhodecode-enterprise-ce
# make a dummy repo without source code
mkdir rhodecode-enterprise-ee

for EE development (dev team, you have to have access to internal repos):

cd $WORKSPACE_HOME/rhodecode-docker
git clone ssh://rhodecode@code.rhodecode.com:3022/internal/rhodecode-vcsserver
git clone ssh://rhodecode@code.rhodecode.com:3022/internal/rhodecode-enterprise-ce
git clone ssh://rhodecode@code.rhodecode.com:3022/internal/rhodecode-enterprise-ee

Finally this is the structure you should get:

ls -la $WORKSPACE_HOME
drwxr-xr-x 1 docker docker       928 Dec 18 23:46 rhodecode-docker
drwxr-xr-x 1 docker docker      1504 Dec 18 23:46 rhodecode-enterprise-ce
drwxr-xr-x 1 docker docker      1280 Dec 18 23:46 rhodecode-enterprise-ee
drwxr-xr-x 1 docker docker       832 Dec 18 23:46 rhodecode-vcsserver

run dev-env

First start with setting up a dev builds for dev images

cd $WORKSPACE_HOME/rhodecode-docker && ./rcstack cli set-image beta

To start developing we need few services to run, we can run this using dev-env

cd $WORKSPACE_HOME/rhodecode-docker && ./dev-tools dev-env

Note

There’s an option to run dev version of each of the service, e.g if ssh or svn should be tested it can be run like ./dev-tools ssh ./dev-tools svn

You can check the status of services by running

cd $WORKSPACE_HOME/rhodecode-docker && ./rcstack status

Prepare services in develop mode

Go to rhodecode-docker/.custom/.runtime.env and copy a value of DB_PASSWORD.

Go to rhodecode-enterprise-ce/configs/development.ini and update sqlalchemy.db1.url variable as:

sqlalchemy.db1.url = postgresql://rhodecode:{insert DB_PASSWORD value here, remove brackets}@database/rhodecode

In $WORKSPACE_HOME/rhodecode-docker, copy the runtime.env as our dev.env:

$WORKSPACE_HOME/rhodecode-docker && cp .custom/.runtime.env .custom/.dev.env

go to rhodecode-vcsserver and run

cd $WORKSPACE_HOME/rhodecode-vcsserver
mkdir -p .dev/
echo "make sh" > .dev/dev-env.sh && chmod +x .dev/dev-env.sh
cp configs/development.ini .dev/dev.ini
cp configs/gunicorn_config.py .dev/gunicorn_config.py

go to rhodecode-enterprise-ce and run

cd $WORKSPACE_HOME/rhodecode-enterprise-ce
mkdir -p .dev/
echo "make sh" > .dev/dev-env.sh && chmod +x .dev/dev-env.sh
cp configs/development.ini .dev/dev.ini
cp configs/gunicorn_config.py .dev/gunicorn_config.py

run services (preferably in two separate shells)

Creates and attaches Docker containers, providing an interactive command-line interface within each container.

Note

To start the web servers, run a separate command after the containers are created.

cd $WORKSPACE_HOME/rhodecode-docker

# shell 1
./dev-tools ce
➜ rhodecode-enterprise-ce

# shell 2
./dev-tools vcs
➜ rhodecode-vcsserver

Init DB

# run from enterprise shell rhodecode-enterprise-ce

/usr/local/bin/rhodecode_bin/bin/rc-setup-app \
/home/rhodecode/rhodecode-enterprise-ce/.dev/dev.ini \
--force-yes \
--skip-existing-db \
--user=admin \
--password=secret4 \
--email=admin@example.com \
--repos=/var/opt/rhodecode_repo_store

Note

–user=admin –password=secret4 used here can be used to log-in to first super-admin account in web UI

Manually Upgrade DB

/usr/local/bin/rhodecode_bin/bin/rc-upgrade-db \
/home/rhodecode/rhodecode-enterprise-ce/.dev/dev.ini \
--force-yes

Start enterprise-ce and vcsserver web servers

To start the web server, use the container terminal (see the “Run Services” section above) and execute the following command for each service.

make dev-srv

View service on localhost

Add line in /etc/hosts file: 127.0.0.1 rhodecode.local. Check http://rhodecode.local:10020/ and login with credentials you created.

Note

Default super-admin account: Username: admin Password: secret4

Build static JS files

Go to rhodecode-enterprise-ce and run command:

# execute from cd $WORKSPACE_HOME/rhodecode-enterprise-ce
docker run -it --rm -v $PWD:/project --workdir=/project rhodecode/static-files-build:16 -c "npm install && grunt"

Rebuild dev-env.

Known issues and fixes

Services not running on Apple M-series or other, ARM CPUs

Add platform: linux/amd64 line in rhodecode-docker/docker-compose-apps.yaml for following services as in example:

services:
    # base shared options for RhodeCode type services
    common_base:
        platform: linux/amd64
        image: rhodecode/rhodecode-${RC_EDITION}:${RC_VERSION}

platform: linux/arm64

and add platform: linux/arm64 or platform: linux/amd64 line in rhodecode-docker/docker-compose-services.yaml for following services as in example:

services:
    channelstream:
        platform: linux/amd64

    nginx-statics:
        platform: linux/arm64

    nginx-errors:
        platform: linux/arm64

    elasticsearch:
        platform: linux/amd64

    redis:
        platform: linux/arm64

    database:
        platform: linux/arm64

    database-mysql:
        platform: linux/arm64

Pyramid toolbar not found

In rhodecode-vcsserver, in file requirements.txt add ‘pyramid_debugtoolbar as an additional library to fetch.