feat: 添加 Docker 部署配置文件 (admin Dockerfile/nginx.conf, server Dockerfile)

This commit is contained in:
code@server 2026-03-09 18:37:09 +08:00
parent 4f4c95d3d4
commit 4213a94763
3 changed files with 61 additions and 0 deletions

12
admin/Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN rm -f package-lock.json && npm install
COPY . .
RUN npm run build
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

26
admin/nginx.conf Normal file
View File

@ -0,0 +1,26 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://huangye-parking-server:8080/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 20m;
}
location /upload/ {
proxy_pass http://huangye-parking-server:8080/upload/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 20m;
}
}

23
server/Dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM mcr.microsoft.com/dotnet/aspnet:10.0-preview AS base
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:10.0-preview AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/HuangyanParking.Api/HuangyanParking.Api.csproj", "src/HuangyanParking.Api/"]
COPY ["src/HuangyanParking.Infrastructure/HuangyanParking.Infrastructure.csproj", "src/HuangyanParking.Infrastructure/"]
COPY ["src/HuangyanParking.Domain/HuangyanParking.Domain.csproj", "src/HuangyanParking.Domain/"]
RUN dotnet restore "src/HuangyanParking.Api/HuangyanParking.Api.csproj"
COPY . .
WORKDIR "/src/src/HuangyanParking.Api"
RUN dotnet build "HuangyanParking.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "HuangyanParking.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HuangyanParking.Api.dll"]