openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] [aspnetcore] aspnetCoreVersion 6.0 not compatible with 3.0 mustache templates

Open cocakohler opened this issue 3 years ago • 0 comments

Description

When using aspnetCoreVersion=6.0 parameter the generated Dockerfile is corrupt.

openapi-generator version

openapi-generator-cli-6.2.0.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.2.0/openapi-generator-cli-6.2.0.jar

OpenAPI declaration file content or url

https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml

Command line used for generation

java -jar openapi-generator-cli-6.2.0.jar generate -g aspnetcore --additional-properties aspnetCoreVersion=6.0 --additional-properties classModifier=abstract --additional-properties operationModifier=abstract --additional-properties packageName=Pet --additional-properties packageTitle=Pet.Api -i https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml --skip-validate-spec

Steps to reproduce

java -jar openapi-generator-cli-6.2.0.jar generate -g aspnetcore --additional-properties aspnetCoreVersion=6.0 --additional-properties classModifier=abstract --additional-properties operationModifier=abstract --additional-properties packageName=Pet --additional-properties packageTitle=Pet.Api -i https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml --skip-validate-spec

This will generate a the following Dockerfile:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

# Container we use for final publish
FROM mcr.microsoft.com/dotnet/core/aspnet:6.0-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

# Build container
FROM mcr.microsoft.com/dotnet/core/sdk:6.0-buster AS build

# Copy the code into the container
WORKDIR /src
COPY ["src/Pet/Pet.csproj", "Pet/"]

# NuGet restore
RUN dotnet restore "Pet/Pet.csproj"
COPY ["src/Pet/", "Pet/"]

# Build the API
WORKDIR "Pet"
RUN dotnet build "Pet.csproj" -c Release -o /app/build

# Publish it
FROM build AS publish
RUN dotnet publish "Pet.csproj" -c Release -o /app/publish

# Make the final image for publishing
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Pet.dll"]

The referenced base images (mcr.microsoft.com/dotnet/core/aspnet:6.0-buster-slim + mcr.microsoft.com/dotnet/core/sdk:6.0-buster) in the Dockerfile do not exist!

$ cd src/Pet $ docker build -t petstore:1.0.17 .

[+] Building 0.6s (4/4) FINISHED
 => [internal] load build definition from Dockerfile                                                                                   0.1s
 => => transferring dockerfile: 873B                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                      0.1s
 => => transferring context: 2B                                                                                                        0.0s
 => ERROR [internal] load metadata for mcr.microsoft.com/dotnet/core/sdk:6.0-buster                                                    0.4s
 => CANCELED [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:6.0-buster-slim                                         0.4s
------
 > [internal] load metadata for mcr.microsoft.com/dotnet/core/sdk:6.0-buster:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: mcr.microsoft.com/dotnet/core/sdk:6.0-buster: not found
Related issues/PRs
Suggest a fix/enhancement

see here

This has to be fixed. "6.0" must not use 3.0 templates

cocakohler avatar Oct 08 '22 07:10 cocakohler