Files
BimAI/BimAI.API/Dockerfile

48 lines
1.3 KiB
Docker
Raw Permalink Normal View History

2025-10-12 20:17:33 +02:00
# Stage 1: Build
2025-11-21 14:19:44 +01:00
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
2025-10-12 20:17:33 +02:00
WORKDIR /src
# Copy solution and all project files for restore
COPY BimAI.sln ./
COPY BimAI.API/BimAI.API.csproj BimAI.API/
COPY BimAI.Domain/BimAI.Domain.csproj BimAI.Domain/
COPY BimAI.Application/BimAI.Application.csproj BimAI.Application/
COPY BimAI.Infrastructure/BimAI.Infrastructure.csproj BimAI.Infrastructure/
# Restore dependencies
RUN dotnet restore BimAI.API/BimAI.API.csproj
# Copy all source code
COPY . .
# Build and publish
WORKDIR /src/BimAI.API
RUN dotnet publish -c Release -o /app/publish --no-restore
# Stage 2: Runtime
2025-11-21 14:19:44 +01:00
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
2025-10-12 20:17:33 +02:00
WORKDIR /app
2025-10-18 16:42:44 +02:00
# Install wget for health checks
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
2025-10-12 20:17:33 +02:00
# Set timezone
ENV TZ=Europe/Warsaw
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Copy published files
COPY --from=build /app/publish .
# Set environment variables
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://0.0.0.0:7142
# Expose port
EXPOSE 7142
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:7142/health || exit 1
# Run the application
ENTRYPOINT ["dotnet", "BimAI.API.dll"]