1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-02 10:12:16 -05:00
tangowithfoxtrot 7a99f5dc5d
Revert "build: we don't need to copy the .git dir"
This reverts commit 32c2f6236a894534de09ffe847ffff064a7174bd.
2025-04-30 13:35:38 -07:00

82 lines
2.5 KiB
Docker

###############################################
# Build stage #
###############################################
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG GIT_COMMIT
# 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 src/EventsProcessor/*.csproj ./src/EventsProcessor/
COPY src/Core/*.csproj ./src/Core/
COPY src/Infrastructure.Dapper/*.csproj ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/*.csproj ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/*.csproj ./src/SharedWeb/
COPY Directory.Build.props .
# Restore project dependencies and tools
WORKDIR /source/src/EventsProcessor
RUN . /tmp/rid.txt && dotnet restore -r $RID
# Copy required project files
WORKDIR /source
COPY src/EventsProcessor/. ./src/EventsProcessor/
COPY src/Core/. ./src/Core/
COPY src/Infrastructure.Dapper/. ./src/Infrastructure.Dapper/
COPY src/Infrastructure.EntityFramework/. ./src/Infrastructure.EntityFramework/
COPY src/SharedWeb/. ./src/SharedWeb/
COPY .git/. ./.git/
COPY .editorconfig /source
# Build project
WORKDIR /source/src/EventsProcessor
RUN . /tmp/rid.txt && dotnet publish \
--self-contained \
/p:PublishSingleFile=true \
/p:SourceRevisionId="$GIT_COMMIT" \
-r $RID \
-o out
WORKDIR /app
###############################################
# App stage #
###############################################
FROM mcr.microsoft.com/dotnet/aspnet:8.0
ARG TARGETPLATFORM
LABEL com.bitwarden.product="bitwarden"
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gosu \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy app from the build stage
# Copy app from the build stage
WORKDIR /app
COPY --from=build /source/src/EventsProcessor/out /app
COPY ./src/EventsProcessor/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
HEALTHCHECK CMD curl -f http://localhost:5000/alive || exit 1
CMD ["/entrypoint.sh"]