From c0fca8e7ac6c7db09ce22811624268344beb4c0c Mon Sep 17 00:00:00 2001 From: Goncalo Oliveira Date: Wed, 10 Feb 2021 10:33:42 +0100 Subject: [PATCH] fixed detached run --- Dockerfile | 2 +- src/DockerWrapper.cs | 18 ++++++++++-------- src/faas-run.csproj | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 60914ce..824766f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # stage 1 -FROM mcr.microsoft.com/dotnet/sdk:5.0 as builder +FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim as builder # suppress data collection ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 diff --git a/src/DockerWrapper.cs b/src/DockerWrapper.cs index bf7f7c9..2163bed 100644 --- a/src/DockerWrapper.cs +++ b/src/DockerWrapper.cs @@ -6,7 +6,7 @@ namespace OpenFaaS { internal class DockerWrapper { - private readonly string dockerImage = "goncalo-oliveira/faas-run"; + private readonly string dockerImage = "docker.pkg.github.com/goncalo-oliveira/faas-run/faas-run"; private string GetImageTag() { @@ -25,8 +25,9 @@ private string GetImageTag() public void RunDetached( Options options ) { // to run detached we need the full path, not the relative - var assemblyPath = System.IO.Path.GetFullPath( options.Assembly ); - var assemblyFile = System.IO.Path.GetFileName( assemblyPath ); + var assemblyFullPath = System.IO.Path.GetFullPath( options.Assembly ); + var assemblyPath = System.IO.Path.GetDirectoryName( assemblyFullPath ); + var assemblyFile = System.IO.Path.GetFileName( assemblyFullPath ); var configPath = !string.IsNullOrEmpty( options.Config ) && System.IO.File.Exists( options.Config ) ? System.IO.Path.GetFullPath( options.Config ) @@ -44,9 +45,9 @@ public void RunDetached( Options options ) "run", "-d", $"-p {options.Port}:80", - $"-v {assemblyPath}:/home/app/{assemblyFile}:ro", + $"-v {assemblyPath}:/home/app/:ro", !string.IsNullOrEmpty( configPath ) - ? $"-v {configPath}:/home/app/config.json:ro" + ? $"-v {configPath}:/home/config.json:ro" : string.Empty, $"{dockerImage}:{imageTag}", "faas-run", @@ -54,7 +55,7 @@ public void RunDetached( Options options ) "-p 80", options.NoAuth ? "--no-auth" : string.Empty, !string.IsNullOrEmpty( configPath ) - ? $"/home/app/config.json" + ? "--config /home/config.json" : string.Empty, } .Where( x => !string.IsNullOrEmpty( x ) ) @@ -62,8 +63,9 @@ public void RunDetached( Options options ) var dockerArgs = string.Join( (char)0x20, args ); - // Console.WriteLine( $"docker pull {dockerImage}:{imageTag}" ); - // Console.WriteLine( "docker " + dockerArgs ); + // Console.WriteLine( $"docker pull {dockerImage}:{imageTag}" ); + // Console.WriteLine( "docker " + dockerArgs ); + // return; // pull faas-run image var pullExitCode = Exec( "docker", $"pull {dockerImage}:{imageTag}" ); diff --git a/src/faas-run.csproj b/src/faas-run.csproj index 3a87415..3a096ed 100644 --- a/src/faas-run.csproj +++ b/src/faas-run.csproj @@ -3,7 +3,7 @@ Exe net5.0 - 1.6 + 1.6.1 Goncalo Oliveira FaaS runner for ASPNET functions https://github.com/goncalo-oliveira/faas-run