- C# TokyoコミュニティSlack https://csharp-tokyo.connpass.com/
- Igniteでのセッション BRK3176: Windows container and the Azure Kubernetes Service https://myignite.techcommunity.microsoft.com/sessions/82952?source=sessions
- AKSでWindows Server Node groupセットアップ https://docs.microsoft.com/ja-jp/azure/aks/windows-container-cli?WT.mc_id=OSS-MVP-5000211 https://kubernetes.io/docs/setup/production-environment/windows/intro-windows-in-kubernetes/
- Windowsコンテナの作成 https://docs.microsoft.com/ja-jp/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile?WT.mc_id=OSS-MVP-5000211&context=/azure/aks/context/aks-context
- WindowsコンテナのDockerfileサンプル集 https://github.com/MicrosoftDocs/Virtualization-Documentation/tree/master/windows-container-samples
- 発表資料 https://1drv.ms/p/s!AqwIyH6ypmaykZAKQGoHTONI9lqGDw?e=modpef
Last active
January 21, 2020 16:40
-
-
Save tanaka-takayoshi/74749701c8f77c56e7362d153c84a330 to your computer and use it in GitHub Desktop.
WindowsコンテナのDockerfileサンプルなど (Ignite Tour Tokyo THR3001/Osaka THR30079 セッション参考資料)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ASP.NET Web(.NET Framework)のDockerfileサンプル。slnファイルと同じ階層に配置。 | |
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build | |
WORKDIR /app | |
COPY *.sln . | |
# プロジェクトファイルを格納しているフォルダごとをコピー | |
COPY HelloWCOW/ ./HelloWCOW/ | |
# ソリューションファイルを指定してMSBuildによりローカルファイルシステムに発行(Publish)する | |
RUN msbuild HelloWCOW.sln /p:Configuration=Release /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=\output | |
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 | |
WORKDIR /inetpub/wwwroot | |
COPY --from=build /output/. ./ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build-argで環境変数を設定する場合の参照方法 | |
#> docker build --build-arg NRLicenseKey=<key> --buid-arg NRAppName=MyApp . | |
# RUN命令でpowershellの引数から参照しているので、PowerShell形式 | |
RUN powershell.exe -Command Start-Process -Wait -FilePath msiexec -ArgumentList /i, "C:\NewRelicDotNetAgent_x64.msi", /qn, NR_LICENSE_KEY=$env:NRLicenseKey | |
# ENVコマンドなどではDockerfile形式 | |
ENV NEW_RELIC_APP_NAME=${NRAppName} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COPY *.sln . | |
COPY HelloWCOW/ ./HelloWCOW/ | |
# 空白を含むパスの場合 | |
COPY ["Hello Library", "./Hello Library/"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ¥の代わりに`を複数行のエスケープに指定できる | |
# escape=` | |
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build | |
#中略 | |
RUN msbuild HelloWCOW.sln ` | |
/p:Configuration=Release ` | |
/p:DeployOnBuild=True ` | |
/p:DeployDefaultTarget=WebPublish ` | |
/p:WebPublishMethod=FileSystem ` | |
/p:DeleteExistingFiles=True ` | |
/p:publishUrl=output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# IIS ARRをインストールするRUNコマンド | |
# https://github.com/MicrosoftDocs/Virtualization-Documentation/blob/master/windows-container-samples/iis-arr/Dockerfile より引用 | |
# https://github.com/MicrosoftDocs/Virtualization-Documentation/blob/master/windows-container-samples/iis-arr/Dockerfile より引 | |
RUN @powershell wget http://download.microsoft.com/download/5/7/0/57065640-4665-4980-a2f1-4d5940b577b0/webfarm_v1.1_amd64_en_us.msi -OutFile webfarm_v1.1_amd64_en_us.msi | |
RUN msiexec /i "webfarm_v1.1_amd64_en_us.msi" /q /log foo.log | |
RUN @powershell wget http://download.microsoft.com/download/6/7/D/67D80164-7DD0-48AF-86E3-DE7A182D6815/rewrite_amd64_en-US.msi -OutFile rewrite_amd64_en-US.msi | |
RUN msiexec /i "rewrite_amd64_en-US.msi" /q /log foo.log | |
RUN @powershell wget http://download.microsoft.com/download/6/3/D/63D67918-483E-4507-939D-7F8C077F889E/requestRouter_x64.msi -OutFile requestRouter_x64.msi | |
RUN msiexec /i "requestRouter_x64.msi" /q /log foo.log | |
# この後ARRそのものの設定が必要 | |
# IISをプログラムから操作する方法についてはこちらも参考 | |
# https://www.buildinsider.net/web/iis8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 3rd Partyソフトウェア(New Relic .NET Framework Agent)をインストールするサンプル | |
# 最新情報はこちらを参考 https://docs.newrelic.com/docs/agents/net-agent/installation/install-docker-container#windows | |
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 | |
ARG NRAppName="HelloWCOW" | |
ARG NRLicenseKey | |
# 一連の操作を1つのRUN命令にまとめる | |
RUN powershell.exe -Command ` | |
# インストーラーダウンロード | |
Invoke-WebRequest https://download.newrelic.com/dot_net_agent/latest_release/NewRelicDotNetAgent_x64.msi -OutFile C:\NewRelicDotNetAgent_x64.msi ; ` | |
# インストーラー実行 | |
Start-Process -Wait -FilePath msiexec -ArgumentList /i, "C:\NewRelicDotNetAgent_x64.msi", /qn, NR_LICENSE_KEY=$env:NRLicenseKey ; ` | |
# インストーラー削除 | |
Remove-Item C:\NewRelicDotNetAgent_x64.msi -Force | |
ENV NEW_RELIC_APP_NAME=${NRAppName} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WCF用のDockerfile | |
# escape=` | |
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build | |
WORKDIR /app | |
COPY *.sln . | |
COPY HelloWcfService/ ./HelloWcfService/ | |
RUN nuget restore | |
RUN msbuild HelloWcfService.sln /p:Configuration=Release /p:DeployOnBuild=True ` | |
/p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem ` | |
/p:DeleteExistingFiles=True /p:publishUrl=output | |
FROM mcr.microsoft.com/dotnet/framework/wcf:4.8 AS runtime | |
WORKDIR /inetpub/wwwroot | |
COPY --from=build /app/HelloWcfService/output/. ./ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: hellowcf | |
labels: | |
app: hellowcf | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
name: hellowcf | |
labels: | |
app: hellowcf | |
spec: | |
nodeSelector: | |
beta.kubernetes.io/os: windows | |
tolerations: | |
- key: "ostype" | |
operator: "Equal" | |
value: "win" | |
effect: "NoSchedule" | |
containers: | |
- name: hellowcf | |
image: <acr_name>.azurecr.io/hellowcf:latest | |
ports: | |
- containerPort: 80 | |
selector: | |
matchLabels: | |
app: hellowcf | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: hellowcfsvc | |
spec: | |
type: ClusterIP | |
externalName: hellowcfsvc | |
ports: | |
- protocol: TCP | |
port: 80 | |
selector: | |
app: hellowcf | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: wcfwebportal | |
labels: | |
app: wcfwebportal | |
spec: | |
replicas: 1 | |
template: | |
metadata: | |
name: wcfwebportal | |
labels: | |
app: wcfwebportal | |
spec: | |
containers: | |
- name: wcfwebportal | |
image: <acr_name>.azurecr.io/wcfwebportal:latest | |
env: | |
- name: "SERVICE_URL" | |
value: "hellowcfsvc" | |
ports: | |
- containerPort: 80 | |
selector: | |
matchLabels: | |
app: wcfwebportal | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: wcfwebportalsvc | |
spec: | |
type: LoadBalancer | |
externalName: wcfwebportalsvc | |
ports: | |
- protocol: TCP | |
port: 80 | |
selector: | |
app: wcfwebportal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment