Some checks failed
Build & Deploy to K8s / build-and-deploy (push) Has been cancelled
Touch all Dockerfiles to force Gitea Actions to detect changes and build all 25 backend services + 1 frontend via Kaniko → Harbor. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
69 lines
2.3 KiB
Docker
69 lines
2.3 KiB
Docker
# Build stage / Giai đoạn build
|
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
|
WORKDIR /src
|
|
|
|
# EN: Copy project files for layer caching
|
|
# VI: Sao chép các file project để tận dụng layer caching
|
|
COPY ["src/WalletService.API/WalletService.API.csproj", "src/WalletService.API/"]
|
|
COPY ["src/WalletService.Domain/WalletService.Domain.csproj", "src/WalletService.Domain/"]
|
|
COPY ["src/WalletService.Infrastructure/WalletService.Infrastructure.csproj", "src/WalletService.Infrastructure/"]
|
|
COPY ["Directory.Build.props", "./"]
|
|
|
|
# EN: Restore dependencies for all projects
|
|
# VI: Khôi phục dependencies cho tất cả projects
|
|
RUN dotnet restore "src/WalletService.API/WalletService.API.csproj"
|
|
|
|
# EN: Copy all source code
|
|
# VI: Sao chép toàn bộ source code
|
|
COPY src/ ./src/
|
|
|
|
# EN: Build the application
|
|
# VI: Build ứng dụng
|
|
WORKDIR /src/src/WalletService.API
|
|
RUN dotnet build "WalletService.API.csproj" -c Release -o /app/build
|
|
|
|
# Publish stage / Giai đoạn publish
|
|
FROM build AS publish
|
|
RUN dotnet publish "WalletService.API.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
|
|
# Runtime stage / Giai đoạn runtime
|
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
|
|
WORKDIR /app
|
|
|
|
# EN: Create non-root user for security
|
|
# VI: Tạo user non-root cho bảo mật
|
|
RUN apt-get update && apt-get install -y curl --no-install-recommends && rm -rf /var/lib/apt/lists/* && \
|
|
groupadd -g 1001 dotnetuser && \
|
|
useradd -u 1001 -g dotnetuser -s /bin/sh dotnetuser
|
|
|
|
# EN: Copy published application
|
|
# VI: Sao chép ứng dụng đã publish
|
|
COPY --from=publish /app/publish .
|
|
|
|
# EN: Change ownership to non-root user
|
|
# VI: Thay đổi quyền sở hữu sang user non-root
|
|
RUN chown -R dotnetuser:dotnetuser /app
|
|
|
|
# EN: Switch to non-root user
|
|
# VI: Chuyển sang user non-root
|
|
USER dotnetuser
|
|
|
|
# EN: Expose port
|
|
# VI: Mở cổng
|
|
EXPOSE 8080
|
|
|
|
# EN: Set environment variables
|
|
# VI: Thiết lập biến môi trường
|
|
ENV ASPNETCORE_URLS=http://+:8080
|
|
ENV ASPNETCORE_ENVIRONMENT=Production
|
|
|
|
# EN: Health check
|
|
# VI: Kiểm tra health
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
|
CMD curl -f http://localhost:8080/health/live || exit 1
|
|
|
|
# EN: Start the application
|
|
# VI: Khởi động ứng dụng
|
|
ENTRYPOINT ["dotnet", "WalletService.API.dll"]
|
|
# Build trigger 1775832654
|