mirror of
https://github.com/bitwarden/server.git
synced 2025-04-24 22:32:22 -05:00
49 lines
1.5 KiB
Docker
49 lines
1.5 KiB
Docker
###############################################
|
|
# Build stage #
|
|
###############################################
|
|
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
|
|
|
# Docker buildx supplies the value for this arg
|
|
ARG TARGETPLATFORM
|
|
|
|
# Determine proper runtime value for .NET
|
|
# We put the value in a file to be read by later layers.
|
|
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
|
|
RID=linux-x64 ; \
|
|
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
|
|
RID=linux-arm64 ; \
|
|
elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
|
|
RID=linux-arm ; \
|
|
fi \
|
|
&& echo "RID=$RID" > /tmp/rid.txt
|
|
|
|
# Copy csproj files as distinct layers
|
|
WORKDIR /source
|
|
COPY util/Server/*.csproj ./util/Server/
|
|
COPY Directory.Build.props .
|
|
|
|
# Restore Server project dependencies and tools
|
|
WORKDIR /source/util/Server
|
|
RUN . /tmp/rid.txt && dotnet restore -r $RID
|
|
|
|
# Copy required project files
|
|
WORKDIR /source
|
|
COPY util/Server/. ./util/Server/
|
|
COPY .git/. ./.git/
|
|
|
|
# Build Server app
|
|
WORKDIR /source/util/Server
|
|
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Server --no-restore --no-self-contained -r $RID
|
|
|
|
WORKDIR /app
|
|
|
|
###############################################
|
|
# App stage #
|
|
###############################################
|
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
|
|
|
LABEL com.bitwarden.product="bitwarden"
|
|
|
|
# Copy app from the build stage
|
|
WORKDIR /bitwarden_server
|
|
COPY --from=build /app/Server ./ |