✅ Hosting MVC project on LINUX VPS using github actions
Hello, I have recently finished working on a website and would like to host it on VPS, have been researching about this and few things got me kind of curious. What I understood is that before hosting I should install ,NET SDK which contains kestrel and need to install Nginx as reverse proxy, which also seems simple to set up, but then starts the trouble to me, as far as I know I can't see actual desktop and can't install such tools as SSMS to make managing database, in such scenario, how am I supposed to create initial database and obtain
ConnectionString
? It's also downside that I can't manually interfere with database. Another thing is SSL, I found out that I need to use Certbot
to get certificate and automatically renew it, are there no configurations needed other than just something like sudo certbot --nginx -d domain.com
? and also, I am supposed to make first deployment with SSH? or do I need to make specific actions before that. Lastly, is it safe to save ConnectionString
as environment variable?6 Replies
I should install ,NET SDKNo need. You can publish your project as a self-contained app and it will bundle everything, including the .NET runtime, into a single executable.
how am I supposed to create initial databaseMigrations and seeding. Migrations can be compiled into an executable as well. Alternatively, you could create a backup of the schema of your local database and use that.
obtain ConnectionString
That's usually in the app settings or environmental variables.
It's also downside that I can't manually interfere with databaseYou can connect to a remote database with your db tool of choice, no problem.
CertbotPlenty of documentation on the topic. You could even use Caddy instead of Nginx and it will handle certs for you.
No need. You can publish your project as a self-contained app and it will bundle everything, including the .NET runtime, into a single executable.it's first time hearing about such thing, so just adding
self-contained true
in publish section will work? Would it instal MS SQL too for me considering I'm using EF Core
Migrations and seeding. Migrations can be compiled into an executable as well. Alternatively, you could create a backup of the schema of your local database and use that.it's at startup that I'm using
context.Database.Migrate()
to ensure database is up to date, but I believe it doesn't create database itself, also if I want it to be secure I should use user too, so how am I supposed to database or user for my database so I can then access it remotely and with application if I can't use ssms on VPS?No, it will not install any 3rd party software
.Migrate()
will create a database. It will not install MMSQL or Postgres or whatever, but it will create a database if MSSQL is running and connected
Far as security goes, you can whitelist your IP so that only you can connect to that database (besides localhost) or you can use something like Cloudflare Tunnel, or some other VPN solutionisn't there any method to create actual users for it through terminal though?
For the database? Yeah, there certainly is
A tunnel or a whitelist would be more secure, but good ol' login+password works as well
hm, thank you so much