Added docker support

master
Tudor Stanciu 2022-12-27 18:40:07 +02:00
parent 1a509c8012
commit 3b76200d6b
7 changed files with 84 additions and 3 deletions

25
.dockerignore Normal file
View File

@ -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

1
.gitignore vendored
View File

@ -363,3 +363,4 @@ MigrationBackup/
FodyWeavers.xsd
*.development.json
buildx.sh

9
Directory.Build.props Normal file
View File

@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<Version>1.0.0</Version>
<Authors>Tudor Stanciu</Authors>
<Company>STA</Company>
<PackageTags>GoDaddyDDNS</PackageTags>
<Copyright>STA GoDaddyDDNS</Copyright>
</PropertyGroup>
</Project>

View File

@ -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

View File

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

View File

@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>dotnet-GoDaddyDDNS-FB6B86D1-EE02-4695-9CFC-3552E66F6B4F</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<ItemGroup>

View File

@ -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;