Files
pos-system/services/_template_dot_net/Dockerfile
Ho Ngoc Hai 0b0241143a feat(docs): Enhance Vietnamese documentation with updated diagrams and troubleshooting sections
- Improved Mermaid diagrams for better visual clarity and consistency across guides.
- Added detailed troubleshooting sections to assist users in diagnosing common issues effectively.
- Updated formatting and structure to align with the English version, ensuring consistency.
- Included quick tips and common issues sections to facilitate user navigation.
2026-01-10 21:21:41 +07:00

65 lines
2.0 KiB
Docker

# Build stage / Giai đoạn build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# EN: Copy project files
# VI: Sao chép các file project
COPY ["src/YourServiceName.Api/YourServiceName.Api.csproj", "src/YourServiceName.Api/"]
COPY ["src/YourServiceName.Domain/YourServiceName.Domain.csproj", "src/YourServiceName.Domain/"]
COPY ["src/YourServiceName.Infrastructure/YourServiceName.Infrastructure.csproj", "src/YourServiceName.Infrastructure/"]
# EN: Restore dependencies
# VI: Khôi phục dependencies
RUN dotnet restore "src/YourServiceName.Api/YourServiceName.Api.csproj"
# EN: Copy all source code
# VI: Sao chép toàn bộ source code
COPY . .
# EN: Build the application
# VI: Build ứng dụng
WORKDIR "/src/src/YourServiceName.Api"
RUN dotnet build "YourServiceName.Api.csproj" -c Release -o /app/build
# Publish stage / Giai đoạn publish
FROM build AS publish
RUN dotnet publish "YourServiceName.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 addgroup --gid 1001 --system dotnetuser && \
adduser --uid 1001 --system --ingroup dotnetuser 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
# EN: Health check
# VI: Kiểm tra health
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --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", "YourServiceName.Api.dll"]