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