简体   繁体   English

带有 Google 云错误 CS1003:语法错误的 asp.net core 5 的自定义运行时 dockerfile,

[英]Custom runtime dockerfile for asp.net core 5 with Google cloud error CS1003: Syntax error,

I am trying to publish the Asp.net core 5 application to the google cloud using the visual studio plugin.我正在尝试使用 Visual Studio 插件将 Asp.net core 5 应用程序发布到谷歌云。

app.yaml应用程序.yaml

runtime: custom
env: flex

manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

Docker file Docker 文件

FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
# 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/aspnet:5.0
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 8080
ENV ASPNETCORE_URLS=http://*:8080
ENTRYPOINT ["dotnet", "Falcon-Identity.dll"]

When I publish using publish to google cloud from context menu I am getting the below exception当我从上下文菜单使用发布到谷歌云发布时,我收到以下异常

C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(1,23): error CS1003: Syntax error, '(' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(1,23): error CS1001: Identifier expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(1,30): error CS1001: Identifier expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(1,30): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(1,31): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(1,37): error CS1001: Identifier expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(1,37): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(1,41): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(2,9): error CS1001: Identifier expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(2,9): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(2,10): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(3,3): error CS1024: Preprocessor directive expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(4,6): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(4,8): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(4,16): error CS1001: Identifier expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(4,16): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(4,17): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(5,12): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(6,3): error CS1024: Preprocessor directive expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(7,6): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(7,10): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(8,12): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(8,20): error CS1001: Identifier expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(8,20): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(8,21): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(8,31): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(8,32): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(8,34): error CS1001: Identifier expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(8,34): error CS1003: Syntax error, ',' expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(9,3): error CS1024: Preprocessor directive expected [C:\Projects\falcon-identity\Falcon-Identity\Falcon-Identity.csproj]
C:\Projects\falcon-identity\Falcon-Identity\Dockerfile(10,9): error CS1003: Syntax error, ',' e

I'm able to deploy an ASP.NET 5.0 app successfully to App Engine flex (and then Cloud Run).我能够将 ASP.NET 5.0 应用程序成功部署到 App Engine flex(然后是 Cloud Run)。

I'm less familiar with .NET and so I used a simpler configuration but, I think you should be able to apply what I've done to your case too.我对 .NET 不太熟悉,所以我使用了一个更简单的配置,但是,我认为您也应该能够将我所做的应用于您的案例。

Dockerfile : Dockerfile

FROM mcr.microsoft.com/dotnet/sdk:5.0

WORKDIR /app

COPY ./app/*.csproj .
RUN dotnet restore

COPY ./app/ .

EXPOSE 8080
ENTRYPOINT ["dotnet", "run","--urls=http://+:8080"]

And:和:

BILLING=...
PROJECT=...
REGION=...

gcloud projects create ${PROJECT}

gcloud beta billing projects link ${PROJECT} \
--billing-account=${BILLING}

gcloud app create \
--region=${REGION} \
--project=${PROJECT}

mkdir ${PWD}/app

# Create 'empty' ASP.NET (web)app
docker run \
--interactive --tty --rm \
--volume=${PWD}/app:/app \
mcr.microsoft.com/dotnet/sdk:5.0 \
dotnet new webapp -o app

# Change generated files to `$whoami`
# Or `$(id -u):$(id -g)`
chown -R $(whoami):$(whoami) ./app

docker build \
--tag=68103677:v1 \
--file=./Dockerfile \
.

docker run \
--interactive --tty --rm \
--publish=8080:8080 \
68103677:latest

# Prove it
curl localhost:8080

# Deploy
gcloud app deploy ./app.yaml \
--project=${PROJECT} \
--quiet

# Test
gcloud app browse \
--project=${PROJECT}

Just for giggles, we can deploy the container image created by the App Engine deployment and deploy the container to Cloud Run:只是傻笑,我们可以部署由 App Engine 部署创建的容器映像并将容器部署到 Cloud Run:

gcloud services enable run.googleapis.com \
--project=${PROJECT}

# Grab the App Engine image
IMAGE=$(\
  gcloud container images list \
  --repository=us.gcr.io/${PROJECT}/appengine \
  --limit=1 \
  --format="value(name)")

# Deploy it to Cloud Run
# For testing, deploy without authentication
# We need to replicate `ENTRYPOINT` with `--command` and `--args`
NAME="aspnet"
gcloud run deploy ${NAME} \
--image=${IMAGE} \
--command="dotnet" \
--args="run","--urls=http://+:8080" \
--max-instances=1 \
--region=${REGION} \
--project=${PROJECT} \
--allow-unauthenticated

# Grab its endpoint
ENDPOINT=$(\
  gcloud run services describe ${NAME} \
  --project=${PROJECT} \
  --platform=managed \
  --region=${REGION} \
  --format="value(status.address.url)") && \
echo ${ENDPOINT}

# Browse or...
curl ${ENDPOINT}

# Delete it when done
gcloud run services delete ${NAME} \
--region=${REGION} \
--project=${PROJECT} \
--quiet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM