commit
64f52c312a
14 changed files with 329 additions and 46 deletions
@ -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/** |
||||
@ -0,0 +1,13 @@ |
||||
{ |
||||
"version": 1, |
||||
"isRoot": true, |
||||
"tools": { |
||||
"dotnet-ef": { |
||||
"version": "9.0.8", |
||||
"commands": [ |
||||
"dotnet-ef" |
||||
], |
||||
"rollForward": false |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,52 @@ |
||||
# ===== build 阶段 ===== |
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build |
||||
WORKDIR /src |
||||
|
||||
# 只拷贝 .csproj 做还原,最大化缓存命中 |
||||
COPY ["AlarmService/AlarmService.API/AlarmService.API.csproj", "AlarmService/AlarmService.API/"] |
||||
COPY ["Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj", "Common.SharedService/Common.Shared.Application/"] |
||||
COPY ["WeiCloud.Core/WeiCloud.Core.csproj", "WeiCloud.Core/"] |
||||
COPY ["WeiCloud.Utils/WeiCloud.Utils.csproj", "WeiCloud.Utils/"] |
||||
COPY ["AlarmService/Alarm.Application/Alarm.Application.csproj", "AlarmService/Alarm.Application/"] |
||||
COPY ["AlarmService/Alarm.DomainService/Alarm.DomainService.csproj", "AlarmService/Alarm.DomainService/"] |
||||
COPY ["Common.SharedService/Common.Shared.DomainService/Common.Shared.DomainService.csproj", "Common.SharedService/Common.Shared.DomainService/"] |
||||
|
||||
RUN dotnet restore "AlarmService/AlarmService.API/AlarmService.API.csproj" |
||||
|
||||
# 再拷贝全部源码并发布(一次 publish 即可) |
||||
COPY . . |
||||
RUN dotnet publish "AlarmService/AlarmService.API/AlarmService.API.csproj" \ |
||||
-c Release -o /app \ |
||||
/p:PublishReadyToRun=true \ |
||||
/p:UseAppHost=false |
||||
|
||||
# ===== runtime 阶段 ===== |
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final |
||||
WORKDIR /app |
||||
|
||||
# 健康检查工具 |
||||
RUN apt-get update && apt-get install -y --no-install-recommends curl \ |
||||
&& rm -rf /var/lib/apt/lists/* |
||||
|
||||
# 创建非 root 账户(存在则跳过,避免重复构建报错) |
||||
RUN set -eux; \ |
||||
if ! getent group app >/dev/null; then groupadd -g 64198 app; fi; \ |
||||
if ! id -u appuser >/dev/null 2>&1; then useradd -r -u 64198 -g app appuser; fi |
||||
|
||||
# 拷贝发布产物并赋权 |
||||
COPY --from=build /app ./ |
||||
RUN chown -R appuser:app /app |
||||
|
||||
# 对外只走 8080,TLS 在 Nginx 统一终止 |
||||
ENV ASPNETCORE_URLS=http://+:8080 \ |
||||
ASPNETCORE_ENVIRONMENT=Production |
||||
EXPOSE 8080 |
||||
|
||||
# 健康检查:你的服务需提供 /healthz |
||||
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \ |
||||
CMD curl -fsS http://localhost:8080/healthz || exit 1 |
||||
|
||||
# 以非 root 运行 |
||||
USER appuser |
||||
|
||||
ENTRYPOINT ["dotnet", "AlarmService.API.dll"] |
||||
@ -0,0 +1,52 @@ |
||||
# ===== build 阶段 ===== |
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build |
||||
WORKDIR /src |
||||
|
||||
# 只拷贝 .csproj 做还原,最大化缓存命中 |
||||
COPY ["AlarmService/AlarmService.API/AlarmService.API.csproj", "AlarmService/AlarmService.API/"] |
||||
COPY ["Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj", "Common.SharedService/Common.Shared.Application/"] |
||||
COPY ["WeiCloud.Core/WeiCloud.Core.csproj", "WeiCloud.Core/"] |
||||
COPY ["WeiCloud.Utils/WeiCloud.Utils.csproj", "WeiCloud.Utils/"] |
||||
COPY ["AlarmService/Alarm.Application/Alarm.Application.csproj", "AlarmService/Alarm.Application/"] |
||||
COPY ["AlarmService/Alarm.DomainService/Alarm.DomainService.csproj", "AlarmService/Alarm.DomainService/"] |
||||
COPY ["Common.SharedService/Common.Shared.DomainService/Common.Shared.DomainService.csproj", "Common.SharedService/Common.Shared.DomainService/"] |
||||
|
||||
RUN dotnet restore "AlarmService/AlarmService.API/AlarmService.API.csproj" |
||||
|
||||
# 再拷贝全部源码并发布(一次 publish 即可) |
||||
COPY . . |
||||
RUN dotnet publish "AlarmService/AlarmService.API/AlarmService.API.csproj" \ |
||||
-c Release -o /app \ |
||||
/p:PublishReadyToRun=true \ |
||||
/p:UseAppHost=false |
||||
|
||||
# ===== runtime 阶段 ===== |
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final |
||||
WORKDIR /app |
||||
|
||||
# 健康检查工具 |
||||
RUN apt-get update && apt-get install -y --no-install-recommends curl \ |
||||
&& rm -rf /var/lib/apt/lists/* |
||||
|
||||
# 创建非 root 账户(存在则跳过,避免重复构建报错) |
||||
RUN set -eux; \ |
||||
if ! getent group app >/dev/null; then groupadd -g 64198 app; fi; \ |
||||
if ! id -u appuser >/dev/null 2>&1; then useradd -r -u 64198 -g app appuser; fi |
||||
|
||||
# 拷贝发布产物并赋权 |
||||
COPY --from=build /app ./ |
||||
RUN chown -R appuser:app /app |
||||
|
||||
# 对外只走 8080,TLS 在 Nginx 统一终止 |
||||
ENV ASPNETCORE_URLS=http://+:8080 \ |
||||
ASPNETCORE_ENVIRONMENT=Production |
||||
EXPOSE 8080 |
||||
|
||||
# 健康检查:你的服务需提供 /healthz |
||||
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \ |
||||
CMD curl -fsS http://localhost:8080/healthz || exit 1 |
||||
|
||||
# 以非 root 运行 |
||||
USER appuser |
||||
|
||||
ENTRYPOINT ["dotnet", "AlarmService.API.dll"] |
||||
@ -0,0 +1,52 @@ |
||||
# ===== build 阶段 ===== |
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build |
||||
WORKDIR /src |
||||
|
||||
# 仅拷贝 csproj 提升缓存命中 |
||||
COPY ["VideoService/Video.API/Video.API.csproj", "VideoService/Video.API/"] |
||||
COPY ["Common.SharedService/Common.Shared.Application/Common.Shared.Application.csproj", "Common.SharedService/Common.Shared.Application/"] |
||||
COPY ["WeiCloud.Core/WeiCloud.Core.csproj", "WeiCloud.Core/"] |
||||
COPY ["WeiCloud.Utils/WeiCloud.Utils.csproj", "WeiCloud.Utils/"] |
||||
COPY ["VideoService/Video.Application/Video.Application.csproj", "VideoService/Video.Application/"] |
||||
COPY ["VideoService/Video.DomainService/Video.DomainService.csproj", "VideoService/Video.DomainService/"] |
||||
COPY ["Common.SharedService/Common.Shared.DomainService/Common.Shared.DomainService.csproj", "Common.SharedService/Common.Shared.DomainService/"] |
||||
|
||||
RUN dotnet restore "VideoService/Video.API/Video.API.csproj" |
||||
|
||||
# 再拷贝全部源码并发布 |
||||
COPY . . |
||||
RUN dotnet publish "VideoService/Video.API/Video.API.csproj" \ |
||||
-c Release -o /app \ |
||||
/p:PublishReadyToRun=true \ |
||||
/p:UseAppHost=false |
||||
|
||||
# ===== runtime 阶段 ===== |
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final |
||||
WORKDIR /app |
||||
|
||||
# 健康检查用 curl |
||||
RUN apt-get update && apt-get install -y --no-install-recommends curl \ |
||||
&& rm -rf /var/lib/apt/lists/* |
||||
|
||||
# 创建非 root 账户(存在则跳过) |
||||
RUN set -eux; \ |
||||
if ! getent group app >/dev/null; then groupadd -g 64198 app; fi; \ |
||||
if ! id -u appuser >/dev/null 2>&1; then useradd -r -u 64198 -g app appuser; fi |
||||
|
||||
# 拷贝发布产物并赋权 |
||||
COPY --from=build /app ./ |
||||
RUN chown -R appuser:app /app |
||||
|
||||
# 对外只走 8080,TLS 在 Nginx 统一终止 |
||||
ENV ASPNETCORE_URLS=http://+:8080 \ |
||||
ASPNETCORE_ENVIRONMENT=Production |
||||
EXPOSE 8080 |
||||
|
||||
# 健康检查:需要你的服务实现 /healthz |
||||
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \ |
||||
CMD curl -fsS http://localhost:8080/healthz || exit 1 |
||||
|
||||
# 以非 root 运行 |
||||
USER appuser |
||||
|
||||
ENTRYPOINT ["dotnet", "Video.API.dll"] |
||||
Loading…
Reference in new issue