From 3b76200d6b11fa42e0340a33b66065382c9ac237 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Tue, 27 Dec 2022 18:40:07 +0200 Subject: [PATCH] Added docker support --- .dockerignore | 25 +++++++++++ .gitignore | 3 +- Directory.Build.props | 9 ++++ GoDaddyDDNS.sln | 3 +- src/GoDaddyDDNS/Dockerfile | 43 +++++++++++++++++++ src/GoDaddyDDNS/GoDaddyDDNS.csproj | 2 + src/GoDaddyDDNS/Services/DynamicDNSService.cs | 2 +- 7 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 Directory.Build.props create mode 100644 src/GoDaddyDDNS/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3729ff0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1793a90..c81d3fc 100644 --- a/.gitignore +++ b/.gitignore @@ -362,4 +362,5 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd -*.development.json \ No newline at end of file +*.development.json +buildx.sh \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..55372a6 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,9 @@ + + + 1.0.0 + Tudor Stanciu + STA + GoDaddyDDNS + STA GoDaddyDDNS + + \ No newline at end of file diff --git a/GoDaddyDDNS.sln b/GoDaddyDDNS.sln index 8ac3cf2..013a333 100644 --- a/GoDaddyDDNS.sln +++ b/GoDaddyDDNS.sln @@ -5,12 +5,13 @@ VisualStudioVersion = 17.2.32526.322 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0935CA6B-5C67-4503-9700-849721AAA61E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoDaddyDDNS", "src\GoDaddyDDNS\GoDaddyDDNS.csproj", "{63210018-9CF9-48ED-A99B-BE6B29F2B080}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoDaddyDDNS", "src\GoDaddyDDNS\GoDaddyDDNS.csproj", "{63210018-9CF9-48ED-A99B-BE6B29F2B080}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution items", "{F0FD0A54-278C-4D7D-9F3A-6424DA2A0CD3}" ProjectSection(SolutionItems) = preProject .gitattributes = .gitattributes .gitignore = .gitignore + Directory.Build.props = Directory.Build.props README.md = README.md EndProjectSection EndProject diff --git a/src/GoDaddyDDNS/Dockerfile b/src/GoDaddyDDNS/Dockerfile new file mode 100644 index 0000000..2069697 --- /dev/null +++ b/src/GoDaddyDDNS/Dockerfile @@ -0,0 +1,43 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +WORKDIR /workspace +COPY Directory.Build.props . +COPY ["src/GoDaddyDDNS/GoDaddyDDNS.csproj", "src/GoDaddyDDNS/"] +RUN dotnet restore "src/GoDaddyDDNS/GoDaddyDDNS.csproj" +COPY . . +WORKDIR "/workspace/src/GoDaddyDDNS" +RUN dotnet build "GoDaddyDDNS.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "GoDaddyDDNS.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . + +ENV AUTHOR="Tudor Stanciu" +ENV TZ=Europe/Bucharest + +ARG APP_VERSION=0.0.0.0 +ENV APP_VERSION=${APP_VERSION} + +ARG LOGGING_LEVEL="Information" +ENV Logging__LogLevel__Default=${LOGGING_LEVEL} + +ARG DOMAIN="" +ENV Domain=${DOMAIN} + +ARG KEY="" +ENV Key=${KEY} + +ARG SECRET="" +ENV Secret=${SECRET} + +ARG EXECUTION_TIME +ENV ExecutionTimeInSeconds=${EXECUTION_TIME} + +ENTRYPOINT ["dotnet", "GoDaddyDDNS.dll"] \ No newline at end of file diff --git a/src/GoDaddyDDNS/GoDaddyDDNS.csproj b/src/GoDaddyDDNS/GoDaddyDDNS.csproj index 135589e..869757f 100644 --- a/src/GoDaddyDDNS/GoDaddyDDNS.csproj +++ b/src/GoDaddyDDNS/GoDaddyDDNS.csproj @@ -3,6 +3,8 @@ net5.0 dotnet-GoDaddyDDNS-FB6B86D1-EE02-4695-9CFC-3552E66F6B4F + Linux + ..\.. diff --git a/src/GoDaddyDDNS/Services/DynamicDNSService.cs b/src/GoDaddyDDNS/Services/DynamicDNSService.cs index dbb13fb..70ebaf1 100644 --- a/src/GoDaddyDDNS/Services/DynamicDNSService.cs +++ b/src/GoDaddyDDNS/Services/DynamicDNSService.cs @@ -38,7 +38,7 @@ namespace GoDaddyDDNS.Services var publicIP = await _publicIPTracker.Get(); if (PublicIP != publicIP) { - _logger.LogInformation($"[{DateTime.Now}]: Public IP has changed from '{PublicIP}' to '{publicIP}'"); + _logger.LogWarning($"[{DateTime.Now}]: Public IP has changed from '{PublicIP}' to '{publicIP}'"); var newRecords = DNSRecords.Select(record => { record.Data = publicIP;