Deploying a .NET Core + Angular SPA with Docker and GitLab - asp.net

I have a droplet in Digital Ocean with Ubuntu 20.04 and a .NET Core web application that connects to Mongo.
My deployment workflow is the following:
I work locally with Visual Studio and release my app to a folder.
Then I connect to my server through FTP and drag the content of my folder to /var/www/myapp
Secrets are managed by Azure (it took me a lot of time to set this up).
A service runs the app and restarts it if needed.
The web server is Nginx
Everything works fine, nothing new so far. However, I'd like to automate each deployment and I found GitLab can run a pipeline to help me achieve that. The problem is I don't understand how to set this up correctly since I've seen there are more partes involved, such as Docker and Kubernetes, and I feel a bit overwhelmed.
Do I need to "dockerize" my application, database, etc.? If I want to add Angular as the client side, do I need to dockerize it as well or it goes in the same container as the .NET Core app?
Do I need Kubernetes? If so, why?
What would be the most straightforward and recommended way of achieving a CI/CD for my app?
It took me a lot of effort to deploy to my Linux server and I'm afraid I can destroy something in production.
I would really appreciate any help.

Related

How to debug ASP.NET MVC web app without pushing a commit in CodeStar (AWS)

There is something that I cannot really understand during the AWS CodeStar development flow. Let's say I am developing a web app (MVC) locally, it works and now I want to test it remotely before deploying to the final production environment.
CodeStar has created a Git repository for pushing the changes and it automatically starts the building, testing and deployment tasks. I have few questions:
How can I deploy a change to verify that it works BEFORE doing any sort of commit (avoiding to put dirty commits in the case there are some errors) to the remote environment?
How can I DEBUG a remotely ASP.NET application (breakpoints, etc...)?
How can I tell the application to use a different development database (or any other AWS service) while it is in the development "status" ?
Thank you for your delucidations.

asp.net MVC 5 hosting setup

Note: because there is no windows hosting that satisfies me at the moment, I'm developing my application in PHP and host them on a linux VPS.
Since Windows Server 2016 supports Docker and you are able to create .net 4.5 images, I thought why not review my applications and hosting plans.
Because I'm not a fan of hosting websites directly on a VPS with IIS (setup and configuration seems clumsy), I thought this "infrastructure" seems ideal for me.
A Windows 2016 VPS
A Linux based VPS
For each asp.net application, create a docker image based on microsoft/iis. This means that for the application, there is nothing left to be configured, right? This application will run on the Windows 2016 server.
On the Linux VPS, I will have nginx configured to have all the configuration for SSL certificates and optimizations. Nginx will have proxies that point to the Windows 2016 VPS on specific ports for the different applications.
I think this architecture has scaling possibilities, less configuration on the Windows VPS, more room for improvement? It should even be possible to do this with Ansible if I'm not wrong.
I only need hosting, nothing related to email, ftp, ... That's why I'm not using shared and/or cloud hosting.
Does this architecture seem fine?
Am I missing something?
Would you still just use a Windows VPS for hosting asp.net applications, even if this architecture is possible?
Does this all seem possible with Ansible? I only have basic experience with it.
I don't see anything wrong in your proposal. Remember you can use ansible inside the Linux image's Dockerfile. Maybe you can find that it is an overkill but it should work.
Probably you will find some problems linking your Linux / Windows containers. But I don't see anything short stopping.
Go ahead and post your results. Also if you encounter some walls just ask here and we will try to help.
Regards
because there is no windows hosting that satisfies me at the moment, I'm developing my application in PHP and host them on a linux VPS.
Would you mind telling us a bit about your requirement of Windows Hosting?
For each asp.net http://asp.net/ application, create a docker image based on microsoft/iis. This means that for the application, there is nothing left to be configured, right?
Once fully functional pre-configured image is prepared, you don't have to perform any other changes to your main image. The main image is only modified when you want to update any application in the image or looking to make any changes or update Windows OS.
Does this architecture seem fine?
NGINX reverse proxy works with IIS backend, so, this proposed architecture is achievable. Initial setup of connecting Linux VPS NGINX web server to individual Windows docker image is slightly complex. If you are successful doing that, the next challenge will be adding subsequent dockers to Windows Hyper-V. Here, I don't see actual purpose of using Docker images to host ASP.Net http://asp.net/ applications, when you can easily deploy pre-installed VMs through Windows HyperVisor.
As far as Ansible is concerned, I don't have much idea about this product, but as seen on their website Ansible can automate the dockers.

