The DeploySite utility is necessary because Visual Studio Publish and dotnet publish are insufficient to deploy a YetaWF site. YetaWF uses symlinks heavily which can't be deployed by other tools.
The deployment method shown here is typically used for first-time deployment. For subsequent deploys, see Deploying To A Server (FTP, Automatic Blue/Green), which offers an automatic way to deploy the Blue or Green site, based on the currently active site.
Blue/Green deployment is a simple technique where you deploy a site while the current site continues to be up and running. Only once deployment has finished will the new site become active. For this to work a proxy is needed that delegates traffic to the correct site. In this documentation, deployment using IIS is shown. But the same techniques can also be used with other proxies, such as nginx. For additional details about Blue/Green deployment see IIS Proxy (Blue/Green Deploy).
Deploying to a server using FTP is a two step process. First, the site is backed up locally, including SQL databases, and uploaded. The second step takes place on the server where the site is restored, again using DeploySite. All tools and config settings are uploaded so no tools need to be installed.
A yaml file (named DeploySite.Windows.yaml in this example) is used to define all the deployment attributes. The following is an example of a yaml file used to deploy via FTP to a server. It also backups up the SQL database yetawf which is used by the site. Multiple databases can be defined if necessary.
Databases: - DevDB: yetawf DevServer: localserver DevUsername: theuser DevPassword: thepassword ProdDB: yetawf-production ProdServer: productionserver ProdUsername: theuser ProdPassword: thepassword Deploy: Type: zip To: C:\Temp\Website.zip BaseFolder: C:\Development\YetaWF From: C:\Temp\PublishOutput ConfigParm: Windows.Prod FTP: Server: ftp://yourftpserver Port: 21 User: ftpuser Password: ftppassword Copy: - From: .\DeploySite.Windows.yaml To: /DeploySite.yaml ReplaceBG: true # The following is the health check file - From: .\Website\wwwroot\Maintenance\_hc.html To: /_hc.html ReplaceBG: true # The following is the web.config file for the IIS proxy - From: .\web-BLUEGREEN.config To: /web-BLUEGREEN.config ReplaceBG: true # This is the ZIP file we're uploading - From: C:\Temp\Website.zip To: /Website.zip # The following are required so you can run DeploySite on the server - From: .\PublicTools\DeploySite\Bin\Windows\Softelvdm.DeploySite.exe To: /PublicTools/DeploySite/Bin/Softelvdm.DeploySite.exe Conditional: true - From: .\Restore.bat To: /Restore.bat Site: Location: C:\Sites\YetaWF-BLUEGREEN Zip: C:\Sites\Website.zip RunFirst: - Command: C:\windows\system32\inetsrv\appcmd.exe stop site /site.name:YetaWF-BLUEGREEN - Command: C:\windows\system32\inetsrv\appcmd.exe stop apppool /apppool.name:YetaWF-BLUEGREEN IgnoreErrors: true Run: - Command: C:\windows\system32\inetsrv\appcmd.exe start apppool /apppool.name:YetaWF-BLUEGREEN - Command: C:\windows\system32\inetsrv\appcmd.exe start site /site.name:YetaWF-BLUEGREEN - Command: Copy /Y "Web-BLUEGREEN.config" "YetaWF-BlueGreen\Web.config" - Command: Del "YetaWF-Blue\wwwroot\_hc.html" IgnoreErrors: true - Command: Del "YetaWF-Green\wwwroot\_hc.html" IgnoreErrors: true - Command: Copy /Y "_hc.html" "YetaWF-BLUEGREEN\wwwroot\_hc.html"
In this example, the root of the FTP server is C:\Sites. This means when we upload file DeploySite.Windows.yaml to /DeploySite.yaml it is saved at C:\Sites\DeploySite.yaml.
For information about available options see the topic DeploySite yaml File.
The first step in deploying a site is to run Visual Studio Publish or dotnet publish. In this example, the solution file is located at C:\Development\YetaWF and the published (partial) site is created at C:\Temp\PublishOutput.
Softelvdm.DeploySite Backup yourfile.yaml Blue (or Green)
The DeploySite utility takes your partial deployed site (from C:\Temp\PublishOutput merged with C:\Development\YetaWF) and adds all JavaScript, CSS, config files, saving the result as a ZIP file at C:\Temp\Website.zip. Then the FTP,Copy: statements are executed, uploading all necessary files to the server. In this example, the root of the FTP server is C:\Sites. This means when we upload file DeploySite.Windows.yaml to /DeploySite.yaml it is saved at C:\Sites\DeploySite.yaml.
Once everything is uploaded to the server, run the DeploySite utility on the server:
Softelvdm.DeploySite Restore yourfile.yaml
The Site tag in the yaml file is used determine how the site is restored to the server. In this example the ZIP file C:\Sites\Website.zip is unzipped and the site is created in the folder C:\Sites\YetaWF.
The Site tag offers additional options, particularly the ability to run commands before and after creating the site can be useful. It could be used to start/stop IIS application pools, update database permissions, etc. For information about available options see the topic DeploySite yaml File.
Last Updated 11/12/2020 - (email)
© 2023 - Softel vdm, Inc. - YetaWF.com