Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
build:
runs-on: ubuntu-latest
environment: PrTest
env:
AspNetCert: ${{ secrets.AspNetCert }}

steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@
<PropertyGroup>
<WarningsAsErrors>CS8618</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<!-- See/Attribution: https://blog.magnusmontin.net/2018/11/05/platform-conditional-compilation-in-net-core/ -->
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
</Project>
20 changes: 14 additions & 6 deletions PasswordKeeper.Server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
EXPOSE 8000
EXPOSE 8001

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["PasswordKeeper.Server/PasswordKeeper.Server.csproj", "PasswordKeeper.Server/"]
COPY ["PasswordKeeper.BusinessLogic/PasswordKeeper.BusinessLogic.csproj", "PasswordKeeper.BusinessLogic/"]
COPY ["PasswordKeeper.DataAccess/PasswordKeeper.DataAccess.csproj", "PasswordKeeper.DataAccess/"]
COPY ["PasswordKeeper.Classes/PasswordKeeper.Classes.csproj", "PasswordKeeper.Classes/"]
COPY ["PasswordKeeper.DAO/PasswordKeeper.DAO.csproj", "PasswordKeeper.DAO/"]
COPY ["PasswordKeeper.DataAccess/PasswordKeeper.DataAccess.csproj", "PasswordKeeper.DataAccess/"]
COPY ["PasswordKeeper.DatabaseMigrations/PasswordKeeper.DatabaseMigrations.csproj", "PasswordKeeper.DatabaseMigrations/"]
COPY ["PasswordKeeper.DTO/PasswordKeeper.DTO.csproj", "PasswordKeeper.DTO/"]
COPY ["PasswordKeeper.Interfaces/PasswordKeeper.Interfaces.csproj", "PasswordKeeper.Interfaces/"]
COPY ["DbMigrate/DbMigrate.csproj", "DbMigrate/"]
RUN dotnet restore "PasswordKeeper.Server/PasswordKeeper.Server.csproj"§
COPY ["PasswordKeeper.Server/PasswordKeeper.Server.csproj", "PasswordKeeper.Server/"]
COPY ["./Directory.Build.props", "/"]
COPY ["./Directory.Build.targets", "/"]

RUN dotnet restore "PasswordKeeper.Server/PasswordKeeper.Server.csproj"
COPY . .
WORKDIR "/src/PasswordKeeper.Server"
RUN dotnet build "PasswordKeeper.Server.csproj" -c $BUILD_CONFIGURATION -o /app/build
Expand All @@ -26,4 +30,8 @@ RUN dotnet publish "PasswordKeeper.Server.csproj" -c $BUILD_CONFIGURATION -o /ap
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

RUN mkdir -p /app/Certificates
COPY "PasswordKeeper.Server/CertGen/AspNetApp.pfx" /app/Certificates

ENTRYPOINT ["dotnet", "PasswordKeeper.Server.dll"]
15 changes: 13 additions & 2 deletions PasswordKeeper.Server/PasswordKeeper.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
Expand All @@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="14.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.3" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.3"/>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.3" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.7.0" />
<PackageReference Include="MySql.Data" Version="9.2.0" />
<PackageReference Include="MySql.EntityFrameworkCore" Version="9.0.0" />
Expand All @@ -27,4 +27,15 @@
<ProjectReference Include="..\PasswordKeeper.DataAccess\PasswordKeeper.DataAccess.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="CertGen\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Condition="'$(IsWindows)'=='true'" Command="dotnet dev-certs https -ep CertGen\AspNetApp.pfx -p %AspNetCert%" />
<Exec Condition="'$(IsWindows)'=='false'" Command="dotnet dev-certs https -ep CertGen/AspNetApp.pfx -p $AspNetCert" />
</Target>

</Project>
1 change: 1 addition & 0 deletions PasswordKeeperServer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
LICENSE = LICENSE
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PasswordKeeper.DatabaseMigrations", "PasswordKeeper.DatabaseMigrations\PasswordKeeper.DatabaseMigrations.csproj", "{2047B929-7D63-440A-A1C1-BABAE744194B}"
Expand Down