41 lines
1009 B
Docker
41 lines
1009 B
Docker
# Use the official .NET 9.0 runtime image as the base image
|
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
|
WORKDIR /app
|
|
EXPOSE 5010
|
|
|
|
# Use the official .NET 9.0 SDK image for building
|
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
|
WORKDIR /src
|
|
|
|
# Copy the project file and restore dependencies
|
|
COPY ["AIAss.csproj", "./"]
|
|
RUN dotnet restore "AIAss.csproj"
|
|
|
|
# Copy the rest of the source code
|
|
COPY . .
|
|
WORKDIR "/src/."
|
|
|
|
# Build the application
|
|
RUN dotnet build "AIAss.csproj" -c Release -o /app/build
|
|
|
|
# Publish the application
|
|
FROM build AS publish
|
|
RUN dotnet publish "AIAss.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
|
|
# Final stage/image
|
|
FROM base AS final
|
|
WORKDIR /app
|
|
COPY --from=publish /app/publish .
|
|
|
|
# Set environment variables
|
|
ENV ASPNETCORE_URLS=http://+:5010;
|
|
ENV ASPNETCORE_ENVIRONMENT=Production
|
|
|
|
# Create a non-root user for security
|
|
RUN adduser --disabled-password --gecos "" appuser && chown -R appuser /app
|
|
USER appuser
|
|
|
|
# Set the entry point
|
|
ENTRYPOINT ["dotnet", "AIAss.dll"]
|
|
|