You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.8 KiB
60 lines
1.8 KiB
############################################### |
|
# Build stage # |
|
############################################### |
|
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine 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-musl-x64 ; \ |
|
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ |
|
RID=linux-musl-arm64 ; \ |
|
elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ |
|
RID=linux-musl-arm ; \ |
|
fi \ |
|
&& echo "RID=$RID" > /tmp/rid.txt |
|
|
|
# Copy required project files |
|
WORKDIR /source |
|
COPY . ./ |
|
|
|
# Restore project dependencies and tools |
|
WORKDIR /source/util/Setup |
|
RUN . /tmp/rid.txt && dotnet restore -r $RID |
|
|
|
# Build project |
|
WORKDIR /source/util/Setup |
|
RUN . /tmp/rid.txt && dotnet publish \ |
|
-c release \ |
|
--no-restore \ |
|
--self-contained \ |
|
/p:PublishSingleFile=true \ |
|
-r $RID \ |
|
-o out |
|
|
|
############################################### |
|
# App stage # |
|
############################################### |
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine |
|
|
|
ARG TARGETPLATFORM |
|
LABEL com.bitwarden.product="bitwarden" com.bitwarden.project="setup" |
|
ENV SSL_CERT_DIR=/etc/bitwarden/ca-certificates |
|
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false |
|
|
|
RUN apk add --no-cache curl \ |
|
openssl \ |
|
icu-libs \ |
|
shadow \ |
|
&& apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community gosu |
|
|
|
# Copy app from the build stage |
|
WORKDIR /app |
|
COPY --from=build /source/util/Setup/out . |
|
COPY util/Setup/entrypoint.sh /entrypoint.sh |
|
RUN chmod +x /entrypoint.sh |
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
|