-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Stage 1: Build the Blazor Client Application | ||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build | ||
WORKDIR /src | ||
|
||
# Copy the project files and restore dependencies | ||
COPY ["src/CleanAspire.ClientApp/CleanAspire.ClientApp.csproj", "src/CleanAspire.ClientApp/"] | ||
RUN dotnet restore "src/CleanAspire.ClientApp/CleanAspire.ClientApp.csproj" | ||
|
||
# Copy the entire source code and build the application in Release mode | ||
COPY . . | ||
WORKDIR /src/src/CleanAspire.ClientApp | ||
RUN dotnet publish -c Release -o /app/publish | ||
|
||
# Stage 2: Serve the Blazor Client Application using Nginx | ||
FROM nginx:alpine AS final | ||
WORKDIR /usr/share/nginx/html | ||
|
||
# Install OpenSSL to create a self-signed certificate | ||
RUN apk add --no-cache openssl && \ | ||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt -subj "/CN=localhost" | ||
|
||
# Clean the default nginx content | ||
RUN rm -rf ./* | ||
|
||
# Copy the build output from the previous stage | ||
COPY --from=build /app/publish/wwwroot . | ||
|
||
# Copy the generated self-signed certificate and configure Nginx for HTTPS | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Expose port 80 for HTTP traffic and 443 for HTTPS traffic | ||
EXPOSE 80 | ||
EXPOSE 443 | ||
|
||
# Start Nginx | ||
CMD ["nginx", "-g", "daemon off;"] |