dev-setup.rst
219 lines
| 5.8 KiB
| text/x-rst
|
RstLexer
r303 | .. _dev-setup: | |||
r1 | ||||
=================== | ||||
Development setup | ||||
=================== | ||||
RhodeCode Enterprise runs inside a Nix managed environment. This ensures build | ||||
environment dependencies are correctly declared and installed during setup. | ||||
It also enables atomic upgrades, rollbacks, and multiple instances of RhodeCode | ||||
r272 | Enterprise running with isolation. | |||
r1 | ||||
r271 | To set up RhodeCode Enterprise inside the Nix environment, use the following steps: | |||
r1 | ||||
Setup Nix Package Manager | ||||
------------------------- | ||||
r271 | To install the Nix Package Manager, please run:: | |||
r1 | ||||
$ curl https://nixos.org/nix/install | sh | ||||
r271 | or go to https://nixos.org/nix/ and follow the installation instructions. | |||
Once this is correctly set up on your system, you should be able to use the | ||||
r1 | following commands: | |||
* `nix-env` | ||||
* `nix-shell` | ||||
.. tip:: | ||||
r1418 | Update your channels frequently by running ``nix-channel --update``. | |||
r1 | ||||
r271 | Switch nix to the latest STABLE channel | |||
--------------------------------------- | ||||
r1 | ||||
run:: | ||||
nix-channel --add https://nixos.org/channels/nixos-16.03 nixpkgs | ||||
Followed by:: | ||||
nix-channel --update | ||||
r1215 | Install required binaries | |||
------------------------- | ||||
We need some handy tools first. | ||||
run:: | ||||
nix-env -i nix-prefetch-hg | ||||
nix-env -i nix-prefetch-git | ||||
r1 | Clone the required repositories | |||
------------------------------- | ||||
r271 | After Nix is set up, clone the RhodeCode Enterprise Community Edition and | |||
r1 | RhodeCode VCSServer repositories into the same directory. | |||
r1418 | RhodeCode currently is using Mercurial Version Control System, please make sure | |||
you have it installed before continuing. | ||||
To obtain the required sources, use the following commands: | ||||
r1 | ||||
mkdir rhodecode-develop && cd rhodecode-develop | ||||
hg clone https://code.rhodecode.com/rhodecode-enterprise-ce | ||||
hg clone https://code.rhodecode.com/rhodecode-vcsserver | ||||
.. note:: | ||||
r1418 | If you cannot clone the repository, please contact us via support@rhodecode.com | |||
r1 | ||||
r1215 | Install some required libraries | |||
------------------------------- | ||||
There are some required drivers that we need to install to test RhodeCode | ||||
under different types of databases. For example in Ubuntu we need to install | ||||
the following. | ||||
required libraries:: | ||||
sudo apt-get install libapr1-dev libaprutil1-dev | ||||
sudo apt-get install libsvn-dev | ||||
sudo apt-get install mysql-server libmysqlclient-dev | ||||
sudo apt-get install postgresql postgresql-contrib libpq-dev | ||||
sudo apt-get install libcurl4-openssl-dev | ||||
r1 | ||||
Enter the Development Shell | ||||
--------------------------- | ||||
r1418 | The final step is to start the development shells. To do this, run the | |||
r1 | following command from inside the cloned repository:: | |||
r1418 | #first, the vcsserver | |||
cd ~/rhodecode-vcsserver | ||||
nix-shell | ||||
# then enterprise sources | ||||
r1 | cd ~/rhodecode-enterprise-ce | |||
r271 | nix-shell | |||
r1 | ||||
.. note:: | ||||
On the first run, this will take a while to download and optionally compile | ||||
r272 | a few things. The following runs will be faster. The development shell works | |||
r489 | fine on both MacOS and Linux platforms. | |||
r1 | ||||
r1561 | Create config.nix for development | |||
--------------------------------- | ||||
In order to run proper tests and setup linking across projects, a config.nix | ||||
file needs to be setup:: | ||||
# create config | ||||
mkdir -p ~/.nixpkgs | ||||
touch ~/.nixpkgs/config.nix | ||||
# put the below content into the ~/.nixpkgs/config.nix file | ||||
# adjusts, the path to where you cloned your repositories. | ||||
{ | ||||
rc = { | ||||
sources = { | ||||
rhodecode-vcsserver = "/home/dev/rhodecode-vcsserver"; | ||||
rhodecode-enterprise-ce = "/home/dev/rhodecode-enterprise-ce"; | ||||
rhodecode-enterprise-ee = "/home/dev/rhodecode-enterprise-ee"; | ||||
}; | ||||
}; | ||||
} | ||||
r1 | ||||
Creating a Development Configuration | ||||
------------------------------------ | ||||
To create a development environment for RhodeCode Enterprise, | ||||
use the following steps: | ||||
r1418 | 1. Create a copy of vcsserver config: | |||
`cp ~/rhodecode-vcsserver/configs/development.ini ~/rhodecode-vcsserver/configs/dev.ini` | ||||
2. Create a copy of rhodocode config: | ||||
`cp ~/rhodecode-enterprise-ce/configs/development.ini ~/rhodecode-enterprise-ce/configs/dev.ini` | ||||
3. Adjust the configuration settings to your needs if needed. | ||||
r1 | ||||
r491 | .. note:: | |||
r1 | ||||
r1418 | It is recommended to use the name `dev.ini` since it's included in .hgignore file. | |||
r1 | ||||
Setup the Development Database | ||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||||
r271 | To create a development database, use the following example. This is a one | |||
r1418 | time operation executed from the nix-shell of rhodecode-enterprise-ce sources :: | |||
r1 | ||||
paster setup-rhodecode dev.ini \ | ||||
--user=admin --password=secret \ | ||||
--email=admin@example.com \ | ||||
--repos=~/my_dev_repos | ||||
r490 | Compile CSS and JavaScript | |||
^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||||
r701 | To use the application's frontend and prepare it for production deployment, | |||
you will need to compile the CSS and JavaScript with Grunt. | ||||
This is easily done from within the nix-shell using the following command:: | ||||
grunt | ||||
r490 | ||||
r701 | When developing new features you will need to recompile following any | |||
changes made to the CSS or JavaScript files when developing the code:: | ||||
r490 | ||||
r701 | grunt watch | |||
r490 | ||||
r701 | This prepares the development (with comments/whitespace) versions of files. | |||
r490 | ||||
r1418 | Start the Development Servers | |||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||||
r1 | ||||
r489 | From the rhodecode-vcsserver directory, start the development server in another | |||
nix-shell, using the following command:: | ||||
r1 | ||||
r1418 | pserve configs/dev.ini | |||
r1 | ||||
r489 | In the adjacent nix-shell which you created for your development server, you may | |||
now start CE with the following command:: | ||||
r1 | ||||
r491 | ||||
r1418 | pserve --reload configs/dev.ini | |||
r1 | ||||
r491 | .. note:: | |||
r1418 | `--reload` flag will automatically reload the server when source file changes. | |||
r1 | ||||
Run the Environment Tests | ||||
^^^^^^^^^^^^^^^^^^^^^^^^^ | ||||
r271 | Please make sure that the tests are passing to verify that your environment is | |||
r272 | set up correctly. RhodeCode uses py.test to run tests. | |||
r489 | While your instance is running, start a new nix-shell and simply run | |||
``make test`` to run the basic test suite. | ||||
Need Help? | ||||
^^^^^^^^^^ | ||||
Join us on Slack via https://rhodecode.com/join or post questions in our | ||||
Community Portal at https://community.rhodecode.com | ||||