jakeswenson / BitBetter

Modify bit warden to provide my own licensing for self hosting
500 stars 112 forks source link

It works fine with Bitwarden unified. #154

Open ghost opened 1 year ago

ghost commented 1 year ago

Hi,

I just wanted to say that Bitbetter works fine on Bitwarden Unified, (running in kubernetes) I wrote this Dockerfile(It doesnt look that great, but it does work! 😄

A pre-generated certs directory is needed in the same folder as the Dockerfile.



# Build bitbetter
FROM mcr.microsoft.com/dotnet/sdk:6.0 as build

ENV COMMIT="b819fe0c7de96f6fec99db0524b66b2a5ab261e8"
COPY certs/cert.cert /newLicensing.cer

RUN set -e ;set -x;  cd / && git clone https://github.com/jakeswenson/BitBetter.git && \
cd /BitBetter && git checkout ${COMMIT} && \
cp -rp /BitBetter/src /src && \
cp -rp /src/bitBetter /src/identity && \
# change paths for bitwarden unified
sed -i 's#/app/Core.dll#/app/Api/Core.dll#g' /src/bitBetter/Program.cs && \
cd /src/bitBetter && \
dotnet restore && \
dotnet publish && \

# Build bitbetter for identity
# change path for bitwarden unified
sed -i 's#/app/Core.dll#/app/Identity/Core.dll#g' /src/identity/Program.cs && \
cd /src/identity && \
dotnet restore && \
dotnet publish && \

# build licensegen, when built, run the following in the created container:
# dotnet /licensegen/licenseGen.dll --core /app/Api/Core.dll --cert /certs/cert.pfx interactive
cd /src/licenseGen &&  \
        dotnet add package Newtonsoft.Json --version 13.0.1 && \
        dotnet restore && \
        dotnet publish

# Final Bitwarden image
FROM bitwarden/self-host:beta

# Import everything
COPY --chown=1000:1000 certs/* /certs/
COPY --chown=1000:1000 --from=build /src/licenseGen/bin/Debug/netcoreapp6.0/* /licensegen/
COPY --chown=1000:1000 --from=build /newLicensing.cer /newLicensing.cer
COPY --chown=1000:1000 --from=build /src/bitBetter/bin/Debug/netcoreapp6.0/publish/* /bitBetter/
COPY --chown=1000:1000 --from=build /src/identity/bin/Debug/netcoreapp6.0/publish/* /identity/

# Run bitbetter to modify api core.dll
RUN cd /tmp && dotnet /bitBetter/bitBetter.dll && \
mv /tmp/modified.dll /app/Api/Core.dll && \

# Run bitbetter to modify identify core.dll.
cd /tmp && dotnet /identity/bitBetter.dll && \
mv /tmp/modified.dll /app/Identity/Core.dll && \

# Remove temp files
rm -rf /bitBetter /identity /newLicensing.cer
GieltjE commented 1 year ago

Literaly been working on a new structure to support it all, but have yet to crack my final mistake (won't accept custom licenses for now), see #155

Would you be interested in working together?

GieltjE commented 1 year ago

Working on windows now too, at least we have some options now :)