Skip to content

Commit

Permalink
Switch to Nginx server in Dockerfile and add config
Browse files Browse the repository at this point in the history
The Dockerfile has been updated to use Nginx server instead of the previously used dotnet/aspnet and the default listening port has been changed to 80. The new nginx.conf configuration file has been added and copied over to the right location in the Dockerfile setup. This change allows our application to use Nginx to better manage web traffic.
  • Loading branch information
EpicOfficer committed Mar 30, 2024
1 parent f80d867 commit c47f837
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Blink3.Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM nginx:alpine AS base
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
Expand All @@ -18,6 +15,6 @@ ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Blink3.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Blink3.Web.dll"]
WORKDIR /usr/share/nginx/html
COPY --from=publish /app/publish/wwwroot .
COPY Blink3.Web/nginx.conf /etc/nginx/nginx.conf
10 changes: 10 additions & 0 deletions Blink3.Web/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
http {
include mime.types;
server {
listen 80;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html =404;
}
}
}

0 comments on commit c47f837

Please sign in to comment.