Files
OTSSignsOrchestrator/OTSSignsOrchestrator/Dockerfile

54 lines
1.6 KiB
Docker

# ==============================================================================
# OTSSignsOrchestrator - Multi-stage Dockerfile
# ==============================================================================
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
# Copy csproj and restore
COPY OTSSignsOrchestrator.csproj ./
RUN dotnet restore
# Copy everything else and publish
COPY . .
RUN dotnet publish -c Release -o /app/publish --no-restore
# ==============================================================================
# Stage 2: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
WORKDIR /app
# Install Docker CLI for stack deploy/rm/ls commands
RUN apt-get update && \
apt-get install -y --no-install-recommends \
docker.io \
git \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Create non-root user (will need docker group for socket access)
RUN groupadd -r xiboapp && \
useradd -r -g xiboapp -d /app -s /sbin/nologin xiboapp
# Copy published app
COPY --from=build /app/publish .
# Create directories for logs, data, and template cache
RUN mkdir -p /app/logs /app/data /app/template-cache && \
chown -R xiboapp:xiboapp /app
# Expose port (Kestrel default in .NET 9)
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:8080/healthz || exit 1
# Switch to non-root user
USER xiboapp
# Environment defaults
ENV ASPNETCORE_URLS=http://+:8080
ENV ASPNETCORE_ENVIRONMENT=Production
ENTRYPOINT ["dotnet", "OTSSignsOrchestrator.dll"]