diff --git a/admin/Dockerfile b/admin/Dockerfile new file mode 100644 index 0000000..0f8dead --- /dev/null +++ b/admin/Dockerfile @@ -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;"] diff --git a/admin/nginx.conf b/admin/nginx.conf new file mode 100644 index 0000000..f4b1b41 --- /dev/null +++ b/admin/nginx.conf @@ -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; + } +} diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..50735c1 --- /dev/null +++ b/server/Dockerfile @@ -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"]