Build an ASP.net Core Web API environment on Docker (VSCode) Part 1

procedure

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"]

VSCode_20201226-1.png

VSCode_20201226-2.pngVSCode_20201226-3.png

# 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

docker_20201226-1.png

VSCode_20201226-4.png

Recommended Posts

Build an ASP.net Core Web API environment on Docker (VSCode) Part 1
Build an ASP.NET Core Web API environment on Docker (VSCode) Part 2
Build an environment with Docker on AWS
Build an Ultra96v2 development environment on Docker 1
Build PlantUML environment with VSCode + Docker
Build Clang x VSCode on Docker (1)
Build Unity development environment on docker
Build Redmine code reading environment on Docker
Build an environment of "API development + API verification using Swagger UI" with Docker
Build a Laravel / Docker environment with VSCode devcontainer
Build Java x Spring x VSCode x Gradle on Docker (1)
Building OpenPose (Pytorch_Realtime_Multi-Person_Pose_Estimation) environment on Docker: training part
Build a Laravel environment on an AWS instance
[Ruby on Rails] Let's build an environment on mac
Build a development environment for Docker, java, vscode
[Rails] How to build an environment with Docker
[First team development ②] Build an environment with Docker
Build a Doker-based development environment on Windows 10 Home 2020 ver. Part 1 Until WSL2-based Docker build
Build an environment of Ruby2.7.x + Rails6.0.x + MySQL8.0.x with Docker
[Docker] Build an Apache container on EC2 using dockerfile
Build Rails (API) x MySQL x Nuxt.js environment with Docker
I tried to build an environment using Docker (beginner)
Use Java Web Start in an OpenJDK environment on Windows
I tried to build the environment of WSL2 + Docker + VSCode
WSL2 + VSCode + Docker development environment
Build docker environment with WSL
Build Go development environment with WSL2 + Docker Desktop + VSCode (Remote --Containers)
[App development 0.5] [Node.js express Docker] Build an environment for Node.js Express MongoDB using Docker
Build a Docker-based development environment on Windows 10 Home 2020 ver. Part 2 VS Code should make the Docker development environment comfortable
Build a Node.js environment with Docker
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Build a XAMPP environment on Ubuntu
Rails on Docker environment construction procedure
Build docker + laravel environment with laradock
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
How to build a Ruby on Rails environment using Docker (for Docker beginners)
Creating a java web application development environment with docker for mac part1
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Create a java web application development environment with docker for mac part2