「マイクロソフト系技術情報 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。
以下の手順で検証・評価した。
ASP.NET Core MVCアプリケーションの作成
> docker version > docker run hello-world
※ 後々、「from microsoft/aspnetcore」でググって、
コンパイル済みのASP.NET Coreアプリケーションを実行するための
公式のDocker Imageをダウンロードしていたことが解った。
https://hub.docker.com/r/microsoft/aspnetcore/
より実践的な開発環境を構成する。
ホスト側のDBで動作させようとしたが、ハマりどころが多かったのでメモ。
Expressの場合は、SQL Server 構成マネージャーの設定も必要にある。
以下は、ASP.NET Core MVCのOpen棟梁テンプレートの変更点のスクショです。
手順1と同じ。
Dockerfileファイル(Dockerfile)の作成
FROM microsoft/aspnetcore:latest #WORKDIR /app #COPY publish . #ENV ASPNETCORE_URLS http://+:5000 #EXPOSE 5000 #ENTRYPOINT ["dotnet", "xxxx.dll"]
FROM nginx:latest COPY default.conf /etc/nginx/conf.d/default.conf
nginxフォルダにdefault.confを作成する。
server { listen 80; server_name example.com *.example.com; location / { proxy_pass http://localhost:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $http_host; proxy_cache_bypass $http_upgrade; } }
server{ listen 80; server_name xxx.xxx.xxx.xxx; location / { proxy_pass http://sampleapp:5001; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_buffering off; proxy_set_header Host xxx.xxx.xxx.xxx; proxy_set_header X-RealIP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
Docker Composeファイル(docker-compose.yml)の作成
version: '3' services: proxy: image: proxy build: context: ./nginx dockerfile: Dockerfile ports: - "8888:80" links: - sampleapp sampleapp: image: sampleapp build: context: ./SampleApp dockerfile: Dockerfile
version: '3' services: proxy: image: nginx:latest ports: - "8888:80" links: - "sampleapp" volumes: - ./nginx/default.conf:/etc/nginx/conf.d/default.conf - ./sampleapp/publish/wwwroot:/usr/share/nginx/html/wwwroot sampleapp: image: sampleapp build: context: ./SampleApp dockerfile: Dockerfile
手順3に3つ目の、PostgreSQLのコンテナを追加してみる。
Docker側でライブラリのデバッグをする場合、ライブラリのPDBが、
「完全(full)」ではなくて、「ポータブル(portable)」である必要がある。
Tags: :.NET開発, :.NET Core, :Hyper-V, :仮想化