You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+44
Original file line number
Diff line number
Diff line change
@@ -402,6 +402,50 @@ See some elements, when you go to http://localhost:8080/#/bootstrap/ - this shou
402
402
A good discussion about various UI component frameworks: http://vuetips.com/bootstrap
403
403
404
404
405
+
## Heroku Deployment
406
+
407
+
As you may already read, the app is automatically deployed to Heroku on https://spring-boot-vuejs.herokuapp.com/.
408
+
409
+
The project makes use of the nice Heroku Pipelines feature, where we do get a full Continuous Delivery pipeline with nearly no effort:
410
+
411
+

412
+
413
+
And with the help of super cool `Automatic deploys`, we have our TravisCI build our app after every push to master - and with the checkbox set to `Wait for CI to pass before deploy` - the app gets also automatically deployed to Heroku - but only, if the TravisCI (and Coveralls...) build succeeded:
You only have to connect your Heroku app to GitHub, activate Automatic deploys and set the named checkbox. That´s everything!
418
+
419
+
420
+
#### Accessing correct Heroku Port in Vue.js frontend
421
+
422
+
Frontend needs to know the Port of our Spring Boot backend API, which is [automatically set by Heroku every time, we (re-)start our App](https://stackoverflow.com/a/12023039/4964553).
423
+
424
+
> You can [try out your Heroku app locally](https://devcenter.heroku.com/articles/heroku-local)! Just create a .env-File with all your Environment variables and run `heroku local`!
425
+
426
+
To access the Heroku set port, we need to configure the used port inside our Vue.js application dynamically instead of hard-coded. This can be easily achieved with the help of enviroment variables, which can be added to the [dev.env.js](https://github.com/jonashackt/spring-boot-vuejs/blob/master/frontend/config/dev.env.js) and [prod.env.js](https://github.com/jonashackt/spring-boot-vuejs/blob/master/frontend/config/prod.env.js) files. Let´s do this with the variable `API_PORT`:
427
+
428
+
```
429
+
module.exports = {
430
+
NODE_ENV: '"production"',
431
+
API_PORT: '"8077"'
432
+
}
433
+
```
434
+
435
+
Now we can access this variable inside our Vue.js application. Just access the variable inside the `<script>` area inside a method:
436
+
437
+
```
438
+
logPortEnvVariable () {
439
+
console.log('Now what´s the port?')
440
+
console.log(process.env.API_PORT)
441
+
}
442
+
```
443
+
444
+
If you want, have a look at [Service.vue](https://github.com/jonashackt/spring-boot-vuejs/blob/master/frontend/src/components/Service.vue), where this is implemented.
0 commit comments