Skip to content

Commit

Permalink
Update README for Linux #7
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonZiminSaritasa committed Sep 20, 2018
1 parent daea5bf commit 454494f
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 33 deletions.
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
ASP.NET Core Deployment
=======================
ASP.NET Core Deployment on Linux
================================

Set up Server
-------------

### Enable WinRM

Enable WinRM over HTTPS on server, generate certificate, add firewall rule:

```powershell
Install-PackageProvider NuGet -Force; Install-Module Saritasa.WinRM -Force; Install-WinrmHttps
```
Set up Build Server
-------------------

More details: [WinRM Configuration](https://github.com/Saritasa/PSGallery/blob/master/docs/WinRMConfiguration.md)
Install .NET Core SDK, PowerShell Core, psake.

### Trust Server
You can do it with Ansible:

Add client to trusted certificate authorities list on build server or developer PC:

```powershell
Install-Module Saritasa.Web -Force
Import-TrustedSslCertificate web.saritasa.local 5986
```sh
ansible-galaxy install brentwg.powershell geerlingguy.jenkins geerlingguy.nginx ocha.dotnet-core
ansible-playbook -i inventory.yml --limit buildservers buildserver.yml -Kv
```

### Configure Server
Set up Web Server
-----------------

Edit `inventory.yml`. Set correct values:

- hostname
- site_name
- service_name
- deploy_username
- deploy_password
- deploy_key
- ansible_username
- ansible_password

Install Ansible modules:

```sh
ansible-galaxy install brentwg.powershell geerlingguy.jenkins geerlingguy.nginx ocha.dotnet-core
```

Execute Ansible playbook:

```sh
cd ansible
ansible-playbook -i inventory.yml web.yml -v
ansible-playbook -i inventory.yml --limit webservers web.yml -Kv
```

Scaffold Scripts
Expand Down Expand Up @@ -80,19 +78,10 @@ Required Software

You need following software installed:

- [Visual Studio 2017](https://www.visualstudio.com/downloads/)
- [psake](https://github.com/psake/psake)
- [Git](https://git-scm.com/)
- [GitVersion](https://gitversion.readthedocs.io/)
- [.NET Core SDK 2.1](https://www.microsoft.com/net/download)

You can easily install most software with Chocolatey package manager. To do that run `PowerShell` as administrator and type commands:

```powershell
PS> iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
PS> choco install psake git gitversion.portable dotnetcore-sdk
```

Build Project
-------------

Expand Down Expand Up @@ -172,7 +161,18 @@ Create a credential with **secret file** type. Add credential parameter to job w
}
```

Create SSH credential with `deployuser` name. Use it in `sshagent` block:

```groovy
script {
sshagent(['deployuser']) {
sh script: "psake publish-web"
}
}
```

Articles
--------

[Config Transformations](docs/ConfigTransformations.md)
- [Config Transformations](docs/ConfigTransformations.md)
- [Psake on Linux](docs/PsakeOnLinux.md)
59 changes: 59 additions & 0 deletions docs/PsakeOnLinux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Psake on Linux
==============

Here's a small instruction how to use psake on Linux.

- Install PowerShell Core

https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-powershell-core-on-linux?view=powershell-6

- Clone psake repository

```sh
git clone https://github.com/psake/psake /opt/psake
```

- Create wrapper

```sh
sudo sh -c 'echo "#!/bin/env sh\npwsh -Command \"& /opt/psake/src/psake.ps1 \$@; if (\\\$psake.build_success -eq \\\$false) { exit 1 } else { exit 0 }\"" > /usr/bin/psake'
sudo chmod +x /usr/bin/psake
```

It will create following script:

```sh
#!/usr/bin/env sh
pwsh -Command "& /opt/psake/src/psake.ps1 $@; if (\$psake.build_success -eq \$false) { exit 1 } else { exit 0 }"
```

You may use Ansible to do the actions above. Tested on Ubuntu Server 18.04.

```yaml
- hosts: buildserver

roles:
- brentwg.powershell

vars:
ansible_become: true

tasks:
- name: Clone psake repository
git:
repo: 'https://github.com/psake/psake'
dest: /opt/psake
- name: Create psake wrapper
copy:
content: |
#!/usr/bin/env sh
pwsh -Command "& /opt/psake/src/psake.ps1 $@; if (\$psake.build_success -eq \$false) { exit 1 } else { exit 0 }"
dest: /usr/bin/psake
mode: 0755

pre_tasks:
- name: Enable Universe repository
apt_repository:
repo: deb http://archive.ubuntu.com/ubuntu bionic universe
become: yes
```

0 comments on commit 454494f

Please sign in to comment.