-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix PostgreSqlConnectorScripts.RemoveAllScript in Azure
- Loading branch information
1 parent
df215a2
commit f9cc544
Showing
1 changed file
with
1 addition
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f9cc544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Southwind inside of a Docker Container and running in Azure
I've spent the last days dockerizing
Southwind
. This is the related commit.There were a few issues upgrading
Signum.TSGeneator
andSignum.MSBuildTask
to .Net Core 3.1 and fixing casing in some TS files, but except for that everything worked nicely.Why Docker?
Docker has been around since 2013 and it's currently a very popular technology. It combines the lightweight of a Process with the OS isolation of a Virtual Machine.
This is huge for many solutions, but not so important for the typical Signum Framework application:
Still, being able to do this kind of stuff in a Signum Framework application can be useful in some cases.
There are other more down-to-earth advantages for using Docker:
Installing Docker for Windows
Install Docker for Windows.
Debugging Southwind.React with with Visual Studio
In Visual Studio, F5 (Play) button, choose Docker and play. Visual Studio will look for a Dockerfile in the Southwind.React folder and only read the first lines to check the base image, then create a custom (aka Magic) docker container with shared folders, so changes in the website are automatically reflected inside of the docker. It makes a great development experience but not a great way of learn how docker works. More info here.
Creating a Docker image with the CLI
Got to
Southwind
folder (the one withSouthwind.sln
file) and run docker build.This will create a Docker image tagged as
southwind
. An image is like a CD or a Zip file containing your application and all the dependencies. Images are stacked on top of each other after any change in the dockerfile, and identical images can be cached and identified by his SHA. Very much like how Git commits stack on top of each parent.A tag is a non-unique name for an image.
You can then run the image doing:
This will create a docker container named
southwind_container
from thesouthwind
image and start it. A container is a running image.You can list, start, stop, or remove containers with the CLI, or use Visual Studio Containers window for it.
It's not a good idea to have the connection strings inside of the docker image. Instead you can pass it as an environment variable:
Pushing to Azure
Finally in your Azure Portal you have to create a Container Registry (they cost money, choose the cheap one or reuse another one). I named mine
southwindcr.azurecr.io
. You will get a username and password.You can use VisualStudio to publish, or use the docker cli:
Finally in Azure create the Web App for Containers:
Once the App Service is created go to
Settings
>Configuration
and add an environment variable forConnectionStrings__ConnectionString
with your secret connection string.I've created two App Settings, one with an Sql Server connection string (https://southwindsqlserver.azurewebsites.net/) and one for PostgreSQL (https://southwindpostgres.azurewebsites.net/)
Azure SQL Server vs PostgreSQL
Both SQL Server and PostgreSQL are configured to spend about 25€/Month (under my 150€/Month Credit of my Enterprise MSDN subscription). But I think Azure SQL Server is
substantiallyslightly faster for the same price in Azure.Dockerize Southwind.Terminal?
It's definitely possible to dockerize
Southwind.Terminal
(akaSouthwind.Load
) too, but since deploying to Staging requires creating migrations interactively and the Docker file-system is read-only I'm not sure if it's worth that the first time you test running the Terminal in a Linux environment is when deploying to Live. Uppercase / lowercase of CSV file paths in CSharp migrations could crash for example.Happy know your opinion about it.
Enjoy!
f9cc544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f9cc544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're on a roll Olmo!
f9cc544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f9cc544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remember that it is bad practice to expose .net core to the world.
You have to put a real web-server in front of it.
For example, you can take Nginx / Apache and place it as a reverse proxy. (https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-3.1).
Kestrel is not intended to be exposed to the world. it is just an internal entry point.
f9cc544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine that a Azure Web App is behind some kind of web server. Https was automatic for example.
f9cc544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No... is not:
f9cc544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the SSL are automatically provisioned by the cloud providers via LetEncrypt. but this can be done for kestrel as well.
When you put Nginx in front, you expose a port for Nginx and let it communicated with .net inside docker network communication.
f9cc544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you expand the dockerfile to have nginx in the middle ?
f9cc544
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you add Nginx reverse proxy you add it as an independent container. moreover, this should not be part of your development env.
this should be added to your Kubernetes YAML or docker-compose yaml for deployment.
Also, in general, this is not something you are sharing as part of an opensource project, it is very different between environments, this is not "one suit fits all".
Also, in most cases, you don't add it as a dockerfile, it is more of a service inside docker-compose and you control its settings in docker-compose.yaml,
This is how a typical Nginx reverse proxy looks like, note the
proxy_pass
line, this is how you point to kestrel internally.app1
is .net core service/container name...