From 1738b8654c53e7bd91dd5f19935b991889be0e25 Mon Sep 17 00:00:00 2001 From: Peace Date: Wed, 12 Jun 2024 17:40:41 +0900 Subject: [PATCH] add docker file --- .dockerignore | 30 +++++++++ ConnectFour/.config/dotnet-tools.json | 13 ++++ ConnectFour/ConnectFour.csproj | 6 ++ ConnectFour/Dockerfile | 25 ++++++++ ConnectFour/Properties/launchSettings.json | 75 +++++++++++++--------- 5 files changed, 117 insertions(+), 32 deletions(-) create mode 100644 .dockerignore create mode 100644 ConnectFour/.config/dotnet-tools.json create mode 100644 ConnectFour/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/ConnectFour/.config/dotnet-tools.json b/ConnectFour/.config/dotnet-tools.json new file mode 100644 index 0000000..4f257cf --- /dev/null +++ b/ConnectFour/.config/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "8.0.6", + "commands": [ + "dotnet-ef" + ], + "rollForward": false + } + } +} \ No newline at end of file diff --git a/ConnectFour/ConnectFour.csproj b/ConnectFour/ConnectFour.csproj index 1b28a01..e062a3a 100644 --- a/ConnectFour/ConnectFour.csproj +++ b/ConnectFour/ConnectFour.csproj @@ -4,6 +4,12 @@ net8.0 enable enable + 2bdd990f-d305-48a6-b08d-0d9bce3c158f + Linux + + + + diff --git a/ConnectFour/Dockerfile b/ConnectFour/Dockerfile new file mode 100644 index 0000000..d9d6cf0 --- /dev/null +++ b/ConnectFour/Dockerfile @@ -0,0 +1,25 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER app +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["ConnectFour/ConnectFour.csproj", "ConnectFour/"] +RUN dotnet restore "./ConnectFour/ConnectFour.csproj" +COPY . . +WORKDIR "/src/ConnectFour" +RUN dotnet build "./ConnectFour.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./ConnectFour.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "ConnectFour.dll"] \ No newline at end of file diff --git a/ConnectFour/Properties/launchSettings.json b/ConnectFour/Properties/launchSettings.json index 90c7fca..c4ec4e7 100644 --- a/ConnectFour/Properties/launchSettings.json +++ b/ConnectFour/Properties/launchSettings.json @@ -1,38 +1,49 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:41840", - "sslPort": 44379 - } - }, - "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "http://localhost:5144", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } + "profiles": { + "http": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" }, - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "https://localhost:7208;http://localhost:5144", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5144" + }, + "https": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7208;http://localhost:5144" + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" } + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": true + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:41840", + "sslPort": 44379 } } +} \ No newline at end of file