dotnet new webapi -o ./WebApi1
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# copy everything else and build app
COPY . ./
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
WORKDIR /app
COPY --from=build /app/out .
ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
ENTRYPOINT ["dotnet", "WebApi1.dll"]
# Please refer https://aka.ms/HTTPSinContainer on how to setup an https developer certificate for your ASP .NET Core service.
version: '3.4'
services:
webapi1:
image: webapi1
container_name: webapi-container
build:
context: .
dockerfile: ./Dockerfile
ports:
- 5001:5000 #add to
docker-compose up
Creating webapi1_webapi1_1 ... done
Attaching to webapi1_webapi1_1
webapi1_1 | info: Microsoft.Hosting.Lifetime[0]
webapi1_1 | Now listening on: http://[::]:5000
webapi1_1 | info: Microsoft.Hosting.Lifetime[0]
webapi1_1 | Application started. Press Ctrl+C to shut down.
webapi1_1 | info: Microsoft.Hosting.Lifetime[0]
webapi1_1 | Hosting environment: Production
webapi1_1 | info: Microsoft.Hosting.Lifetime[0]
webapi1_1 | Content root path: /app
Recommended Posts