Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Fix docker build for admin project (#113)

Leendert de Borstd87800f37015
diff --git a/init.sh b/init.sh
index 05fda0a2d..c416c3a9a 100755
--- a/init.sh
+++ b/init.sh
@@ -127,7 +127,7 @@ generate_admin_password() {
ADMIN_PASSWORD=$(openssl rand -base64 12)
printf "\n"
- printf "${BLUE} Building Docker image for password generation...${NC}\n"
+ printf "${BLUE} Building Docker image for password generation...${NC}\n "
if [ "$VERBOSE" = true ]; then
docker build -t initcli -f src/Utilities/InitializationCLI/Dockerfile .
else
diff --git a/src/AliasVault.Admin/AliasVault.Admin.csproj b/src/AliasVault.Admin/AliasVault.Admin.csproj
index c47dfb842..ca23b9be1 100644
--- a/src/AliasVault.Admin/AliasVault.Admin.csproj
+++ b/src/AliasVault.Admin/AliasVault.Admin.csproj
@@ -40,9 +40,7 @@
</ItemGroup>
<ItemGroup>
- <AdditionalFiles Include="..\stylecop.json">
- <Link>stylecop.json</Link>
- </AdditionalFiles>
+ <AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>
diff --git a/src/AliasVault.Admin/Dockerfile b/src/AliasVault.Admin/Dockerfile
index fbd4a5b44..ef526a804 100644
--- a/src/AliasVault.Admin/Dockerfile
+++ b/src/AliasVault.Admin/Dockerfile
@@ -1,33 +1,32 @@
-# Use the official .NET 8 SDK image to build the app
-FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
-WORKDIR /src
-
-# Copy the solution file to the /src directory in the container
-COPY aliasvault.sln ./
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
+WORKDIR /app
+EXPOSE 8082
-# Copy the project file to the /src/AliasVault directory in the container
-COPY src/AliasVault.Admin/AliasVault.Admin.csproj ./AliasVault.Admin/
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
+ARG BUILD_CONFIGURATION=Release
-# Restore dependencies for the AliasVault project
-RUN dotnet restore "./AliasVault.Admin/AliasVault.Admin.csproj" --verbosity detailed
+WORKDIR /src
-# Copy the rest of the application code to the /src directory in the container
-COPY src/. ./
+# Copy the project files and restore dependencies
+COPY ["src/AliasVault.Admin/AliasVault.Admin.csproj", "src/AliasVault.Admin/"]
+COPY ["src/Databases/AliasServerDb/AliasServerDb.csproj", "src/Databases/AliasServerDb/"]
+RUN dotnet restore "src/AliasVault.Admin/AliasVault.Admin.csproj"
-# Publish the application to the /app/publish directory in the container
-WORKDIR /src/AliasVault.Admin
-RUN dotnet publish -c Release -o /app --verbosity detailed
+# Copy the rest of the application code
+COPY . .
-# Use the official ASP.NET Core runtime image to run the app
-FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
-WORKDIR /app/AliasVault.Admin
+# Build the WebApi project
+WORKDIR "/src/src/AliasVault.Admin"
+RUN dotnet build "AliasVault.Admin.csproj" -c "$BUILD_CONFIGURATION" -o /app/build
-# Copy the published output from the build stage to the runtime stage
-COPY --from=build /app ./
+# Publish the application to the /app/publish directory in the container
+FROM build AS publish
+ARG BUILD_CONFIGURATION=Release
+RUN dotnet publish "AliasVault.Admin.csproj" -c "$BUILD_CONFIGURATION" -o /app/publish /p:UseAppHost=false
-# Expose the port the app runs on
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
EXPOSE 8082
ENV ASPNETCORE_URLS=http://+:8082
-
ENTRYPOINT ["dotnet", "AliasVault.Admin.dll"]
-