Show More
@@ -1,243 +1,243 b'' | |||||
1 | .. _dev-setup: |
|
1 | .. _dev-setup: | |
2 |
|
2 | |||
3 | =================== |
|
3 | =================== | |
4 | Development setup |
|
4 | Development setup | |
5 | =================== |
|
5 | =================== | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | RhodeCode Enterprise runs inside a Nix managed environment. This ensures build |
|
8 | RhodeCode Enterprise runs inside a Nix managed environment. This ensures build | |
9 | environment dependencies are correctly declared and installed during setup. |
|
9 | environment dependencies are correctly declared and installed during setup. | |
10 | It also enables atomic upgrades, rollbacks, and multiple instances of RhodeCode |
|
10 | It also enables atomic upgrades, rollbacks, and multiple instances of RhodeCode | |
11 | Enterprise running with isolation. |
|
11 | Enterprise running with isolation. | |
12 |
|
12 | |||
13 | To set up RhodeCode Enterprise inside the Nix environment, use the following steps: |
|
13 | To set up RhodeCode Enterprise inside the Nix environment, use the following steps: | |
14 |
|
14 | |||
15 |
|
15 | |||
16 |
|
16 | |||
17 | Setup Nix Package Manager |
|
17 | Setup Nix Package Manager | |
18 | ------------------------- |
|
18 | ------------------------- | |
19 |
|
19 | |||
20 | To install the Nix Package Manager, please run:: |
|
20 | To install the Nix Package Manager, please run:: | |
21 |
|
21 | |||
22 | $ curl https://nixos.org/nix/install | sh |
|
22 | $ curl https://nixos.org/releases/nix/nix-2.0.4/install | sh | |
23 |
|
23 | |||
24 | or go to https://nixos.org/nix/ and follow the installation instructions. |
|
24 | or go to https://nixos.org/nix/ and follow the installation instructions. | |
25 | Once this is correctly set up on your system, you should be able to use the |
|
25 | Once this is correctly set up on your system, you should be able to use the | |
26 | following commands: |
|
26 | following commands: | |
27 |
|
27 | |||
28 | * `nix-env` |
|
28 | * `nix-env` | |
29 |
|
29 | |||
30 | * `nix-shell` |
|
30 | * `nix-shell` | |
31 |
|
31 | |||
32 |
|
32 | |||
33 | .. tip:: |
|
33 | .. tip:: | |
34 |
|
34 | |||
35 | Update your channels frequently by running ``nix-channel --update``. |
|
35 | Update your channels frequently by running ``nix-channel --update``. | |
36 |
|
36 | |||
37 | .. note:: |
|
37 | .. note:: | |
38 |
|
38 | |||
39 | To uninstall nix run the following: |
|
39 | To uninstall nix run the following: | |
40 |
|
40 | |||
41 | remove the . "$HOME/.nix-profile/etc/profile.d/nix.sh" line in your ~/.profile or ~/.bash_profile |
|
41 | remove the . "$HOME/.nix-profile/etc/profile.d/nix.sh" line in your ~/.profile or ~/.bash_profile | |
42 | rm -rf $HOME/{.nix-channels,.nix-defexpr,.nix-profile,.config/nixpkgs} |
|
42 | rm -rf $HOME/{.nix-channels,.nix-defexpr,.nix-profile,.config/nixpkgs} | |
43 | sudo rm -rf /nix |
|
43 | sudo rm -rf /nix | |
44 |
|
44 | |||
45 | Switch nix to the latest STABLE channel |
|
45 | Switch nix to the latest STABLE channel | |
46 | --------------------------------------- |
|
46 | --------------------------------------- | |
47 |
|
47 | |||
48 | run:: |
|
48 | run:: | |
49 |
|
49 | |||
50 | nix-channel --add https://nixos.org/channels/nixos-18.03 nixpkgs |
|
50 | nix-channel --add https://nixos.org/channels/nixos-18.03 nixpkgs | |
51 |
|
51 | |||
52 | Followed by:: |
|
52 | Followed by:: | |
53 |
|
53 | |||
54 | nix-channel --update |
|
54 | nix-channel --update | |
55 | nix-env -i nix-2.0.4 |
|
55 | nix-env -i nix-2.0.4 | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | Install required binaries |
|
58 | Install required binaries | |
59 | ------------------------- |
|
59 | ------------------------- | |
60 |
|
60 | |||
61 | We need some handy tools first. |
|
61 | We need some handy tools first. | |
62 |
|
62 | |||
63 | run:: |
|
63 | run:: | |
64 |
|
64 | |||
65 | nix-env -i nix-prefetch-hg |
|
65 | nix-env -i nix-prefetch-hg | |
66 | nix-env -i nix-prefetch-git |
|
66 | nix-env -i nix-prefetch-git | |
67 |
|
67 | |||
68 |
|
68 | |||
69 | Speed up JS build by installing PhantomJS |
|
69 | Speed up JS build by installing PhantomJS | |
70 | ----------------------------------------- |
|
70 | ----------------------------------------- | |
71 |
|
71 | |||
72 | PhantomJS will be downloaded each time nix-shell is invoked. To speed this by |
|
72 | PhantomJS will be downloaded each time nix-shell is invoked. To speed this by | |
73 | setting already downloaded version do this:: |
|
73 | setting already downloaded version do this:: | |
74 |
|
74 | |||
75 | nix-env -i phantomjs-2.1.1 |
|
75 | nix-env -i phantomjs-2.1.1 | |
76 |
|
76 | |||
77 | # and set nix bin path |
|
77 | # and set nix bin path | |
78 | export PATH=$PATH:~/.nix-profile/bin |
|
78 | export PATH=$PATH:~/.nix-profile/bin | |
79 |
|
79 | |||
80 |
|
80 | |||
81 | Clone the required repositories |
|
81 | Clone the required repositories | |
82 | ------------------------------- |
|
82 | ------------------------------- | |
83 |
|
83 | |||
84 | After Nix is set up, clone the RhodeCode Enterprise Community Edition and |
|
84 | After Nix is set up, clone the RhodeCode Enterprise Community Edition and | |
85 | RhodeCode VCSServer repositories into the same directory. |
|
85 | RhodeCode VCSServer repositories into the same directory. | |
86 | RhodeCode currently is using Mercurial Version Control System, please make sure |
|
86 | RhodeCode currently is using Mercurial Version Control System, please make sure | |
87 | you have it installed before continuing. |
|
87 | you have it installed before continuing. | |
88 |
|
88 | |||
89 | To obtain the required sources, use the following commands:: |
|
89 | To obtain the required sources, use the following commands:: | |
90 |
|
90 | |||
91 | mkdir rhodecode-develop && cd rhodecode-develop |
|
91 | mkdir rhodecode-develop && cd rhodecode-develop | |
92 | hg clone -u default https://code.rhodecode.com/rhodecode-enterprise-ce |
|
92 | hg clone -u default https://code.rhodecode.com/rhodecode-enterprise-ce | |
93 | hg clone -u default https://code.rhodecode.com/rhodecode-vcsserver |
|
93 | hg clone -u default https://code.rhodecode.com/rhodecode-vcsserver | |
94 |
|
94 | |||
95 | .. note:: |
|
95 | .. note:: | |
96 |
|
96 | |||
97 | If you cannot clone the repository, please contact us via support@rhodecode.com |
|
97 | If you cannot clone the repository, please contact us via support@rhodecode.com | |
98 |
|
98 | |||
99 |
|
99 | |||
100 | Install some required libraries |
|
100 | Install some required libraries | |
101 | ------------------------------- |
|
101 | ------------------------------- | |
102 |
|
102 | |||
103 | There are some required drivers and dev libraries that we need to install to |
|
103 | There are some required drivers and dev libraries that we need to install to | |
104 | test RhodeCode under different types of databases. For example in Ubuntu we |
|
104 | test RhodeCode under different types of databases. For example in Ubuntu we | |
105 | need to install the following. |
|
105 | need to install the following. | |
106 |
|
106 | |||
107 | required libraries:: |
|
107 | required libraries:: | |
108 |
|
108 | |||
109 | # svn related |
|
109 | # svn related | |
110 | sudo apt-get install libapr1-dev libaprutil1-dev |
|
110 | sudo apt-get install libapr1-dev libaprutil1-dev | |
111 | sudo apt-get install libsvn-dev |
|
111 | sudo apt-get install libsvn-dev | |
112 | # libcurl required too |
|
112 | # libcurl required too | |
113 | sudo apt-get install libcurl4-openssl-dev |
|
113 | sudo apt-get install libcurl4-openssl-dev | |
114 | # mysql/pg server for development, optional |
|
114 | # mysql/pg server for development, optional | |
115 | sudo apt-get install mysql-server libmysqlclient-dev |
|
115 | sudo apt-get install mysql-server libmysqlclient-dev | |
116 | sudo apt-get install postgresql postgresql-contrib libpq-dev |
|
116 | sudo apt-get install postgresql postgresql-contrib libpq-dev | |
117 |
|
117 | |||
118 |
|
118 | |||
119 |
|
119 | |||
120 | Enter the Development Shell |
|
120 | Enter the Development Shell | |
121 | --------------------------- |
|
121 | --------------------------- | |
122 |
|
122 | |||
123 | The final step is to start the development shells. To do this, run the |
|
123 | The final step is to start the development shells. To do this, run the | |
124 | following command from inside the cloned repository:: |
|
124 | following command from inside the cloned repository:: | |
125 |
|
125 | |||
126 | # first, the vcsserver |
|
126 | # first, the vcsserver | |
127 | cd ~/rhodecode-vcsserver |
|
127 | cd ~/rhodecode-vcsserver | |
128 | nix-shell |
|
128 | nix-shell | |
129 |
|
129 | |||
130 | # then enterprise sources |
|
130 | # then enterprise sources | |
131 | cd ~/rhodecode-enterprise-ce |
|
131 | cd ~/rhodecode-enterprise-ce | |
132 | nix-shell |
|
132 | nix-shell | |
133 |
|
133 | |||
134 | .. note:: |
|
134 | .. note:: | |
135 |
|
135 | |||
136 | On the first run, this will take a while to download and optionally compile |
|
136 | On the first run, this will take a while to download and optionally compile | |
137 | a few things. The following runs will be faster. The development shell works |
|
137 | a few things. The following runs will be faster. The development shell works | |
138 | fine on both MacOS and Linux platforms. |
|
138 | fine on both MacOS and Linux platforms. | |
139 |
|
139 | |||
140 |
|
140 | |||
141 | Create config.nix for development |
|
141 | Create config.nix for development | |
142 | --------------------------------- |
|
142 | --------------------------------- | |
143 |
|
143 | |||
144 | In order to run proper tests and setup linking across projects, a config.nix |
|
144 | In order to run proper tests and setup linking across projects, a config.nix | |
145 | file needs to be setup:: |
|
145 | file needs to be setup:: | |
146 |
|
146 | |||
147 | # create config |
|
147 | # create config | |
148 | mkdir -p ~/.nixpkgs |
|
148 | mkdir -p ~/.nixpkgs | |
149 | touch ~/.nixpkgs/config.nix |
|
149 | touch ~/.nixpkgs/config.nix | |
150 |
|
150 | |||
151 | # put the below content into the ~/.nixpkgs/config.nix file |
|
151 | # put the below content into the ~/.nixpkgs/config.nix file | |
152 | # adjusts, the path to where you cloned your repositories. |
|
152 | # adjusts, the path to where you cloned your repositories. | |
153 |
|
153 | |||
154 | { |
|
154 | { | |
155 | rc = { |
|
155 | rc = { | |
156 | sources = { |
|
156 | sources = { | |
157 | rhodecode-vcsserver = "/home/dev/rhodecode-vcsserver"; |
|
157 | rhodecode-vcsserver = "/home/dev/rhodecode-vcsserver"; | |
158 | rhodecode-enterprise-ce = "/home/dev/rhodecode-enterprise-ce"; |
|
158 | rhodecode-enterprise-ce = "/home/dev/rhodecode-enterprise-ce"; | |
159 | rhodecode-enterprise-ee = "/home/dev/rhodecode-enterprise-ee"; |
|
159 | rhodecode-enterprise-ee = "/home/dev/rhodecode-enterprise-ee"; | |
160 | }; |
|
160 | }; | |
161 | }; |
|
161 | }; | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 |
|
164 | |||
165 |
|
165 | |||
166 | Creating a Development Configuration |
|
166 | Creating a Development Configuration | |
167 | ------------------------------------ |
|
167 | ------------------------------------ | |
168 |
|
168 | |||
169 | To create a development environment for RhodeCode Enterprise, |
|
169 | To create a development environment for RhodeCode Enterprise, | |
170 | use the following steps: |
|
170 | use the following steps: | |
171 |
|
171 | |||
172 | 1. Create a copy of vcsserver config: |
|
172 | 1. Create a copy of vcsserver config: | |
173 | `cp ~/rhodecode-vcsserver/configs/development.ini ~/rhodecode-vcsserver/configs/dev.ini` |
|
173 | `cp ~/rhodecode-vcsserver/configs/development.ini ~/rhodecode-vcsserver/configs/dev.ini` | |
174 | 2. Create a copy of rhodocode config: |
|
174 | 2. Create a copy of rhodocode config: | |
175 | `cp ~/rhodecode-enterprise-ce/configs/development.ini ~/rhodecode-enterprise-ce/configs/dev.ini` |
|
175 | `cp ~/rhodecode-enterprise-ce/configs/development.ini ~/rhodecode-enterprise-ce/configs/dev.ini` | |
176 | 3. Adjust the configuration settings to your needs if needed. |
|
176 | 3. Adjust the configuration settings to your needs if needed. | |
177 |
|
177 | |||
178 | .. note:: |
|
178 | .. note:: | |
179 |
|
179 | |||
180 | It is recommended to use the name `dev.ini` since it's included in .hgignore file. |
|
180 | It is recommended to use the name `dev.ini` since it's included in .hgignore file. | |
181 |
|
181 | |||
182 |
|
182 | |||
183 | Setup the Development Database |
|
183 | Setup the Development Database | |
184 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
184 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
185 |
|
185 | |||
186 | To create a development database, use the following example. This is a one |
|
186 | To create a development database, use the following example. This is a one | |
187 | time operation executed from the nix-shell of rhodecode-enterprise-ce sources :: |
|
187 | time operation executed from the nix-shell of rhodecode-enterprise-ce sources :: | |
188 |
|
188 | |||
189 | rc-setup-app dev.ini \ |
|
189 | rc-setup-app dev.ini \ | |
190 | --user=admin --password=secret \ |
|
190 | --user=admin --password=secret \ | |
191 | --email=admin@example.com \ |
|
191 | --email=admin@example.com \ | |
192 | --repos=~/my_dev_repos |
|
192 | --repos=~/my_dev_repos | |
193 |
|
193 | |||
194 |
|
194 | |||
195 | Compile CSS and JavaScript |
|
195 | Compile CSS and JavaScript | |
196 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
196 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
197 |
|
197 | |||
198 | To use the application's frontend and prepare it for production deployment, |
|
198 | To use the application's frontend and prepare it for production deployment, | |
199 | you will need to compile the CSS and JavaScript with Grunt. |
|
199 | you will need to compile the CSS and JavaScript with Grunt. | |
200 | This is easily done from within the nix-shell using the following command:: |
|
200 | This is easily done from within the nix-shell using the following command:: | |
201 |
|
201 | |||
202 | make web-build |
|
202 | make web-build | |
203 |
|
203 | |||
204 | When developing new features you will need to recompile following any |
|
204 | When developing new features you will need to recompile following any | |
205 | changes made to the CSS or JavaScript files when developing the code:: |
|
205 | changes made to the CSS or JavaScript files when developing the code:: | |
206 |
|
206 | |||
207 | grunt watch |
|
207 | grunt watch | |
208 |
|
208 | |||
209 | This prepares the development (with comments/whitespace) versions of files. |
|
209 | This prepares the development (with comments/whitespace) versions of files. | |
210 |
|
210 | |||
211 | Start the Development Servers |
|
211 | Start the Development Servers | |
212 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
212 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
213 |
|
213 | |||
214 | From the rhodecode-vcsserver directory, start the development server in another |
|
214 | From the rhodecode-vcsserver directory, start the development server in another | |
215 | nix-shell, using the following command:: |
|
215 | nix-shell, using the following command:: | |
216 |
|
216 | |||
217 | pserve configs/dev.ini |
|
217 | pserve configs/dev.ini | |
218 |
|
218 | |||
219 | In the adjacent nix-shell which you created for your development server, you may |
|
219 | In the adjacent nix-shell which you created for your development server, you may | |
220 | now start CE with the following command:: |
|
220 | now start CE with the following command:: | |
221 |
|
221 | |||
222 |
|
222 | |||
223 | pserve --reload configs/dev.ini |
|
223 | pserve --reload configs/dev.ini | |
224 |
|
224 | |||
225 | .. note:: |
|
225 | .. note:: | |
226 |
|
226 | |||
227 | `--reload` flag will automatically reload the server when source file changes. |
|
227 | `--reload` flag will automatically reload the server when source file changes. | |
228 |
|
228 | |||
229 |
|
229 | |||
230 | Run the Environment Tests |
|
230 | Run the Environment Tests | |
231 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
231 | ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
232 |
|
232 | |||
233 | Please make sure that the tests are passing to verify that your environment is |
|
233 | Please make sure that the tests are passing to verify that your environment is | |
234 | set up correctly. RhodeCode uses py.test to run tests. |
|
234 | set up correctly. RhodeCode uses py.test to run tests. | |
235 | While your instance is running, start a new nix-shell and simply run |
|
235 | While your instance is running, start a new nix-shell and simply run | |
236 | ``make test`` to run the basic test suite. |
|
236 | ``make test`` to run the basic test suite. | |
237 |
|
237 | |||
238 |
|
238 | |||
239 | Need Help? |
|
239 | Need Help? | |
240 | ^^^^^^^^^^ |
|
240 | ^^^^^^^^^^ | |
241 |
|
241 | |||
242 | Join us on Slack via https://rhodecode.com/join or post questions in our |
|
242 | Join us on Slack via https://rhodecode.com/join or post questions in our | |
243 | Community Portal at https://community.rhodecode.com |
|
243 | Community Portal at https://community.rhodecode.com |
General Comments 0
You need to be logged in to leave comments.
Login now