Commit b67ee216317fe8d580c4ecfa4c2ae023271fe22a
1 parent
663586ee
added documentation for deployment
Showing
2 changed files
with
78 additions
and
28 deletions
README.md
@@ -9,7 +9,8 @@ BeuthBot is a master project of the Beuth University of Applied Sciences Berlin. | @@ -9,7 +9,8 @@ BeuthBot is a master project of the Beuth University of Applied Sciences Berlin. | ||
9 | - [Application properties](#application-properties) | 9 | - [Application properties](#application-properties) |
10 | - [Docker configuration](#docker-configuration) | 10 | - [Docker configuration](#docker-configuration) |
11 | - [Local tunnel](#local-tunnel) | 11 | - [Local tunnel](#local-tunnel) |
12 | -- [Debugging](#debugging) | 12 | +- [Debug application](#debugging) |
13 | +- [Deploy application](#aeploy-application) | ||
13 | - [Known issues](#known-issues) | 14 | - [Known issues](#known-issues) |
14 | - [Used online sources](#used-online-sources) | 15 | - [Used online sources](#used-online-sources) |
15 | 16 | ||
@@ -49,7 +50,7 @@ The project should be cloned from the repository. For development it is possible | @@ -49,7 +50,7 @@ The project should be cloned from the repository. For development it is possible | ||
49 | 50 | ||
50 | With the following command it is possible to build the whole project. The construction of the project is possible during operation and before starting the server. In the first case the running server is automatically updated during operation. | 51 | With the following command it is possible to build the whole project. The construction of the project is possible during operation and before starting the server. In the first case the running server is automatically updated during operation. |
51 | 52 | ||
52 | -``` | 53 | +```bash |
53 | ./gradlew war | 54 | ./gradlew war |
54 | ``` | 55 | ``` |
55 | 56 | ||
@@ -57,17 +58,17 @@ With the following command it is possible to build the whole project. The constr | @@ -57,17 +58,17 @@ With the following command it is possible to build the whole project. The constr | ||
57 | 58 | ||
58 | The application can be started with the following command: | 59 | The application can be started with the following command: |
59 | 60 | ||
60 | -``` | 61 | +```bash |
61 | # Unix | 62 | # Unix |
62 | ./gradlew chatbotRun | 63 | ./gradlew chatbotRun |
63 | ``` | 64 | ``` |
64 | 65 | ||
65 | -``` | 66 | +```bash |
66 | # Windows | 67 | # Windows |
67 | gradlew.bat chatbotRun | 68 | gradlew.bat chatbotRun |
68 | ``` | 69 | ``` |
69 | 70 | ||
70 | -``` | 71 | +```bash |
71 | # MacOS | 72 | # MacOS |
72 | cd docker | 73 | cd docker |
73 | docker-compose up --build | 74 | docker-compose up --build |
@@ -88,17 +89,17 @@ In addition it is also possible to set up your own bot for example, in Telegram | @@ -88,17 +89,17 @@ In addition it is also possible to set up your own bot for example, in Telegram | ||
88 | 89 | ||
89 | The following command can be used to stop the running application: | 90 | The following command can be used to stop the running application: |
90 | 91 | ||
91 | -``` | 92 | +```bash |
92 | # Unix | 93 | # Unix |
93 | ./gradlew chatbotStop | 94 | ./gradlew chatbotStop |
94 | ``` | 95 | ``` |
95 | 96 | ||
96 | -``` | 97 | +```bash |
97 | # Windows | 98 | # Windows |
98 | gradlew.bat chatbotStop | 99 | gradlew.bat chatbotStop |
99 | ``` | 100 | ``` |
100 | 101 | ||
101 | -``` | 102 | +```bash |
102 | # MacOS | 103 | # MacOS |
103 | cd docker | 104 | cd docker |
104 | docker-compose down | 105 | docker-compose down |
@@ -159,30 +160,35 @@ MacOS: | @@ -159,30 +160,35 @@ MacOS: | ||
159 | MacOS requires XCode and Homebrew in order to install NodeJS. | 160 | MacOS requires XCode and Homebrew in order to install NodeJS. |
160 | XCode can be downloaded and installed for free via the App Store. | 161 | XCode can be downloaded and installed for free via the App Store. |
161 | 162 | ||
162 | -To install Homebrew, open a terminal window and type` | ||
163 | -``` | 163 | +To install Homebrew, open a terminal window and type |
164 | + | ||
165 | +```bash | ||
164 | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | 166 | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
165 | ``` | 167 | ``` |
166 | 168 | ||
167 | After Homebrew has completed installation, install NodeJS by typing: | 169 | After Homebrew has completed installation, install NodeJS by typing: |
168 | -``` | 170 | + |
171 | +```bash | ||
169 | brew install node | 172 | brew install node |
170 | ``` | 173 | ``` |
171 | 174 | ||
172 | Finally install localtunnel by typing: | 175 | Finally install localtunnel by typing: |
173 | -``` | 176 | + |
177 | +```bash | ||
174 | npm install -g localtunnel | 178 | npm install -g localtunnel |
175 | ``` | 179 | ``` |
176 | 180 | ||
177 | If everything has worked correctly, you are now ready to use localtunnel. | 181 | If everything has worked correctly, you are now ready to use localtunnel. |
178 | Using localtunnel is fairly easy, simply type: | 182 | Using localtunnel is fairly easy, simply type: |
179 | -``` | 183 | + |
184 | +```bash | ||
180 | lt --port 8080 | 185 | lt --port 8080 |
181 | ``` | 186 | ``` |
182 | 187 | ||
183 | Where the number entered after --port corresponds to the port you want localtunnel to route its HTTPS-Domain to. | 188 | Where the number entered after --port corresponds to the port you want localtunnel to route its HTTPS-Domain to. |
184 | The localtunnel server can be slow and a little unreliable at times, but if everything goes well you should see something like: | 189 | The localtunnel server can be slow and a little unreliable at times, but if everything goes well you should see something like: |
185 | -``` | 190 | + |
191 | +```bash | ||
186 | your url is: https://uawfhausjdj.localtunnel.me | 192 | your url is: https://uawfhausjdj.localtunnel.me |
187 | ``` | 193 | ``` |
188 | which is the url you can put in the first line of the `beuthbot.properties` file in the /docker/wildfly/volumes/conf` directory. | 194 | which is the url you can put in the first line of the `beuthbot.properties` file in the /docker/wildfly/volumes/conf` directory. |
@@ -193,7 +199,7 @@ NOTE: Localtunnel tends to crash every now and then, displaying an error message | @@ -193,7 +199,7 @@ NOTE: Localtunnel tends to crash every now and then, displaying an error message | ||
193 | 199 | ||
194 | <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --> | 200 | <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --> |
195 | 201 | ||
196 | -## Debugging | 202 | +## Debug application |
197 | 203 | ||
198 | At the moment, the JBoss server is always started with open debugging ports. To attach to the process using IntelliJ, a remote debug configuration has to be created. To do so, perform the following steps: | 204 | At the moment, the JBoss server is always started with open debugging ports. To attach to the process using IntelliJ, a remote debug configuration has to be created. To do so, perform the following steps: |
199 | 205 | ||
@@ -206,6 +212,59 @@ At the moment, the JBoss server is always started with open debugging ports. To | @@ -206,6 +212,59 @@ At the moment, the JBoss server is always started with open debugging ports. To | ||
206 | 212 | ||
207 | <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --> | 213 | <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --> |
208 | 214 | ||
215 | +## Deploy application | ||
216 | + | ||
217 | +The following paragraph describes how the deplyoment is performed from a local Git repository to the production server. All development statuses have to be transferred to the `master` branch before performing the deployment. Just from the `master` branch it is possible to carry out the deployment on the productive server. To be able to perform the deplyment, it is necessary to be able to access the server via SSH. Then Git will transfer the status of the `master` branch to the server. This requires customizations on the server and in the local Git. | ||
218 | + | ||
219 | +### 1. Setup on the server | ||
220 | + | ||
221 | +On the server the following Git command have to be executed in the directory `home/<user>/`. Instead of the placeholder `<projectname>` the actual name of the project has to be used. The command creates a Git directory which includes all necessary files for a Git Hook. | ||
222 | + | ||
223 | +```bash | ||
224 | +git init --bare ~/<projectname>.git | ||
225 | +``` | ||
226 | + | ||
227 | +After the Git folder has been successfully created, a new file with the name `post-receive` has to be created in the subfolder `<projectname>.git/hooks`. Afterwards the script has to be inserted into this file and the placeholders get changed by project-specific variables. The script will also start the `deployment.sh` script. This executes the build of the project and starts the appropriate Docker command. In addition, this script ensures that the `beuthbot.properties` file on the server is replaced by the corresponding productive file. In local development the `post-receive` and `deployment.sh` file can be found in the `scripts/` folder. | ||
228 | + | ||
229 | +```bash | ||
230 | +#!/bin/bash | ||
231 | +while read oldrev newrev ref | ||
232 | +do | ||
233 | + # only checking out the master (or whatever branch you would like to deploy) | ||
234 | + if [[ $ref =~ .*/master$ ]]; | ||
235 | + then | ||
236 | + echo "Master ref received. Deploying master branch to production..." | ||
237 | + git --work-tree=/home/<user>/<projectname>/ --git-dir=/home/<user>/<projectname>.git/ checkout -f | ||
238 | + cd /home/<user>/<projectname>/ | ||
239 | + ./scripts/deployment.sh | ||
240 | + else | ||
241 | + echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server." | ||
242 | + fi | ||
243 | +done | ||
244 | +``` | ||
245 | + | ||
246 | +In addition a folder with the project name `<projectname>` has to be created on the server in the directory `home/<user>/`. This is where the code from the `master` branch is pushed. | ||
247 | + | ||
248 | +```bash | ||
249 | +mkdir ~/<projectname> | ||
250 | +``` | ||
251 | + | ||
252 | +### 2. Use in a local development environment | ||
253 | + | ||
254 | +This step sets up a reference to the server on which the application is deployed. For this the following command must be executed. The placeholder `<user>` has to be replaced by the matching SSH user and the project `<projectname>` that has been set up on the server. | ||
255 | + | ||
256 | +```bash | ||
257 | +git remote add production ssh://<user>@<ip>:<port>/home/<user>/<projectname> | ||
258 | +``` | ||
259 | + | ||
260 | +After the Git remote settings have been made the current state of the `master` branch can be pushed to the server using the following command. | ||
261 | + | ||
262 | +```bash | ||
263 | +git push production master | ||
264 | +``` | ||
265 | + | ||
266 | +<!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --> | ||
267 | + | ||
209 | ## Known issues | 268 | ## Known issues |
210 | 269 | ||
211 | The following issues are currently known in the application: | 270 | The following issues are currently known in the application: |
docu/project_documentation.md
@@ -3,28 +3,19 @@ The hole project is build by gradle and divided into a couple of subprojects (cf | @@ -3,28 +3,19 @@ The hole project is build by gradle and divided into a couple of subprojects (cf | ||
3 | Each module is loosely connected through a Java Message Service. The application is running on a Jboss Wildfly | 3 | Each module is loosely connected through a Java Message Service. The application is running on a Jboss Wildfly |
4 | inside of a docker container. Another docker container is used for the Rasa backend. | 4 | inside of a docker container. Another docker container is used for the Rasa backend. |
5 | 5 | ||
6 | -## Infrastructure | ||
7 | -- see [docker compose file](../docker/docker-compose.yml) | ||
8 | - | ||
9 | -The productive project is represented by a separate Git repository in absent of a continuous integration server. | ||
10 | -Pushing into this repository will automatically trigger a rebuild of the productive environment. | ||
11 | -- confer [post-receive](../scripts/post-receive) - Git hook for auto deploying the application | ||
12 | - | ||
13 | -### Subprojects | ||
14 | - | ||
15 | -#### MainBot | 6 | +## MainBot |
16 | - [Canteen Parser](canteenParser.md) - web crawler for collecting data of the beuth university canteen | 7 | - [Canteen Parser](canteenParser.md) - web crawler for collecting data of the beuth university canteen |
17 | - Common - holding common classes used by all other subprojects | 8 | - Common - holding common classes used by all other subprojects |
18 | - [Drools](drools.md) - Business Rules Management System used to generate the right answer | 9 | - [Drools](drools.md) - Business Rules Management System used to generate the right answer |
19 | - Global - global available services | 10 | - Global - global available services |
20 | 11 | ||
21 | -#### Natural Language Processing | 12 | +## Natural Language Processing |
22 | - [ApiAi](apiai.md) - simple RESTEasy client application calling googles Api.ai API | 13 | - [ApiAi](apiai.md) - simple RESTEasy client application calling googles Api.ai API |
23 | - [Rasa](rasa.md) - simple RESTEasy client application calling the rasa backend rest API | 14 | - [Rasa](rasa.md) - simple RESTEasy client application calling the rasa backend rest API |
24 | 15 | ||
25 | -#### Messenger | 16 | +## Messenger |
26 | - [Facebook](facebook.md) - Facebook Messenger connector | 17 | - [Facebook](facebook.md) - Facebook Messenger connector |
27 | - [Telegram](telegram.md) - Telegram Messenger connector | 18 | - [Telegram](telegram.md) - Telegram Messenger connector |
28 | 19 | ||
29 | -#### Text <-> Speech Processing | 20 | +## Text <-> Speech Processing |
30 | - [Bing Speech](binspeechapi.md) - REST client for Microsofts Bing Speech API | 21 | - [Bing Speech](binspeechapi.md) - REST client for Microsofts Bing Speech API |
31 | \ No newline at end of file | 22 | \ No newline at end of file |