mirror of
https://github.com/openfaas/faas.git
synced 2025-06-13 18:56:46 +00:00
Check that Docker is in Swarm mode
This commit updates deploy_stack.ps1 to check that Docker is running in Swarm mode before proceeding. Signed-off-by: John McCabe <john@johnmccabe.net>
This commit is contained in:
parent
8d041efd0c
commit
7d5955b6f2
@ -2,33 +2,41 @@
|
|||||||
|
|
||||||
if (Get-Command docker -errorAction SilentlyContinue)
|
if (Get-Command docker -errorAction SilentlyContinue)
|
||||||
{
|
{
|
||||||
|
docker node ls 2>&1 | out-null
|
||||||
$user_secret = "basic-auth-user"
|
|
||||||
docker secret inspect $user_secret 2>&1 | out-null
|
|
||||||
if($?)
|
if($?)
|
||||||
{
|
{
|
||||||
Write-Host "$user_secret secret exists"
|
$user_secret = "basic-auth-user"
|
||||||
|
docker secret inspect $user_secret 2>&1 | out-null
|
||||||
|
if($?)
|
||||||
|
{
|
||||||
|
Write-Host "$user_secret secret exists"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$user = Read-Host 'Admin User?'
|
||||||
|
$user | docker secret create $user_secret -
|
||||||
|
}
|
||||||
|
|
||||||
|
$password_secret = "basic-auth-password"
|
||||||
|
docker secret inspect $password_secret 2>&1 | out-null
|
||||||
|
if($?)
|
||||||
|
{
|
||||||
|
Write-Host "$password_secret secret exists"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pass = Read-Host 'Password?' -AsSecureString
|
||||||
|
[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($pass)) | docker secret create $password_secret -
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Deploying stack"
|
||||||
|
docker stack deploy func --compose-file ./docker-compose.yml
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$user = Read-Host 'Admin User?'
|
Write-Host "Docker not in swarm mode, please initialise the cluster (`docker swarm init`) and retry"
|
||||||
$user | docker secret create $user_secret -
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$password_secret = "basic-auth-password"
|
|
||||||
docker secret inspect $password_secret 2>&1 | out-null
|
|
||||||
if($?)
|
|
||||||
{
|
|
||||||
Write-Host "$password_secret secret exists"
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$pass = Read-Host 'Password?' -AsSecureString
|
|
||||||
[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($pass)) | docker secret create $password_secret -
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Deploying stack"
|
|
||||||
docker stack deploy func --compose-file ./docker-compose.yml
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user