I'm using Google Cloud to host my .Net Core 2.2 application, but I want to update it to 3.0. My app.yaml looks like this
service: api
runtime: aspnetcore
env: flex
I know that I can specify the .Net Core version in runtime section. But Google Cloud Container Registry doesn't have .Net Core 3.0. I've checked it here.
Should I make a custom container then? I have zero experience with docker. Maybe there is a ready-to-go container somehow.
I didn't found any roadmap for update .Net Core images in public Container Registry.
@update
Solution
It's working!
My dockerfile looks like this:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY MyProject.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish /app/MyProject.csproj -c Release -o ./out --nologo
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out/ .
EXPOSE 8080
ENV ASPNETCORE_URLS=http://*:8080
ENV ASPNETCORE_ENVIRONMENT=production
ENV TAPTAKE_SEED=false
ENTRYPOINT ["dotnet", "MyProject.dll"]
And my new app.yaml
service: api
runtime: custom
env: flex
env_variables:
ASPNETCORE_ENVIRONMENT: "production"
# Note this manual scaling is only for development
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 4
disk_size_gb: 10
And my cloudbuild.yaml:
steps:
# Build
- name: 'gcr.io/cloud-builders/dotnet'
args: [ 'publish', '-c', 'Release' ]
dir: 'MyProject'
# Migrations
- name: 'gcr.io/cloud-builders/dotnet'
args: [ 'ef', 'database', 'update' , '--configuration', 'Production']
dir: 'MyProject'
env:
- 'ASPNETCORE_ENVIRONMENT=production'
# DEPLOY
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app','deploy','MyProject/bin/Release/netcoreapp3.1/publish/app.yaml', '--verbosity=debug']
timeout: '1200s'