Skip to content

Commit

Permalink
Merge pull request #398 from swagger-api/fix-aspnet
Browse files Browse the repository at this point in the history
fix aspnetcore version in dockerfile
  • Loading branch information
frantuma committed Jun 24, 2019
2 parents db6e57f + ced8c3b commit 4b73f49
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ public void processOpts() {
apiTemplateFiles.put("controller.mustache", ".cs");
supportingFiles.add(new SupportingFile("Program.mustache", packageFolder, "Program.cs"));
supportingFiles.add(new SupportingFile("Project.csproj.mustache", packageFolder, this.packageName + ".csproj"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", packageFolder, "Dockerfile"));
} else{
apiTemplateFiles.put("2.1/controller.mustache", ".cs");
supportingFiles.add(new SupportingFile("2.1/Program.mustache", packageFolder, "Program.cs"));
supportingFiles.add(new SupportingFile("2.1/Project.csproj.mustache", packageFolder, this.packageName + ".csproj"));
supportingFiles.add(new SupportingFile("2.1/Dockerfile.mustache", packageFolder, "Dockerfile"));
}

if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
Expand All @@ -149,7 +151,6 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("build.bat.mustache", "", "build.bat"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("Solution.mustache", "", this.packageName + ".sln"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", packageFolder, "Dockerfile"));
supportingFiles.add(new SupportingFile("gitignore", packageFolder, ".gitignore"));
supportingFiles.add(new SupportingFile("appsettings.json", packageFolder, "appsettings.json"));

Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/handlebars/aspnetcore/2.1/Dockerfile.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM mcr.microsoft.com/dotnet/core/sdk:{{aspNetCoreVersion}} AS build-env
WORKDIR /app

ENV DOTNET_CLI_TELEMETRY_OPTOUT 1

# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:{{aspNetCoreVersion}}
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "{{packageName}}.dll"]
4 changes: 2 additions & 2 deletions src/main/resources/handlebars/aspnetcore/Dockerfile.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM microsoft/aspnetcore-build:2.0 AS build-env
FROM microsoft/aspnetcore-build:{{aspNetCoreVersion}} AS build-env
WORKDIR /app

ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
Expand All @@ -12,7 +12,7 @@ COPY . ./
RUN dotnet publish -c Release -o out

# build runtime image
FROM microsoft/aspnetcore:2.0
FROM microsoft/aspnetcore:{{aspNetCoreVersion}}
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "{{packageName}}.dll"]

0 comments on commit 4b73f49

Please sign in to comment.