-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
51 lines (38 loc) · 1.63 KB
/
Dockerfile
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
# Use the official .NET SDK image as the build stage
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app
# Expose the desired port
ENV ASPNETCORE_ENVIRONMENT=Development
EXPOSE 5000
# Build configuration variable. Debug as default
ENV BUILD_CONFIGURATION=Debug
# Copy data
COPY ["DocumentService.API/DocumentService.API.csproj", "DocumentService.API/"]
COPY ["DocumentService/DocumentService.csproj", "DocumentService/"]
# Restore the project dependencies
RUN dotnet restore "./DocumentService.API/./DocumentService.API.csproj"
RUN dotnet restore "./DocumentService/./DocumentService.csproj"
# Copy the rest of the data
COPY . .
WORKDIR "/app/DocumentService.API"
# Build the project and store artifacts in /out folder
RUN dotnet publish "./DocumentService.API.csproj" -c BUILD_CONFIGURATION -o /app/out
# Use the official ASP.NET runtime image as the base image
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
# Copy the published artifacts from the build stage
COPY --from=build /app/out .
# Install only necessary dependencies for wkhtmltopdf, Node.js and npm
RUN apt-get update \
&& apt-get install -y --fix-missing wkhtmltopdf \
&& apt-get install -y --fix-missing nodejs \
&& apt-get install -y --no-install-recommends npm \
&& rm -rf /var/lib/apt/lists/*
# Install wkhtmltopdf and allow execute access
RUN chmod 755 /usr/bin/wkhtmltopdf
# Install ejs globally without unnecessary dependencies
RUN npm install -g --only=prod ejs
# Set the environment variable for the application URL
ENV DOTNET_URLS=http://localhost:5000
# Set the entry point for the container
ENTRYPOINT ["dotnet", "DocumentService.API.dll"]