Supports running on docker

This commit is contained in:
ShaoHua
2024-06-28 00:10:01 +08:00
parent 08e7bf004b
commit 6d66b6532b
4 changed files with 15 additions and 38 deletions

View File

@@ -1,25 +0,0 @@
**/.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

View File

@@ -1,21 +1,22 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
#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/sdk:8.0 AS base
USER app
WORKDIR /app
#EXPOSE 8080
#EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Hua.DDNS/Hua.DDNS.csproj", "Hua.DDNS/"]
RUN dotnet restore "Hua.DDNS/Hua.DDNS.csproj"
RUN dotnet restore "./Hua.DDNS/Hua.DDNS.csproj"
COPY . .
WORKDIR "/src/Hua.DDNS"
RUN dotnet build "Hua.DDNS.csproj" -c Release -o /app/build
RUN dotnet build "./Hua.DDNS.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
RUN dotnet publish "Hua.DDNS.csproj" -c Release -o /app/publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Hua.DDNS.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=true
FROM base AS final
WORKDIR /app

View File

@@ -4,9 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PublishSingleFile>true</PublishSingleFile>
<UserSecretsId>dotnet-Hua.DDNS-C4DADDFF-6D5B-4BD5-AB11-02F07B517CAC</UserSecretsId>
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
<SelfContained>true</SelfContained>
</PropertyGroup>

3
buildImages.ps1 Normal file
View File

@@ -0,0 +1,3 @@
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
cd ./Hua.DDNS
docker build -t hua.ddns:latest -f Dockerfile ..