-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.backend
More file actions
45 lines (34 loc) · 1.4 KB
/
Dockerfile.backend
File metadata and controls
45 lines (34 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Stage 1: Build
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /app
# Copy csproj and restore dependencies
COPY PortLogistics.csproj ./
RUN dotnet restore PortLogistics.csproj
# Copy everything else and build
COPY . ./
RUN dotnet publish PortLogistics.csproj -c Release -o out
# Stage 2: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
WORKDIR /app
# Install curl for healthchecks
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Install SWI-Prolog runtime (non-interactive package)
RUN apt-get update && apt-get install -y swi-prolog-nox && rm -rf /var/lib/apt/lists/* || true
# Copy published app from build stage
COPY --from=build /app/out .
# Create directory for SQLite database
RUN mkdir -p /app/data
# Set environment variables
ENV ASPNETCORE_ENVIRONMENT=Production
# Listen on both HTTP (5000) and HTTPS (5001)
ENV ASPNETCORE_URLS="http://+:5000;https://+:5001"
# Kestrel certificate can be provided at runtime via these env vars (set in docker-compose):
# ASPNETCORE_Kestrel__Certificates__Default__Path (e.g. /https/aspnetapp.pfx)
# ASPNETCORE_Kestrel__Certificates__Default__Password
# Expose ports for HTTP and HTTPS
EXPOSE 5000 5001
# Health check (use HTTP port)
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD curl --fail http://localhost:5000/api/health || exit 1
# Run the application
ENTRYPOINT ["dotnet", "PortLogistics.dll"]