How to deploy a .NET web application in Mono hosted on a Linux Server?

We have a web application we've been writing in VB.NET. We want to get that running within a Linux server, specifically CentOS. I installed Mono version 4.0.1 on the server, as well as xsp and mod_mono. I'm not sure however, how to properly configure the setup to get the application running. We have several .aspx and .dll files. Do I just FTP them over to the server? I think we would need some wrapper executable script to get the application going, since all the websites I have been looking at state that, but I'm not sure how that works for a web application.
If you are using Visual Studio, you should use FTP to deploy your asp.net applications into GNU Linux environment. The IDE would take care of what files has to be deployed in order to get your asp.net application working.
But if you are using MonoDevelop you could use SSH Fuse. Here you have a Getting Started guide about working and deploying ASP.NET apps from MonoDevelop to an Linux environment:
http://www.monodevelop.com/documentation/creating-aspnet-projects/
If you don't have experience with FUSE, don't worry I get this for you
https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh
That's all. You don't need a wrapper as you mentioned before, it is pretty much like and an standard IIS site. Quite easy right? It has to work always that your application and its dependencies are compatible with mono, and indeed with apache or xsp configured correctly.
Cheers!

Changing Web Service from Localhost to Server

I've got a small WCF service I've created.
I can edit it and get it working great on the localhost, but my PC is not where this application is going to be run from. It is going to run on our Server.
However, every time I try making any kind of change to the project that points it to our server, the entire project goes to crap: I can no longer view the project in a browser and my test console application can not connect to it. I try changing it back to using the local IIS web server, but then the local machine does not start up IIS whenever the project is started so it doesn't work either.
I can debug and troubleshoot for a day or so to get it working again on the local machine, but then I'm back to Square 1 where I need to deploy my application onto our Server.
This is freakin' maddening!
My project works, but I can't seem to get it from Localhost to a real Server.
All the examples I find online show how to do this using Localhost. Does no one ever deploy their projects?
Where is the Guide for getting me from Development stage to Deploy?
Some nice tutorials here
http://www.dotnetspider.com/forum/193466-Deploy-Wcf-service-IIS.aspx
http://wcftutorial.net/WCF-IIS-Hosting.aspx
also on SO Deploy WCF Service to IIS when it only has an App.config
Also a video on youtube http://www.youtube.com/watch?v=mX8quq7MoeI

Windows Azure version backward

Today, I checked my windows azure website (built with a web service) And the version was not the same as yesterday. It's very strange, it seems that ther version went backward.
So I took my project in VS and reuploaded it. Then it was good
I am quite scared, is it a normal behaviour, I think not. But how to stop this behaviour. If I remember well it's not the first time it happens to my project.
Thanks a lot for your help.
Internally if there is any problem within Azure, It is the nature of Azure to Remove the troublesome VMs and Deploy a new VM with the "cspkg" File that we upload during application deployment either through Azure portal or through Visual studio directly.
In case You make any changes through RDP to the deployed application, there is no guarantee that the application will retain the Changes.
Further more if you face this again, it is better to contact Microsoft Support, They should help you out.
Here is the explanation of the Microsoft Support :
Any changes made with Web Deploy are temporary. It can only be used for development and testing and not intended for updating applications in production. When the role instance is restarted, the changes will be gone. We would suggest that you upgrade the deployment by uploading package files from the management portal or disabling WebDeploy while deploying.
You can read more about Web Deploy here http://blogs.msdn.com/b/cloud/archive/2011/04/19/enabling-web-deploy-for-windows-azure-web-roles-with-visual-studio.aspx.

Resources