Recommended way to deploy Nuxt.js App with Express - express

I'm looking into using Nuxt.js for a new Web application with an Express server / API attached in the project itself. I've created the Nuxt.js application with the npx create-nuxt-app command and selected Express as "custom server framework".
When using the development environment (npm run dev), it works like a charm. Now, I want to deploy the application to a server which is running pm2 using Gitlab CI. I struggle with the right way to deploy the application, as I don't think I should "upload" the sourcecode to the server and then run the neccessary commands like npm run build or npm start. So, what is actually "the right way" to deploy this application with the server?
I have SSH access to a server where I want to deploy this application & API. The server is running pm2 for managing the Node processes.
Furthermore, the sourcecode is in a repository on a Gitlab server with a Gitlab CI Runner available. The current gitlab-ci.yml does the following:
npm install
npm run build
lftp the dist folder to the server
With a SPA, only the client is built and the server / API is not. We now have a, in my opinion, dirty workaround which doesn't work very well that does the following:
npm install
npm run build
mirror the whole project to the server
use a watcher in pm2 to detect changes in files
build project again???
It looks like it doesn't work as intended and I have the feeling we are creating problems instead of solving the deployment issue the right way. We don't use Heroku, Google or any other services for hosting the application, it's just a webhosting with SSH access basically.

Related

how to run a NuxtJS project automatically

NuxtJS project management is developed on GitHub.
The following is the development procedure.
1.Push updates from your local PC to the GitHub remote repository.
2.Log in to your hosting server and pull the remote repository to retrieve the differences.
3.Then run npm run build and npm run generate to update the project.
Is there a way to run npm run * automatically after downloading the differences from the remote repository?
I think you are looking for GitHub webhooks. See the documentation here.

Add npm run build to Fortrabbit deploy process

Using Fortrabbit to deploy a PHP app which uses a node project for the front end. Is there any way in which I can add npm run build to the deploy process instead of having to always build first manually and then deploying it through Fortrabbit?
(There is a fortrabbit.yaml file on the fortrabbit site that needs to be configured for every fortrabbit app but the example doesn't show how we can add that command in the deployment pipeline.)
Sorry. There is no way to run Node JS during deployment on fortrabbit yet.

GitLab CI / CD: do I need docker for ASP.NET Core - Angular application

I am having self-hosted GitLab-EE. I want to enable CI / CD. I already have gitlab-runner on windows and it is activated for my project.
I also have custom server for hosting my ASP.NET Core 2.0 with Angular 5.0 application.
My final idea is when commit is made to GitLab, build and deploy (to custom server) is executed. Deploy path would be different if commit to master was made or any other branch (from merge request) conditional by Git Tag.
Almost all tutorials use docker, but I couldn't found why? What are the cons using docker?
I thought I only need msbuild (I can also install Visual Studio) on machine where GitLab-runner is running. It would build and deploy application. I found this configuration file which doesn't use docker, but question remains. Do I need docker and why?
A docker image would contain all the msbuild dependencies and build tools needed to build your application with out you going through the trouble of manually installing them on your server.
So basically docker helps you to manage dependencies of you application more efficiently.

Gitlab CE Continuous Integration build node/angular app and deploy dist folder to server

I've spent countless hours trying to understand how to do this correctly.
I have a nodejs application with angular front-end which are both contained in the same project.
I would simply like to have Gitlab CE CI build the project and then copy the resulting dist folder and package.json file to the production server and restart
I have a shared gitlab runner setup and was able to successfully configure the ssh runner.
Using the Gitlab runner ssh I was able to copy the entire project to the production server but cannot get it to build (plus I really don't want to have all files on the server, just the production required files.
what am I missing. do you use a docker runner with a node image to build the project and they scp files to the production server?
Any guidance would greatly be appreciated.
Yes, I think you already state the solution.
I would recommend looking into Job Artifacts to build your application in a Docker-based build job and upload the production files as an artifact.
The next job could then deploy (by scp or ssh+wget/curl) the artifact files to your production server and restart the webserver.

How to Serve an Aurelia.io app without using Gulp watch

How do you run an Aurelia app without running gulp watch and just going to localhost:9000. Ideally I would like to just run my nodejs server and it all just works without having to run a separate task (a gulp task).
I would like to build Aurelia and just start using it in the same way that I can with Durandal.
take a look at the Aurelia-Node Repo for a quick start. It uses ExpressJS to provide a simple REST api as well as static serve the Aurelia App.
You'd still need the Gulp task (inside public/app) to build your es6 modules etc. but the hosting then works from node itself, so gulp build should be enough.
EDIT:
The repo provides a gulpfile in the root as well. The big difference using this one is that it not only transpiles the frontend code but also browserSyncs the node application via nodemon. Again all of this is not necessary for final hosting. A normal node app.js would be enough. Gulp etc. is just used during the development process.
I download Aurelia repository from
https://github.com/aurelia/
And run project successfully via webstrom on different port not on localhost:9000 without "gulp watch" .
But I installed Aurelia dependency then started project on webstorm its run successfully.
Steps for run project without "gulp watch"...
Run given command on command line from project folder.
Install the Apps dependencies - **npm install**
Install JSPM dependencies - **jspm install -y**
Install Gulp - **npm install gulp**
then explore your index.html page on chrome. Make sure you running Aurelia in Chrome, IE and Firefox.
I tested Aurelia application in Chrome, IE , Safari and Firefox result
Chrome - Pass
IE - Pass
Firefox - Pass
Safari - Fail
But in safari that was fail.