Skip to content

Commit

Permalink
add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
neozhu committed May 15, 2024
1 parent c6301a8 commit 83ba4c8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 28 deletions.
60 changes: 60 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
# apt update and install fonts
RUN echo "deb http://deb.debian.org/debian/ bookworm main contrib" > /etc/apt/sources.list && \
echo "deb-src http://deb.debian.org/debian/ bookworm main contrib" >> /etc/apt/sources.list && \
echo "deb http://security.debian.org/ bookworm-security main contrib" >> /etc/apt/sources.list && \
echo "deb-src http://security.debian.org/ bookworm-security main contrib" >> /etc/apt/sources.list
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
RUN apt-get install -y fonts-noto-cjk fontconfig openssl



# Generate a self-signed certificate
RUN mkdir -p /app/https && \
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout /app/https/private.key -out /app/https/certificate.crt \
-subj "/C=US/ST=State/L=City/O=Organization/CN=localhost" && \
openssl pkcs12 -export -out /app/https/aspnetapp.pfx \
-inkey /app/https/private.key -in /app/https/certificate.crt \
-password pass:CREDENTIAL_PLACEHOLDER


# Setup environment variables for the application to find the certificate
ENV ASPNETCORE_URLS=http://+:80;https://+:443
ENV ASPNETCORE_Kestrel__Certificates__Default__Password="CREDENTIAL_PLACEHOLDER"
ENV ASPNETCORE_Kestrel__Certificates__Default__Path="/app/https/aspnetapp.pfx"

WORKDIR /app
EXPOSE 80
EXPOSE 443



FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

COPY ["src/Blazor.Server.UI/Blazor.Server.UI.csproj", "src/Blazor.Server.UI/"]
COPY ["src/Application/Application.csproj", "src/Application/"]
COPY ["src/Domain/Domain.csproj", "src/Domain/"]
COPY ["src/Infrastructure/Infrastructure.csproj", "src/Infrastructure/"]
RUN dotnet restore "src/Blazor.Server.UI/Blazor.Server.UI.csproj"
COPY . .

WORKDIR "/src/src/Blazor.Server.UI"
RUN dotnet add package SkiaSharp.NativeAssets.Linux.NoDependencies
RUN dotnet add package HarfBuzzSharp.NativeAssets.Linux
RUN dotnet build "Blazor.Server.UI.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Blazor.Server.UI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "Blazor.Server.UI.dll"]
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
image: visitormanagement/web
build:
context: .
dockerfile: src/Blazor.Server.UI/Dockerfile
dockerfile: ./Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- UseInMemoryDatabase=false
Expand Down
27 changes: 0 additions & 27 deletions src/Blazor.Server.UI/Dockerfile

This file was deleted.

0 comments on commit 83ba4c8

Please sign in to comment.