From c97df32b0df4a87f19c493dc37843feca38351fc Mon Sep 17 00:00:00 2001 From: Vinrobot Date: Fri, 5 Jul 2019 20:29:22 +0200 Subject: [PATCH] Build licenseGen in Docker This way we don't have to install dotnet sdk on the host --- src/licenseGen/Dockerfile | 15 +++++++++++++-- src/licenseGen/build.sh | 10 ++-------- src/licenseGen/run.sh | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/licenseGen/Dockerfile b/src/licenseGen/Dockerfile index 441f497..b6612e5 100644 --- a/src/licenseGen/Dockerfile +++ b/src/licenseGen/Dockerfile @@ -1,5 +1,16 @@ +FROM mcr.microsoft.com/dotnet/core/sdk:2.1 as build + +WORKDIR /licenseGen + +COPY . /licenseGen + +RUN dotnet add package Newtonsoft.Json --version 12.0.1 \ + && dotnet restore \ + && dotnet publish + + FROM bitbetter/api -COPY bin/Debug/netcoreapp2.0/publish/* /app/ +COPY --from=build /licenseGen/bin/Debug/netcoreapp2.0/publish/* /app/ -ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--cert", "/cert.pfx" ] \ No newline at end of file +ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--cert", "/cert.pfx" ] diff --git a/src/licenseGen/build.sh b/src/licenseGen/build.sh index 06b146f..0837edb 100755 --- a/src/licenseGen/build.sh +++ b/src/licenseGen/build.sh @@ -1,11 +1,5 @@ #!/bin/bash -script_dir=`cd $(dirname $0); pwd` - -cd "$script_dir" - -dotnet restore -dotnet publish - -docker build . -t bitbetter/licensegen # --squash +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +docker build -t bitbetter/licensegen "$DIR" # --squash diff --git a/src/licenseGen/run.sh b/src/licenseGen/run.sh index 3b4c930..bdcdca6 100755 --- a/src/licenseGen/run.sh +++ b/src/licenseGen/run.sh @@ -14,5 +14,5 @@ elif [ "$#" -ge "2" ]; then shift fi -docker run -it -v "$cert_path:/cert.pfx" bitbetter/licensegen "$@" +docker run -it --rm -v "$cert_path:/cert.pfx" bitbetter/licensegen "$@"