Skip to content

Commit

Permalink
Refactor Dockerfile for readability (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
lanedirt committed Jan 4, 2025
1 parent d08bec9 commit 14898c0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
7 changes: 5 additions & 2 deletions src/AliasVault.Admin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ ARG TARGETARCH
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/AliasVault.Admin/AliasVault.Admin.csproj", "src/AliasVault.Admin/"]
RUN dotnet restore "src/AliasVault.Admin/AliasVault.Admin.csproj" -a $TARGETARCH
RUN dotnet restore "src/AliasVault.Admin/AliasVault.Admin.csproj" -a "$TARGETARCH"
COPY . .

WORKDIR "/src/src/AliasVault.Admin"
RUN dotnet publish "AliasVault.Admin.csproj" -c "$BUILD_CONFIGURATION" -a $TARGETARCH -o /app/publish /p:UseAppHost=false
RUN dotnet publish "AliasVault.Admin.csproj" -c "$BUILD_CONFIGURATION" \
-a "$TARGETARCH" \
-o /app/publish \
/p:UseAppHost=false

FROM base AS final
WORKDIR /app
Expand Down
7 changes: 5 additions & 2 deletions src/AliasVault.Api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ WORKDIR /src

# Copy the project files and restore dependencies
COPY ["src/AliasVault.Api/AliasVault.Api.csproj", "src/AliasVault.Api/"]
RUN dotnet restore "src/AliasVault.Api/AliasVault.Api.csproj" -a $TARGETARCH
RUN dotnet restore "src/AliasVault.Api/AliasVault.Api.csproj" -a "$TARGETARCH"
COPY . .

# Build and publish
WORKDIR "/src/src/AliasVault.Api"
RUN dotnet publish "AliasVault.Api.csproj" -c "$BUILD_CONFIGURATION" -a $TARGETARCH -o /app/publish /p:UseAppHost=false
RUN dotnet publish "AliasVault.Api.csproj" -c "$BUILD_CONFIGURATION" \
-a "$TARGETARCH" \
-o /app/publish \
/p:UseAppHost=false

# Final stage
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
Expand Down
9 changes: 6 additions & 3 deletions src/AliasVault.Client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ RUN dotnet workload install wasm-tools

# Copy the project files and restore dependencies
COPY ["src/AliasVault.Client/AliasVault.Client.csproj", "src/AliasVault.Client/"]
RUN dotnet restore "src/AliasVault.Client/AliasVault.Client.csproj" -a $TARGETARCH
RUN dotnet restore "src/AliasVault.Client/AliasVault.Client.csproj" -a "$TARGETARCH"
COPY . .

# Build the Client project
WORKDIR "/src/src/AliasVault.Client"
RUN dotnet build "AliasVault.Client.csproj" -c "$BUILD_CONFIGURATION" -o /app/build -a $TARGETARCH
RUN dotnet build "AliasVault.Client.csproj" \
-c "$BUILD_CONFIGURATION" \
-o /app/build \
-a "$TARGETARCH"

# Publish the Client project
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
ARG TARGETARCH
RUN dotnet publish "AliasVault.Client.csproj" \
-c "$BUILD_CONFIGURATION" \
-a $TARGETARCH \
-a "$TARGETARCH" \
--no-restore \
-o /app/publish \
/p:UseAppHost=false \
Expand Down
7 changes: 5 additions & 2 deletions src/Services/AliasVault.SmtpService/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ WORKDIR /src

# Copy the project files and restore dependencies
COPY ["src/Services/AliasVault.SmtpService/AliasVault.SmtpService.csproj", "src/Services/AliasVault.SmtpService/"]
RUN dotnet restore "./src/Services/AliasVault.SmtpService/AliasVault.SmtpService.csproj" -a $TARGETARCH
RUN dotnet restore "./src/Services/AliasVault.SmtpService/AliasVault.SmtpService.csproj" -a "$TARGETARCH"
COPY . .

# Build and publish the application
WORKDIR "/src/src/Services/AliasVault.SmtpService"
RUN dotnet publish "./AliasVault.SmtpService.csproj" -c "$BUILD_CONFIGURATION" -a $TARGETARCH -o /app/publish /p:UseAppHost=false
RUN dotnet publish "./AliasVault.SmtpService.csproj" -c "$BUILD_CONFIGURATION" \
-a "$TARGETARCH" \
-o /app/publish \
/p:UseAppHost=false

FROM base AS final
WORKDIR /app
Expand Down
8 changes: 6 additions & 2 deletions src/Services/AliasVault.TaskRunner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ WORKDIR /src

# Copy the project files and restore dependencies
COPY ["src/Services/AliasVault.TaskRunner/AliasVault.TaskRunner.csproj", "src/Services/AliasVault.TaskRunner/"]
RUN dotnet restore "./src/Services/AliasVault.TaskRunner/AliasVault.TaskRunner.csproj" -a $TARGETARCH
RUN dotnet restore "./src/Services/AliasVault.TaskRunner/AliasVault.TaskRunner.csproj" -a "$TARGETARCH"
COPY . .

# Build and publish the application
WORKDIR "/src/src/Services/AliasVault.TaskRunner"
RUN dotnet publish "./AliasVault.TaskRunner.csproj" -c "$BUILD_CONFIGURATION" -a $TARGETARCH -o /app/publish /p:UseAppHost=false
RUN dotnet publish "./AliasVault.TaskRunner.csproj" \
-c "$BUILD_CONFIGURATION" \
-a "$TARGETARCH" \
-o /app/publish \
/p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/runtime:9.0 AS final
WORKDIR /app
Expand Down
7 changes: 5 additions & 2 deletions src/Utilities/AliasVault.InstallCli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ WORKDIR /src
# Copy csproj files and restore as distinct layers
COPY ["src/Utilities/AliasVault.InstallCli/AliasVault.InstallCli.csproj", "src/Utilities/AliasVault.InstallCli/"]
COPY ["src/Databases/AliasServerDb/AliasServerDb.csproj", "src/Databases/AliasServerDb/"]
RUN dotnet restore "src/Utilities/AliasVault.InstallCli/AliasVault.InstallCli.csproj" -a $TARGETARCH
RUN dotnet restore "src/Utilities/AliasVault.InstallCli/AliasVault.InstallCli.csproj" -a "$TARGETARCH"

# Copy the entire source code
COPY . .

# Build and publish in one step
RUN dotnet publish "src/Utilities/AliasVault.InstallCli/AliasVault.InstallCli.csproj" \
-c "$BUILD_CONFIGURATION" -a $TARGETARCH -o /app/publish /p:UseAppHost=false
-c "$BUILD_CONFIGURATION" \
-a "$TARGETARCH" \
-o /app/publish \
/p:UseAppHost=false

FROM base AS final
WORKDIR /app
Expand Down

0 comments on commit 14898c0

Please sign in to comment.