DeutschLernen/GermanApp/Dockerfile
Lasse Rune Hansen eb6659e9fe fix(infra): correct HEALTHCHECK CMD syntax with bash /dev/tcp
- CMD-SHELL not supported in HEALTHCHECK
- Use CMD bash -c with /dev/tcp for port check
- No external dependencies needed

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-06-05 12:53:00 +02:00

55 lines
1.6 KiB
Docker

# GermanApp Backend Dockerfile
# .NET 9.0 Web API Application
# Multi-stage build for production optimization
# Build context: GermanApp directory
# ============================================
# Build Stage
# ============================================
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
# Copy project file and restore dependencies for Linux-x64
COPY ["GermanApp.csproj", "."]
RUN dotnet restore "GermanApp.csproj" --runtime linux-x64
# Copy everything else and build
COPY . .
WORKDIR "/src"
RUN dotnet build "GermanApp.csproj" -c Release -o /app/build --runtime linux-x64
# Publish the application
RUN dotnet publish "GermanApp.csproj" -c Release -o /app/publish \
--no-restore \
--runtime linux-x64 \
-p:PublishSingleFile=false \
-p:PublishTrimmed=false
# ============================================
# Publish Stage
# ============================================
FROM build AS publish
# ============================================
# Runtime Stage
# ============================================
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
WORKDIR /app
# Copy published app from publish stage
COPY --from=publish /app/publish .
# Set environment variables
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV ASPNETCORE_URLS=http://+:8080
ENV ASPNETCORE_ENVIRONMENT=Production
# Expose port
EXPOSE 8080
# Health check - use bash /dev/tcp to check port (no curl needed)
HEALTHCHECK --interval=30s --timeout=3s --start-period=15s --retries=3 \
CMD bash -c "echo > /dev/tcp/localhost/8080 || exit 1"
# Entry point
ENTRYPOINT ["dotnet", "GermanApp.dll"]