littleshop/LittleShop/Dockerfile
2025-08-27 18:02:39 +01:00

38 lines
936 B
Docker

# Build stage
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
# Copy project file and restore dependencies
COPY LittleShop.csproj .
RUN dotnet restore
# Copy all source files and build
COPY . .
RUN dotnet publish -c Release -o /app/publish
# Runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:9.0
WORKDIR /app
# Install curl for health checks
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Copy published app
COPY --from=build /app/publish .
# Create directories for uploads and database
RUN mkdir -p /app/data /app/wwwroot/uploads/products /app/logs
# Set environment variables
ENV ASPNETCORE_URLS=http://+:5000
ENV ASPNETCORE_ENVIRONMENT=Production
# Expose port
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5000/api/test || exit 1
# Run the application
ENTRYPOINT ["dotnet", "LittleShop.dll"]