-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (42 loc) · 1.62 KB
/
Dockerfile
File metadata and controls
55 lines (42 loc) · 1.62 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
46
47
48
49
50
51
52
53
54
55
# Use the official ASP.NET Core runtime as the base image
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
# Use the SDK image to build the application
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
# Copy project files
COPY ["DocumentTranslation.Web/DocumentTranslation.Web.csproj", "DocumentTranslation.Web/"]
COPY ["DocumentTranslationService/DocumentTranslationService.csproj", "DocumentTranslationService/"]
# Restore dependencies
RUN dotnet restore "DocumentTranslation.Web/DocumentTranslation.Web.csproj"
# Copy all source files
COPY . .
# Build the application
WORKDIR "/src/DocumentTranslation.Web"
RUN dotnet build "DocumentTranslation.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build
# Publish the application
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "DocumentTranslation.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# Create the final runtime image
FROM base AS final
WORKDIR /app
# Install additional dependencies if needed
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy the published application
COPY --from=publish /app/publish .
# Create a non-root user
RUN adduser --disabled-password --gecos '' appuser && chown -R appuser /app
USER appuser
# Set environment variables
ENV ASPNETCORE_URLS=http://+:8080
ENV ASPNETCORE_ENVIRONMENT=Production
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
ENTRYPOINT ["dotnet", "DocumentTranslation.Web.dll"]